[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-evdev: Changes to 'upstream-unstable'



Rebased ref, commits from common ancestor:
commit 6a3beab6137b262fc847093ed5fa51ff70df6a21
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jan 8 15:11:59 2016 +1000

    evdev 2.10.1
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index cc60ce7..3fe2012 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-evdev],
-        [2.10.0],
+        [2.10.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-evdev])
 AC_CONFIG_SRCDIR([Makefile.am])

commit d7e61a7074b802b49f57549530b289bbaa0a4855
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Nov 10 14:35:51 2015 +1000

    Only map x and y to axes 0 and 1
    
    The Logitech G600 has one device with all axes north of ABS_MISC. The current
    code assigns ABS_MISC as first axis to map to axis 0, i.e. x. On button press,
    one node sends the BTN_LEFT but the other node sends an ABS_MISC with a 1 0
    value. ABS_MISC is mapped to axis 0, this moves the pointer to (0, y) on
    every button click.
    
    Avoid this by simply mapping any axis other than x/y to at least axis 3, and
    make sure we only override the MT 0/1 axes when we actually have MT axes.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=92856
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>

diff --git a/src/evdev.c b/src/evdev.c
index 17d9d61..3176660 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1377,7 +1377,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
     }
     atoms = malloc((pEvdev->num_vals + num_mt_axes) * sizeof(Atom));
 
-    i = 0;
+    i = 2;
     for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
         int j;
         pEvdev->abs_axis_map[axis] = -1;
@@ -1385,9 +1385,14 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
             is_blacklisted_axis(axis))
             continue;
 
-        mapping = i;
+        if (axis == ABS_X)
+            mapping = 0;
+        else if (axis == ABS_Y)
+            mapping = 1;
+        else
+            mapping = i;
 
-        for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
+        for (j = 0; !pEvdev->fake_mt && j < ArrayLength(mt_axis_mappings); j++)
         {
             if (mt_axis_mappings[j].code == axis)
                 mt_axis_mappings[j].mapping = mapping;

commit 01e7ac48546d4534fa420ea1873214e738ea125d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Oct 28 14:28:20 2015 +1000

    evdev 2.10.0
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index f6fd2e4..cc60ce7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-evdev],
-        [2.9.99],
+        [2.10.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-evdev])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 034be31159f22ce28d84994d541a45ee44963fd8
Author: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
Date:   Tue Jan 20 00:44:40 2015 +0100

    Add "Resolution" option for mice to the evdev driver
    
    It can be used to scale the resolution of a mouse to that of a 1000 DPI
    mouse. This can be useful to make high resolution mice less sensitive
    without turning off acceleration. The target of 1000 DPI is used as the
    same default is used in libinput. If the option is not set no scaling
    will be done.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=88134
    Signed-off-by: Thomas Hindoe Paaboel Andersen <phomes@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/man/evdev.man b/man/evdev.man
index 06613fc..e70ae1f 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -238,6 +238,12 @@ Default: "1".  Property: "Evdev Scrolling Distance".
 .BI "Option \*qDialDelta\*q \*q" integer \*q
 The amount of motion considered one unit of turning the dial.  Default: "1".
 Property: "Evdev Scrolling Distance".
+.TP 7
+.BI "Option \*qResolution\*q \*q" integer \*q
+Sets the resolution of the device in dots per inch. The resolution is used
+to scale relative motion events from mouse devices to 1000 DPI resolution. This
+can be used to make high resolution mice less sensitive without turning off
+acceleration. If set to 0 no scaling will be performed. Default: "0".
 
 .SH SUPPORTED PROPERTIES
 The following properties are provided by the
diff --git a/src/emuThird.c b/src/emuThird.c
index 7461767..5f14d33 100644
--- a/src/emuThird.c
+++ b/src/emuThird.c
@@ -229,8 +229,8 @@ Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
     {
         if (valuator_mask_isset(vals, axis))
         {
-            int delta = valuator_mask_get(vals, axis) - emu3B->startpos[axis];
-            if (abs(delta) > emu3B->threshold)
+            double delta = valuator_mask_get_double(vals, axis) - emu3B->startpos[axis];
+            if (fabs(delta) > emu3B->threshold)
                 cancel = TRUE;
         }
         axis++;
@@ -248,7 +248,7 @@ Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
  * emulation.
  */
 void
-Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy)
+Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy)
 {
     EvdevPtr          pEvdev = pInfo->private;
     struct emulate3B *emu3B  = &pEvdev->emulate3B;
@@ -260,8 +260,8 @@ Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy)
     emu3B->delta[1] += dy;
     emu3B->flags |= EVDEV_RELATIVE_EVENTS;
 
-    if (abs(emu3B->delta[0]) > emu3B->threshold ||
-        abs(emu3B->delta[1]) > emu3B->threshold)
+    if (fabs(emu3B->delta[0]) > emu3B->threshold ||
+        fabs(emu3B->delta[1]) > emu3B->threshold)
     {
         Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
         Evdev3BCancel(pInfo);
diff --git a/src/evdev.c b/src/evdev.c
index da25b56..17d9d61 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -25,6 +25,7 @@
  *	Adam Jackson (ajax@redhat.com)
  *	Peter Hutterer (peter.hutterer@redhat.com)
  *	Oliver McFadden (oliver.mcfadden@nokia.com)
+ *	Thomas H.P. Andersen (phomes@gmail.com)
  */
 
 #ifdef HAVE_CONFIG_H
@@ -432,31 +433,36 @@ EvdevProcessValuators(InputInfoPtr pInfo)
 
     /* Apply transformations on relative coordinates */
     if (pEvdev->rel_queued) {
-        int deltaX = 0, deltaY = 0;
+        double deltaX = 0, deltaY = 0;
 
         if (valuator_mask_isset(pEvdev->rel_vals, REL_X))
-            deltaX = valuator_mask_get(pEvdev->rel_vals, REL_X);
+            deltaX = valuator_mask_get_double(pEvdev->rel_vals, REL_X);
         if (valuator_mask_isset(pEvdev->rel_vals, REL_Y))
-            deltaY = valuator_mask_get(pEvdev->rel_vals, REL_Y);
+            deltaY = valuator_mask_get_double(pEvdev->rel_vals, REL_Y);
 
         if (pEvdev->swap_axes) {
-            int tmp = deltaX;
+            double tmp = deltaX;
             deltaX = deltaY;
             deltaY = tmp;
         }
 
+        if (pEvdev->resolution > 0) {
+            deltaX *= DEFAULT_MOUSE_DPI / pEvdev->resolution;
+            deltaY *= DEFAULT_MOUSE_DPI / pEvdev->resolution;
+        }
+
         if (pEvdev->invert_x)
             deltaX *= -1;
         if (pEvdev->invert_y)
             deltaY *= -1;
 
         if (deltaX)
-            valuator_mask_set(pEvdev->rel_vals, REL_X, deltaX);
+            valuator_mask_set_double(pEvdev->rel_vals, REL_X, deltaX);
         else
             valuator_mask_unset(pEvdev->rel_vals, REL_X);
 
         if (deltaY)
-            valuator_mask_set(pEvdev->rel_vals, REL_Y, deltaY);
+            valuator_mask_set_double(pEvdev->rel_vals, REL_Y, deltaY);
         else
             valuator_mask_unset(pEvdev->rel_vals, REL_Y);
 
@@ -2293,6 +2299,12 @@ EvdevProbe(InputInfoPtr pInfo)
         pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
         pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
 
+        pEvdev->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0);
+        if (pEvdev->resolution < 0) {
+            xf86IDrvMsg(pInfo, X_ERROR, "Resolution must be a positive number");
+            pEvdev->resolution = 0;
+        }
+
         str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
         if (str) {
             num_calibration = sscanf(str, "%d %d %d %d",
diff --git a/src/evdev.h b/src/evdev.h
index 0f71d78..4d44d2b 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -97,6 +97,8 @@
 /* Number of longs needed to hold the given number of bits */
 #define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
 
+#define DEFAULT_MOUSE_DPI 1000.0
+
 /* Function key mode */
 enum fkeymode {
     FKEYMODE_UNKNOWN = 0,
@@ -170,6 +172,7 @@ typedef struct {
     BOOL swap_axes;
     BOOL invert_x;
     BOOL invert_y;
+    int resolution;
 
     unsigned int abs_queued, rel_queued, prox_queued;
 
@@ -191,7 +194,7 @@ typedef struct {
         int                 button;      /* phys button to emit */
         int                 threshold;   /* move threshold in dev coords */
         OsTimerPtr          timer;
-        int                 delta[2];    /* delta x/y, accumulating */
+        double              delta[2];    /* delta x/y, accumulating */
         int                 startpos[2]; /* starting pos for abs devices */
         int                 flags;       /* remember if we had rel or abs movement */
     } emulate3B;
@@ -269,7 +272,7 @@ BOOL Evdev3BEmuFilterEvent(InputInfoPtr, int, BOOL);
 void Evdev3BEmuPreInit(InputInfoPtr pInfo);
 void Evdev3BEmuOn(InputInfoPtr);
 void Evdev3BEmuFinalize(InputInfoPtr);
-void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy);
+void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy);
 void Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals);
 
 /* Mouse Wheel emulation */

commit 66c997886424a20e92ce30fcfda46cbb5c7352ab
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue May 5 15:34:07 2015 +1000

    Add the default evdev config
    
    This used to be part of the server but now that we have two drivers doing the
    same thing (libinput, evdev) shift the configuration defaults to the driver.
    This way you get what you install.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=89023
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/10-evdev.conf b/10-evdev.conf
new file mode 100644
index 0000000..cc83ab2
--- /dev/null
+++ b/10-evdev.conf
@@ -0,0 +1,40 @@
+#
+# Catch-all evdev loader for udev-based systems
+# We don't simply match on any device since that also adds accelerometers
+# and other devices that we don't really want to use. The list below
+# matches everything but joysticks.
+
+Section "InputClass"
+        Identifier "evdev pointer catchall"
+        MatchIsPointer "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev keyboard catchall"
+        MatchIsKeyboard "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev touchpad catchall"
+        MatchIsTouchpad "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev tablet catchall"
+        MatchIsTablet "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
+
+Section "InputClass"
+        Identifier "evdev touchscreen catchall"
+        MatchIsTouchscreen "on"
+        MatchDevicePath "/dev/input/event*"
+        Driver "evdev"
+EndSection
diff --git a/Makefile.am b/Makefile.am
index 00c7940..1cc3ea6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,6 +28,7 @@ MAINTAINERCLEANFILES = ChangeLog INSTALL
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = xorg-evdev.pc
 
+dist_xorgconf_DATA = 10-evdev.conf
 
 .PHONY: ChangeLog INSTALL
 
diff --git a/configure.ac b/configure.ac
index e0d480a..f6fd2e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,13 @@ AC_ARG_WITH(xorg-module-dir,
 inputdir=${moduledir}/input
 AC_SUBST(inputdir)
 
+AC_ARG_WITH(xorg-conf-dir,
+            AC_HELP_STRING([--with-xorg-conf-dir=DIR],
+                           [Default xorg.conf.d directory [[default=$prefix/share/X11/xorg.conf.d/]]]),
+            [xorgconfdir="$withval"],
+            [xorgconfdir="$prefix/share/X11/xorg.conf.d"])
+AC_SUBST(xorgconfdir)
+
 # X Server SDK location is required to install evdev header files
 # This location is also relayed in the xorg-evdev.pc file
 sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`

commit 0d3494eadfde7e8d30e1bae97cfa6b36e5128a11
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Mar 27 11:41:50 2015 +1000

    Bump to 2.9.99
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 277358d..e0d480a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-evdev],
-        [2.9.1],
+        [2.9.99],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-evdev])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 56a5e6716204916691a67082e3e6a1698df2061b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 16 07:55:34 2015 +1000

    Unconditionally require mtdev
    
    Missing from 2c9f4f0380d
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index e53177e..277358d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,7 @@ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.12] xproto [inputproto >= 2.1.99.3])
 PKG_CHECK_MODULES(UDEV, libudev)
 
 PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
-PKG_CHECK_MODULES(MTDEV, mtdev, HAVE_MTDEV="yes", HAVE_MTDEV="no")
+PKG_CHECK_MODULES(MTDEV, mtdev)
 
 # Define a configure option for an alternate input module directory
 AC_ARG_WITH(xorg-module-dir,

commit 74433f788acf41a43da54269eb1b73c407f3ceba
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Mar 13 11:05:03 2015 +1000

    Always check for a return value on creating a property
    
    Mostly to make static analyzers happy
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 360bbb8..da25b56 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2828,6 +2828,9 @@ EvdevInitProperty(DeviceIntPtr dev)
                                 strlen(XI_PROP_VIRTUAL_DEVICE), TRUE);
         rc = XIChangeDeviceProperty(dev, prop_virtual, XA_INTEGER, 8,
                                     PropModeReplace, 1, &virtual, FALSE);
+        if (rc != Success)
+            return;
+
         XISetDevicePropertyDeletable(dev, prop_virtual, FALSE);
     }
 
@@ -2900,8 +2903,11 @@ EvdevInitProperty(DeviceIntPtr dev)
             }
 
             EvdevInitAxesLabels(pEvdev, mode, num_axes, atoms);
-            XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
-                                   PropModeReplace, num_axes, atoms, FALSE);
+            rc = XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
+                                        PropModeReplace, num_axes, atoms, FALSE);
+            if (rc != Success)
+                return;
+
             XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
         }
         /* Button labelling */
@@ -2909,8 +2915,11 @@ EvdevInitProperty(DeviceIntPtr dev)
         {
             Atom atoms[EVDEV_MAXBUTTONS];
             EvdevInitButtonLabels(pEvdev, EVDEV_MAXBUTTONS, atoms);
-            XIChangeDeviceProperty(dev, prop_btn_label, XA_ATOM, 32,
-                                   PropModeReplace, pEvdev->num_buttons, atoms, FALSE);
+            rc = XIChangeDeviceProperty(dev, prop_btn_label, XA_ATOM, 32,
+                                        PropModeReplace, pEvdev->num_buttons, atoms, FALSE);
+            if (rc != Success)
+                return;
+
             XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE);
         }
 
@@ -2922,8 +2931,11 @@ EvdevInitProperty(DeviceIntPtr dev)
             };
             prop_scroll_dist = MakeAtom(EVDEV_PROP_SCROLL_DISTANCE,
                                         strlen(EVDEV_PROP_SCROLL_DISTANCE), TRUE);
-            XIChangeDeviceProperty(dev, prop_scroll_dist, XA_INTEGER, 32,
-                                   PropModeReplace, 3, smooth_scroll_values, FALSE);
+            rc = XIChangeDeviceProperty(dev, prop_scroll_dist, XA_INTEGER, 32,
+                                        PropModeReplace, 3, smooth_scroll_values, FALSE);
+            if (rc != Success)
+                return;
+
             XISetDevicePropertyDeletable(dev, prop_scroll_dist, FALSE);
         }
 

commit fdc33809de2751c164183df2310a71732be579f3
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Mar 13 10:58:01 2015 +1000

    Invert a condition to reduce nesting
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 639e4a1..360bbb8 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2759,22 +2759,22 @@ static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms)
 
     for (button = BTN_MISC; button < BTN_JOYSTICK; button++)
     {
-        if (libevdev_has_event_code(pEvdev->dev, EV_KEY, button))
-        {
-            int group = (button % 0x100)/16;
-            int idx = button - ((button/16) * 16);
+        int group = (button % 0x100)/16;
+        int idx = button - ((button/16) * 16);
+
+        if (!libevdev_has_event_code(pEvdev->dev, EV_KEY, button))
+            continue;
 
-            if (!btn_labels[group][idx])
-                continue;
+        if (!btn_labels[group][idx])
+            continue;
 
-            atom = XIGetKnownProperty(btn_labels[group][idx]);
-            if (!atom)
-                continue;
+        atom = XIGetKnownProperty(btn_labels[group][idx]);
+        if (!atom)
+            continue;
 
-            /* Props are 0-indexed, button numbers start with 1 */
-            bmap = EvdevUtilButtonEventToButtonNumber(pEvdev, button) - 1;
-            atoms[bmap] = atom;
-        }
+        /* Props are 0-indexed, button numbers start with 1 */
+        bmap = EvdevUtilButtonEventToButtonNumber(pEvdev, button) - 1;
+        atoms[bmap] = atom;
     }
 
     /* wheel buttons, hardcoded anyway */

commit 38e107a39fb4a0b630ee5adb5870c91dbc27abde
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 11 14:58:04 2015 +1000

    Disable axis faking and MT event processing on fake MT devices
    
    This effectively disables all axes >= ABS_MT_SLOT on those devices. But at
    least the device comes up without an error and it didn't work correctly
    beforehand anyway.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=89473
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/src/evdev.c b/src/evdev.c
index 7ce7405..639e4a1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -696,6 +696,9 @@ EvdevProcessTouchEvent(InputInfoPtr pInfo, struct input_event *ev)
         !libevdev_has_event_code(pEvdev->dev, EV_ABS, ABS_MT_SLOT))
         return;
 
+    if (pEvdev->fake_mt)
+        return;
+
     if (ev->code == ABS_MT_SLOT) {
         EvdevProcessTouch(pInfo);
         if (ev->value >= num_slots(pEvdev) ) {
@@ -1174,6 +1177,9 @@ EvdevAddFakeSingleTouchAxes(InputInfoPtr pInfo)
     int num_axes = 0;
     int i;
 
+    if (pEvdev->fake_mt)
+        return 0;
+
     /* Android drivers often have ABS_MT_POSITION_X but not ABS_X.
        Loop over the MT->legacy axis table and add fake axes. */
     for (i = 0; i < ArrayLength(mt_axis_mappings); i++)
@@ -1207,6 +1213,9 @@ EvdevCountMTAxes(EvdevPtr pEvdev, int *num_mt_axes_total,
 {
     int axis;
 
+    if (pEvdev->fake_mt)
+        return;
+
     /* Absolute multitouch axes: adjust mapping and axes counts. */
     for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
     {
@@ -2199,6 +2208,10 @@ EvdevProbe(InputInfoPtr pInfo)
         }
     }
 
+    if (libevdev_has_event_code(pEvdev->dev, EV_ABS, ABS_MT_SLOT) &&
+        libevdev_get_num_slots(pEvdev->dev) == -1)
+        pEvdev->fake_mt = TRUE;
+
     if (ignore_abs && has_abs_axes)
     {
         xf86IDrvMsg(pInfo, X_INFO, "Absolute axes present but ignored.\n");
@@ -2220,6 +2233,8 @@ EvdevProbe(InputInfoPtr pInfo)
                     pEvdev->flags |= EVDEV_BUTTON_EVENTS;
                 }
             }
+            if (pEvdev->fake_mt)
+                xf86IDrvMsg(pInfo, X_PROBED, "Fake MT device detected\n");
         }
 
         if ((libevdev_has_event_code(pEvdev->dev, EV_ABS, ABS_X) &&
diff --git a/src/evdev.h b/src/evdev.h
index 4aa7652..0f71d78 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -161,6 +161,7 @@ typedef struct {
         enum SlotState state;
     } *slots;
     struct mtdev *mtdev;
+    BOOL fake_mt;
 
     int flags;
     int in_proximity;           /* device in proximity */

commit b6176cff5a3fbccc3708721958e9fb346518f57e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 11 13:44:28 2015 +1000

    Invert two conditions to reduce nesting
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/src/evdev.c b/src/evdev.c
index dacd3e3..7ce7405 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1180,22 +1180,22 @@ EvdevAddFakeSingleTouchAxes(InputInfoPtr pInfo)
     {
         int mt_code = mt_axis_mappings[i].mt_code;
         int code = mt_axis_mappings[i].code;
+        const struct input_absinfo* abs;
 
-        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_code) &&
-            !libevdev_has_event_code(pEvdev->dev, EV_ABS, code))
+        if (!libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_code) ||
+            libevdev_has_event_code(pEvdev->dev, EV_ABS, code))
+            continue;
+
+        abs = libevdev_get_abs_info(pEvdev->dev, mt_code);
+        if (libevdev_enable_event_code(pEvdev->dev, EV_ABS, code, abs))
         {
-            const struct input_absinfo* abs;
-            abs = libevdev_get_abs_info(pEvdev->dev, mt_code);
-            if (libevdev_enable_event_code(pEvdev->dev, EV_ABS, code, abs))
-            {
-                xf86IDrvMsg(pInfo, X_ERROR, "Failed to fake axis %s.\n",
-                            libevdev_event_code_get_name(EV_ABS, code));
-                return -1;
-            }
-            xf86IDrvMsg(pInfo, X_INFO, "Faking axis %s.\n",
+            xf86IDrvMsg(pInfo, X_ERROR, "Failed to fake axis %s.\n",
                         libevdev_event_code_get_name(EV_ABS, code));
-            num_axes++;
+            return -1;
         }
+        xf86IDrvMsg(pInfo, X_INFO, "Faking axis %s.\n",
+                    libevdev_event_code_get_name(EV_ABS, code));
+        num_axes++;
     }
 
     return num_axes;
@@ -1210,30 +1210,30 @@ EvdevCountMTAxes(EvdevPtr pEvdev, int *num_mt_axes_total,
     /* Absolute multitouch axes: adjust mapping and axes counts. */
     for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
     {
-        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, axis))
-        {
-            int j;
-            Bool skip = FALSE;
+        int j;
+        Bool skip = FALSE;
 
-            /* Setup mapping if axis is in MT->legacy axis table. */
-            for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
-            {
-                if (mt_axis_mappings[j].mt_code == axis &&
-                    libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_axis_mappings[j].code))
-                {
-                    mt_axis_mappings[j].needs_mapping = TRUE;
-                    skip = TRUE;
-                }
-            }
+        if (!libevdev_has_event_code(pEvdev->dev, EV_ABS, axis))
+            continue;
 
-            if (!is_blacklisted_axis(axis))
+        /* Setup mapping if axis is in MT->legacy axis table. */
+        for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
+        {
+            if (mt_axis_mappings[j].mt_code == axis &&
+                libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_axis_mappings[j].code))
             {
-                (*num_mt_axes_total)++;
-                if (!skip)
-                    (*num_mt_axes)++;
+                mt_axis_mappings[j].needs_mapping = TRUE;
+                skip = TRUE;
             }
-            (*num_axes)--;
         }
+
+        if (!is_blacklisted_axis(axis))
+        {
+            (*num_mt_axes_total)++;
+            if (!skip)
+                (*num_mt_axes)++;
+        }
+        (*num_axes)--;
     }
 }
 

commit 37afebfb67609f04f9c1cdea983e7006ee2d59e5
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 11 13:47:32 2015 +1000

    Factor out MT axis counting into a separate function
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/src/evdev.c b/src/evdev.c
index 1b7b7fd..dacd3e3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1201,6 +1201,42 @@ EvdevAddFakeSingleTouchAxes(InputInfoPtr pInfo)
     return num_axes;
 }
 
+static void
+EvdevCountMTAxes(EvdevPtr pEvdev, int *num_mt_axes_total,
+                 int *num_mt_axes, int *num_axes)
+{
+    int axis;
+
+    /* Absolute multitouch axes: adjust mapping and axes counts. */
+    for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
+    {
+        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, axis))
+        {
+            int j;
+            Bool skip = FALSE;
+
+            /* Setup mapping if axis is in MT->legacy axis table. */
+            for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
+            {
+                if (mt_axis_mappings[j].mt_code == axis &&
+                    libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_axis_mappings[j].code))
+                {
+                    mt_axis_mappings[j].needs_mapping = TRUE;
+                    skip = TRUE;
+                }
+            }
+
+            if (!is_blacklisted_axis(axis))
+            {
+                (*num_mt_axes_total)++;
+                if (!skip)
+                    (*num_mt_axes)++;
+            }
+            (*num_axes)--;
+        }
+    }
+}
+
 static int
 EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
 {
@@ -1235,34 +1271,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
 
     num_axes += num_faked_axes;
 
-    /* Absolute multitouch axes: adjust mapping and axes counts. */
-    for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
-    {
-        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, axis))
-        {
-            int j;
-            Bool skip = FALSE;
-
-            /* Setup mapping if axis is in MT->legacy axis table. */
-            for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
-            {
-                if (mt_axis_mappings[j].mt_code == axis &&
-                    libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_axis_mappings[j].code))
-                {
-                    mt_axis_mappings[j].needs_mapping = TRUE;
-                    skip = TRUE;
-                }
-            }
-
-            if (!is_blacklisted_axis(axis))
-            {
-                num_mt_axes_total++;
-                if (!skip)
-                    num_mt_axes++;
-            }
-            num_axes--;
-        }
-    }
+    EvdevCountMTAxes(pEvdev, &num_mt_axes_total, &num_mt_axes, &num_axes);
 
     /* Panic if, after faking ABS_X etc, we still only have mt-axes. */
     if (num_axes == 0 && num_mt_axes > 0) {

commit 5b5ae1786cb4b2ea35720bacf18f252223b2b2ec
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 11 13:29:19 2015 +1000

    Split android axis simulation into a helper function
    
    No functional changes
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/src/evdev.c b/src/evdev.c
index af691f5..1b7b7fd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1167,6 +1167,39 @@ is_blacklisted_axis(int axis)
     }
 }
 
+static int
+EvdevAddFakeSingleTouchAxes(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    int num_axes = 0;
+    int i;
+
+    /* Android drivers often have ABS_MT_POSITION_X but not ABS_X.
+       Loop over the MT->legacy axis table and add fake axes. */
+    for (i = 0; i < ArrayLength(mt_axis_mappings); i++)
+    {
+        int mt_code = mt_axis_mappings[i].mt_code;
+        int code = mt_axis_mappings[i].code;
+
+        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_code) &&
+            !libevdev_has_event_code(pEvdev->dev, EV_ABS, code))
+        {
+            const struct input_absinfo* abs;
+            abs = libevdev_get_abs_info(pEvdev->dev, mt_code);
+            if (libevdev_enable_event_code(pEvdev->dev, EV_ABS, code, abs))
+            {
+                xf86IDrvMsg(pInfo, X_ERROR, "Failed to fake axis %s.\n",
+                            libevdev_event_code_get_name(EV_ABS, code));
+                return -1;
+            }
+            xf86IDrvMsg(pInfo, X_INFO, "Faking axis %s.\n",
+                        libevdev_event_code_get_name(EV_ABS, code));
+            num_axes++;
+        }
+    }
+
+    return num_axes;
+}
 
 static int
 EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
@@ -1178,6 +1211,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
     int num_mt_axes = 0, /* number of MT-only axes */
         num_mt_axes_total = 0; /* total number of MT axes, including
                                   double-counted ones, excluding blacklisted */
+    int num_faked_axes;
     Atom *atoms;
     int mapping = 0;
 
@@ -1195,28 +1229,11 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
     if (num_axes < 1)
         goto out;
 
-    /* Android drivers often have ABS_MT_POSITION_X but not ABS_X.
-       Loop over the MT->legacy axis table and add fake axes. */
-    for (i = 0; i < ArrayLength(mt_axis_mappings); i++)
-    {
-        int mt_code = mt_axis_mappings[i].mt_code;
-        int code = mt_axis_mappings[i].code;
-        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_code) &&
-            !libevdev_has_event_code(pEvdev->dev, EV_ABS, code))
-        {
-            const struct input_absinfo* abs;
-            abs = libevdev_get_abs_info(pEvdev->dev, mt_code);
-            if (libevdev_enable_event_code(pEvdev->dev, EV_ABS, code, abs))
-            {
-                xf86IDrvMsg(pInfo, X_ERROR, "Failed to fake axis %s.\n",
-                            libevdev_event_code_get_name(EV_ABS, code));
-                goto out;
-            }
-            xf86IDrvMsg(pInfo, X_INFO, "Faking axis %s.\n",
-                        libevdev_event_code_get_name(EV_ABS, code));
-            num_axes++;
-        }
-    }
+    num_faked_axes = EvdevAddFakeSingleTouchAxes(pInfo);
+    if (num_faked_axes < 0)
+        goto out;
+
+    num_axes += num_faked_axes;
 
     /* Absolute multitouch axes: adjust mapping and axes counts. */
     for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)

commit 2c9f4f0380dd5bb5966a6eee34c8e0ec0c98ed17
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 11 13:22:19 2015 +1000

    Require multitouch/smooth scrolling dependencies
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>

diff --git a/configure.ac b/configure.ac
index 46f3dc7..e53177e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,19 +44,11 @@ XORG_MACROS_VERSION(1.8)
 XORG_DEFAULT_OPTIONS
 
 # Obtain compiler/linker options from server and required extensions
-PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto inputproto)
+PKG_CHECK_MODULES(XORG, [xorg-server >= 1.12] xproto [inputproto >= 2.1.99.3])
 PKG_CHECK_MODULES(UDEV, libudev)
 
-PKG_CHECK_MODULES(XI22, [inputproto >= 2.1.99.3] [xorg-server >= 1.11.99.901], HAVE_XI22="yes", HAVE_XI22="no")
 PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
-
-if test "x$HAVE_XI22" = xyes; then
-        # Obtain compiler/linker options for mtdev
-        PKG_CHECK_MODULES(MTDEV, mtdev, HAVE_MTDEV="yes", HAVE_MTDEV="no")
-fi
-if test "x$HAVE_XI22" = xyes && test "x$HAVE_MTDEV" = xyes; then
-        AC_DEFINE(MULTITOUCH, 1, [XI2.2 available])
-fi
+PKG_CHECK_MODULES(MTDEV, mtdev, HAVE_MTDEV="yes", HAVE_MTDEV="no")
 
 # Define a configure option for an alternate input module directory
 AC_ARG_WITH(xorg-module-dir,
diff --git a/src/evdev.c b/src/evdev.c
index 9c1a4d3..af691f5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -53,9 +53,7 @@
 #include <X11/Xatom.h>
 #include <evdev-properties.h>
 #include <xserver-properties.h>
-#ifdef MULTITOUCH
 #include <mtdev-plumbing.h>
-#endif
 
 #ifndef XI_PROP_PRODUCT_ID
 #define XI_PROP_PRODUCT_ID "Device Product ID"
@@ -259,12 +257,6 @@ out:
     return rc;
 }
 
-#ifndef HAVE_SMOOTH_SCROLLING
-static int wheel_up_button = 4;
-static int wheel_down_button = 5;
-static int wheel_left_button = 6;
-static int wheel_right_button = 7;
-#endif
 
 static EventQueuePtr
 EvdevNextInQueue(InputInfoPtr pInfo)
@@ -325,7 +317,6 @@ EvdevQueueProximityEvent(InputInfoPtr pInfo, int value)
     }
 }
 
-#ifdef MULTITOUCH
 void
 EvdevQueueTouchEvent(InputInfoPtr pInfo, unsigned int touch, ValuatorMask *mask,
                      uint16_t evtype)
@@ -339,7 +330,6 @@ EvdevQueueTouchEvent(InputInfoPtr pInfo, unsigned int touch, ValuatorMask *mask,
         pQueue->val = evtype;
     }
 }
-#endif
 
 /**
  * Post button event right here, right now.
@@ -611,23 +601,6 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
     value = ev->value;
 
     switch (ev->code) {
-#ifndef HAVE_SMOOTH_SCROLLING
-        case REL_WHEEL:
-            if (value > 0)
-                EvdevQueueButtonClicks(pInfo, wheel_up_button, value);
-            else if (value < 0)
-                EvdevQueueButtonClicks(pInfo, wheel_down_button, -value);
-            break;
-
-        case REL_DIAL:
-        case REL_HWHEEL:
-            if (value > 0)
-                EvdevQueueButtonClicks(pInfo, wheel_right_button, value);
-            else if (value < 0)
-                EvdevQueueButtonClicks(pInfo, wheel_left_button, -value);
-            break;
-        /* We don't post wheel events as axis motion. */
-#endif
         default:
             /* Ignore EV_REL events if we never set up for them. */
             if (!(pEvdev->flags & EVDEV_RELATIVE_EVENTS) &&


Reply to: