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

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



 autogen.sh        |    4 
 configure.ac      |    3 
 man/evdev.man     |    6 
 src/Makefile.am   |    5 
 src/axis_labels.h |  198 +++++++++++++
 src/emuMB.c       |    4 
 src/emuWheel.c    |    8 
 src/evdev.c       |  782 +++++++++++++++++++++++++++---------------------------
 src/evdev.h       |   15 -
 9 files changed, 628 insertions(+), 397 deletions(-)

New commits:
commit 8a9b1ec6b58a36910a03f3e8b1f9bc8d91f87204
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Jul 11 11:09:24 2013 +1000

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

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

commit 356565111a6bb98f15fbaaf4f527aed8c87b477b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Jun 27 05:47:38 2013 +1000

    Don't allow a wheel emulation inertia of 0 (#66125)
    
    Inertia of 0 results in an infinite loop of events being sent to the server.
    
    X.Org Bug 66125 <http://bugs.freedesktop.org/show_bug.cgi?id=66125>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/emuWheel.c b/src/emuWheel.c
index 5774930..81b777f 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -392,7 +392,7 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
 
         inertia = *((CARD16*)val->data);
 
-        if (inertia < 0)
+        if (inertia <= 0)
             return BadValue;
 
         if (!checkonly)

commit fff3a60fbf5c81b337ae4eaf160feacdfc8c2465
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed May 29 13:26:57 2013 +1000

    Use EvdevBitIsSet, not the server's BitIsOn
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 34cd3a1..ba2a98c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1267,7 +1267,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes)
             for (j = 0; j < ArrayLength(mt_axis_mappings); j++)
             {
                 if (mt_axis_mappings[j].mt_code == axis &&
-                    BitIsOn(pEvdev->abs_bitmask, mt_axis_mappings[j].code))
+                    EvdevBitIsSet(pEvdev->abs_bitmask, mt_axis_mappings[j].code))
                 {
                     mt_axis_mappings[j].needs_mapping = TRUE;
                     skip = TRUE;

commit 8f209ac60d10ba61aa6ea2bec02dbfa54ebe8f17
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed May 29 07:18:19 2013 +1000

    Drop cached name and led_bitmask - nothing reads this
    
    Both fields are write-only as of xf86-input-evdev-2.5.99.902-1-g1ced7ec
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 86af151..34cd3a1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1983,12 +1983,10 @@ EvdevCache(InputInfoPtr pInfo)
     int i, len;
     struct input_id id;
 
-    char name[1024]                  = {0};
     unsigned long bitmask[NLONGS(EV_CNT)]      = {0};
     unsigned long key_bitmask[NLONGS(KEY_CNT)] = {0};
     unsigned long rel_bitmask[NLONGS(REL_CNT)] = {0};
     unsigned long abs_bitmask[NLONGS(ABS_CNT)] = {0};
-    unsigned long led_bitmask[NLONGS(LED_CNT)] = {0};
 
 
     if (ioctl(pInfo->fd, EVIOCGID, &id) < 0)
@@ -2000,13 +1998,6 @@ EvdevCache(InputInfoPtr pInfo)
     pEvdev->id_vendor = id.vendor;
     pEvdev->id_product = id.product;
 
-    if (ioctl(pInfo->fd, EVIOCGNAME(sizeof(name) - 1), name) < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
-        goto error;
-    }
-
-    strcpy(pEvdev->name, name);
-
     len = ioctl(pInfo->fd, EVIOCGBIT(0, sizeof(bitmask)), bitmask);
     if (len < 0) {
         xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for bitmask failed: %s\n",
@@ -2034,15 +2025,6 @@ EvdevCache(InputInfoPtr pInfo)
 
     memcpy(pEvdev->abs_bitmask, abs_bitmask, len);
 
-    len = ioctl(pInfo->fd, EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask);
-    if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_LED failed: %s\n",
-                    strerror(errno));
-        goto error;
-    }
-
-    memcpy(pEvdev->led_bitmask, led_bitmask, len);
-
     /*
      * Do not try to validate absinfo data since it is not expected
      * to be static, always refresh it in evdev structure.
diff --git a/src/evdev.h b/src/evdev.h
index 6ae389c..4742b43 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -235,12 +235,10 @@ typedef struct {
     OsTimerPtr reopen_timer;
 
     /* Cached info from device. */
-    char name[1024];
     unsigned long bitmask[NLONGS(EV_CNT)];
     unsigned long key_bitmask[NLONGS(KEY_CNT)];
     unsigned long rel_bitmask[NLONGS(REL_CNT)];
     unsigned long abs_bitmask[NLONGS(ABS_CNT)];
-    unsigned long led_bitmask[NLONGS(LED_CNT)];
     struct input_absinfo absinfo[ABS_CNT];
 
     /* minor/major number */

commit a0d41af8969b91ec51ebdfb966ccc47e5c40329a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 27 10:19:15 2013 +1000

    Switch default model to pc104.
    
    As of xkeyboard-config 1.9, the evdev model is hidden (c887d2876)
    The server switched to pc105 with version 1.8 (1df4bd601).
    
    The evdev model resolves to pc104 anyway, so this commit has no real effect
    other than to switch from a catch-all rule to explicit.
    Use pc104 so this is easy to find for those investigating the code and
    wondering why. pc104 is the 'correct' geometry for the us layout, which is
    the default after all. Switching to pc105 would show keys missing if no
    model is set (e.g. on uk/de layouts) but it would be the wrong layout for
    the default.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/src/evdev.c b/src/evdev.c
index aec1447..86af151 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -96,7 +96,7 @@
 
 static const char *evdevDefaults[] = {
     "XkbRules",     "evdev",
-    "XkbModel",     "evdev",
+    "XkbModel",     "pc104", /* the right model for 'us' */
     "XkbLayout",    "us",
     NULL
 };

commit dea1d1a3906b98b491e9760b3304f881c6afec5e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Apr 29 11:48:12 2013 +1000

    Fail to set up axes for devices that only have MT axes but no ABS_X/Y equivalents (#64029)
    
    The kernel should give us ABS_X/Y for backwards compat but some devices
    don't. For now, ignore these devices as evdev is not suited to handle this
    yet and will crash if a device is set up without axes (i.e.
    pEvdev->vals == NULL) and later receives an event from an MT axis.
    
    X.Org Bug 64029 <http://bugs.freedesktop.org/show_bug.cgi?id=64029>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>

diff --git a/src/evdev.c b/src/evdev.c
index 94f5499..aec1447 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1283,6 +1283,15 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes)
             num_axes--;
         }
     }
+
+    /* device only has mt-axes. the kernel should give us ABS_X etc for
+       backwards compat but some devices don't have it. */
+    if (num_axes == 0 && num_mt_axes > 0) {
+        xf86IDrvMsg(pInfo, X_ERROR,
+                    "found only multitouch-axes. That shouldn't happen.\n");
+        goto out;
+    }
+
 #endif
 
 #ifdef HAVE_SMOOTH_SCROLLING

commit b59a1a25dad4437e013ce8d3d65d4591c6f4ee4a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Apr 2 14:12:26 2013 +1000

    Add option TypeName (#62831)
    
    evdev tries to assign the right XI 1.x type-name based on various device
    capabilities. In some cases, that fails. e.g. the Mionix Naos 5000 mouse
    looks like a keyboard. And we assign a keyboard type in that case since
    there are plenty of keyboards that also advertise some axes or others.
    
    Add a new option TypeName to allow for system-wide configuration of such
    devices in a quirks file.
    
    This can also be used to address #55867
    
    X.Org Bug 62831 <http://bugs.freedesktop.org/show_bug.cgi?id=62831>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/man/evdev.man b/man/evdev.man
index 2709d7a..220dd13 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -220,6 +220,12 @@ is mapped to the negative Y axis motion and button number
 .I N2
 is mapped to the positive Y axis motion.  Default: "4 5". Property:
 "Evdev Wheel Emulation Axes".
+.TP 7
+.BI "Option \*qTypeName\*q \*q"type"\*q
+Specify the X Input 1.x type (see XListInputDevices(__libmansuffix__)).
+There is rarely a need to use this option, evdev will guess the device type
+based on the device's capabilities. This option is provided for devices that
+need quirks.
 
 .SH SUPPORTED PROPERTIES
 The following properties are provided by the
diff --git a/src/evdev.c b/src/evdev.c
index 052e9f0..94f5499 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2548,6 +2548,9 @@ EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
         /* Release string allocated in EvdevOpenDevice. */
         free(pEvdev->device);
         pEvdev->device = NULL;
+
+        free(pEvdev->type_name);
+        pEvdev->type_name = NULL;
     }
     xf86DeleteInput(pInfo, flags);
 }
@@ -2579,6 +2582,8 @@ EvdevAlloc(void)
     pEvdev->rel_axis_map[0] = 0;
     pEvdev->rel_axis_map[1] = 1;
 
+    pEvdev->type_name = NULL;
+
     return pEvdev;
 }
 
@@ -2623,6 +2628,14 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
         goto error;
     }
 
+    /* Overwrite type_name with custom-defined one (#62831).
+       Note: pInfo->type_name isn't freed so we need to manually do this
+     */
+    pEvdev->type_name = xf86SetStrOption(pInfo->options,
+                                         "TypeName",
+                                         pInfo->type_name);
+    pInfo->type_name = pEvdev->type_name;
+
     EvdevAddDevice(pInfo);
 
     if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
diff --git a/src/evdev.h b/src/evdev.h
index 63c3bfa..6ae389c 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -251,6 +251,8 @@ typedef struct {
     EventQueueRec           queue[EVDEV_MAXQUEUE];
 
     enum fkeymode           fkeymode;
+
+    char *type_name;
 } EvdevRec, *EvdevPtr;
 
 /* Event posting functions */

commit 5138cd2ff47a1a28db82688b932cb1ecd618778f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 26 16:01:39 2013 +1000

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

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

commit c085c8b6c1f8e95f6f4d91bc65268fe57154018c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 12 12:58:08 2013 +1000

    Return BadValue if EvdevOpenMTDev fails
    
    FALSE == Success, so if we fail during EvdevOpenMTDev, the caller thinks
    that everything worked fine, proceeds to set up the fd, etc.
    
    This may later cause a crash, when a device comes back later as different
    device and posts axis events where we didn't configure axes in the first
    place.
    
    Note: Unclear why there was no udev event received for the device being
    removed and coming back as different device though.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index ea2410b..052e9f0 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2511,7 +2511,7 @@ EvdevOpenDevice(InputInfoPtr pInfo)
     if (!EvdevOpenMTDev(pInfo)) {
         xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
         EvdevCloseDevice(pInfo);
-        return FALSE;
+        return BadValue;
     }
 #endif
 

commit 2b675f85aef6df3bb3fb5e68648982e11b752764
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 12 12:48:38 2013 +1000

    Make errors on EVIOCGBIT more obvious
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 731ebb3..ea2410b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2000,7 +2000,7 @@ EvdevCache(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(0, sizeof(bitmask)), bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for bitmask failed: %s\n",
                     strerror(errno));
         goto error;
     }
@@ -2009,7 +2009,7 @@ EvdevCache(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_REL failed: %s\n",
                     strerror(errno));
         goto error;
     }
@@ -2018,7 +2018,7 @@ EvdevCache(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_ABS failed: %s\n",
                     strerror(errno));
         goto error;
     }
@@ -2027,7 +2027,7 @@ EvdevCache(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_LED failed: %s\n",
                     strerror(errno));
         goto error;
     }
@@ -2053,7 +2053,7 @@ EvdevCache(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_KEY failed: %s\n",
                     strerror(errno));
         goto error;
     }
@@ -2435,8 +2435,8 @@ EvdevOpenMTDev(InputInfoPtr pInfo)
     /* Use ioctl here, this may be called before EvdevCache */
     len = ioctl(pInfo->fd, EVIOCGBIT(0, sizeof(bitmask)), bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
-                    strerror(errno));
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for bitmask in %s failed: %s\n",
+                    __func__, strerror(errno));
         return FALSE;
     }
 
@@ -2445,8 +2445,8 @@ EvdevOpenMTDev(InputInfoPtr pInfo)
 
     len = ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask);
     if (len < 0) {
-        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT failed: %s\n",
-                    strerror(errno));
+        xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGBIT for EV_ABS in %s failed: %s\n",
+                    __func__, strerror(errno));
         return FALSE;
     }
 

commit 2b8b0df62ec554952784f2820fb4143c495232b0
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Jan 24 16:18:48 2013 +1000

    Always init axis mapping for the first two rel axes (#59784)
    
    Fixes regression introduced in 2f67509b53b27dd7f51ca2aadd19605aee613a61.
    
    If evdev is used for touchpads, the abs axis movement is converted to a rel
    movement. Without the two relative axes initialized, the events are
    discarded.
    
    Axes 0 and 1 are always x/y anyway unless specifically configured otherwise.
    
    X.Org Bug 59784 <http://bugs.freedesktop.org/show_bug.cgi?id=59784>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 570dd06..731ebb3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2576,6 +2576,9 @@ EvdevAlloc(void)
     for (i = 0; i < ArrayLength(pEvdev->abs_axis_map); i++)
         pEvdev->abs_axis_map[i] = -1;
 
+    pEvdev->rel_axis_map[0] = 0;
+    pEvdev->rel_axis_map[1] = 1;
+
     return pEvdev;
 }
 
@@ -2740,6 +2743,8 @@ static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *ato
 
     memset(atoms, 0, natoms * sizeof(Atom));
 
+    /* rel[0] and [1] are always mapped, so we get the rel labels. if we
+       have abs x/y, the labels will be overwritten with the right one */
     for (axis = 0; axis < ArrayLength(rel_labels); axis++)
         EvdevInitOneAxisLabel(pEvdev, pEvdev->rel_axis_map[axis], rel_labels, axis, atoms);
 

commit f5fe533f1bef0c636b98658aaf40748c219c9879
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 27 12:18:46 2012 +1000

    Allow relative scroll valuators on absolute devices (#54387)
    
    Special-case RHEL_WHEEL, RHEL_HWHEEL and REL_DIAL to add scroll valuators
    for those axes in addition to the absolute axes.
    
    X.Org Bug 54387 <http://bugs.freedesktop.org/show_bug.cgi?id=54387>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 9741821..c25bea4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -692,7 +692,9 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
 #endif
         default:
             /* Ignore EV_REL events if we never set up for them. */
-            if (!(pEvdev->flags & EVDEV_RELATIVE_EVENTS))
+            if (!(pEvdev->flags & EVDEV_RELATIVE_EVENTS) &&
+                    ev->code != REL_WHEEL && ev->code != REL_DIAL &&
+                    ev->code != REL_HWHEEL)
                 return;
 
             /* Handle mouse wheel emulation */
@@ -1215,7 +1217,7 @@ is_blacklisted_axis(int axis)
 
 
 static int
-EvdevAddAbsValuatorClass(DeviceIntPtr device)
+EvdevAddAbsValuatorClass(DeviceIntPtr device, int want_scroll_axes)
 {
     InputInfoPtr pInfo;
     EvdevPtr pEvdev;
@@ -1224,6 +1226,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
         num_mt_axes_total = 0; /* total number of MT axes, including
                                   double-counted ones, excluding blacklisted */
     Atom *atoms;
+    int mapping = 0;
 
     pInfo = device->public.devicePrivate;
     pEvdev = pInfo->private;
@@ -1263,6 +1266,19 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
         }
     }
 #endif
+
+#ifdef HAVE_SMOOTH_SCROLLING
+    if (want_scroll_axes && EvdevBitIsSet(pEvdev->bitmask, EV_REL))
+    {
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_WHEEL))
+            num_axes++;
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_HWHEEL))
+            num_axes++;
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_DIAL))
+            num_axes++;
+    }
+#endif
+
     if (num_axes + num_mt_axes > MAX_VALUATORS) {
         xf86IDrvMsg(pInfo, X_WARNING, "found %d axes, limiting to %d.\n", num_axes, MAX_VALUATORS);
         num_axes = MAX_VALUATORS;
@@ -1329,7 +1345,6 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
 #ifdef MULTITOUCH
         int j;
 #endif
-        int mapping;
         pEvdev->abs_axis_map[axis] = -1;
         if (!EvdevBitIsSet(pEvdev->abs_bitmask, axis) ||
             is_blacklisted_axis(axis))
@@ -1352,6 +1367,20 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
             i++;
     }
 
+#ifdef HAVE_SMOOTH_SCROLLING
+    if (want_scroll_axes)
+    {
+        mapping++; /* continue from abs axis mapping */
+
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_HWHEEL))
+            pEvdev->rel_axis_map[REL_HWHEEL] = mapping++;
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_DIAL))
+            pEvdev->rel_axis_map[REL_DIAL] = mapping++;
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_WHEEL))
+            pEvdev->rel_axis_map[REL_WHEEL] = mapping++;
+    }
+#endif
+
     EvdevInitAxesLabels(pEvdev, Absolute, pEvdev->num_vals + num_mt_axes, atoms);
 
     if (!InitValuatorClassDeviceStruct(device, num_axes + num_mt_axes, atoms,
@@ -1446,6 +1475,51 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
     }
 #endif
 
+#ifdef HAVE_SMOOTH_SCROLLING
+    if (want_scroll_axes)
+    {
+        int idx;
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_WHEEL))
+        {
+            idx = REL_WHEEL;
+            xf86InitValuatorAxisStruct(device,
+                                       pEvdev->rel_axis_map[idx],
+                                       atoms[pEvdev->rel_axis_map[idx]],
+                                       NO_AXIS_LIMITS, NO_AXIS_LIMITS,
+                                       0, 0, 0, Relative);
+            SetScrollValuator(device, pEvdev->rel_axis_map[idx],
+                              SCROLL_TYPE_VERTICAL, -1.0,
+                              SCROLL_FLAG_PREFERRED);
+        }
+
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_HWHEEL))
+        {
+            idx = REL_HWHEEL;
+            xf86InitValuatorAxisStruct(device,
+                                       pEvdev->rel_axis_map[idx],
+                                       atoms[pEvdev->rel_axis_map[idx]],
+                                       NO_AXIS_LIMITS, NO_AXIS_LIMITS,
+                                       0, 0, 0, Relative);
+            SetScrollValuator(device, pEvdev->rel_axis_map[idx],
+                              SCROLL_TYPE_HORIZONTAL, 1.0,
+                              SCROLL_FLAG_NONE);
+        }
+
+        if (EvdevBitIsSet(pEvdev->rel_bitmask, REL_DIAL))
+        {
+            idx = REL_DIAL;
+            xf86InitValuatorAxisStruct(device,
+                                       pEvdev->rel_axis_map[idx],
+                                       atoms[pEvdev->rel_axis_map[idx]],
+                                       NO_AXIS_LIMITS, NO_AXIS_LIMITS,
+                                       0, 0, 0, Relative);
+            SetScrollValuator(device, pEvdev->rel_axis_map[idx],
+                              SCROLL_TYPE_HORIZONTAL, 1.0,
+                              SCROLL_FLAG_NONE);
+        }
+    }
+#endif
+
     free(atoms);
 
     for (i = 0; i < ArrayLength(proximity_bits); i++)
@@ -1675,12 +1749,16 @@ static void
 EvdevInitAnyValuators(DeviceIntPtr device, EvdevPtr pEvdev)
 {
     InputInfoPtr pInfo = device->public.devicePrivate;
+    int rel_success = FALSE;
 
     if (pEvdev->flags & EVDEV_RELATIVE_EVENTS &&
         EvdevAddRelValuatorClass(device) == Success)
+    {
+        rel_success = TRUE;
         xf86IDrvMsg(pInfo, X_INFO, "initialized for relative axes.\n");
+    }
     if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS &&
-        EvdevAddAbsValuatorClass(device) == Success)
+        EvdevAddAbsValuatorClass(device, !rel_success) == Success)
         xf86IDrvMsg(pInfo, X_INFO, "initialized for absolute axes.\n");
 }
 
@@ -1689,7 +1767,7 @@ EvdevInitAbsValuators(DeviceIntPtr device, EvdevPtr pEvdev)
 {
     InputInfoPtr pInfo = device->public.devicePrivate;
 
-    if (EvdevAddAbsValuatorClass(device) == Success) {
+    if (EvdevAddAbsValuatorClass(device, TRUE) == Success) {
         xf86IDrvMsg(pInfo, X_INFO,"initialized for absolute axes.\n");
     } else {
         xf86IDrvMsg(pInfo, X_ERROR,"failed to initialize for absolute axes.\n");

commit 2f67509b53b27dd7f51ca2aadd19605aee613a61
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Jan 16 08:38:52 2013 +1000

    Split rel and abs axis mapping into two separate arrays
    
    This will enable a device to have relative scrolling axes in addition to
    absolute axes (required by the QEMU tablet).
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/emuWheel.c b/src/emuWheel.c
index db989c5..5774930 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -117,7 +117,7 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
 
 	/* We don't want to intercept real mouse wheel events */
 	if(pEv->type == EV_ABS) {
-	    int axis = pEvdev->axis_map[pEv->code];
+	    int axis = pEvdev->abs_axis_map[pEv->code];
 	    oldValue = valuator_mask_get(pEvdev->vals, axis);
 	    valuator_mask_set(pEvdev->vals, axis, value);
 	    value -= oldValue; /* make value into a differential measurement */
diff --git a/src/evdev.c b/src/evdev.c
index a9b1fd2..9741821 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -123,7 +123,7 @@ static int EvdevOpenDevice(InputInfoPtr pInfo);
 static void EvdevCloseDevice(InputInfoPtr pInfo);
 
 static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
-static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int axis,
+static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int mapped_axis,
                                   const char **labels, int label_idx, Atom *atoms);
 static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
 static void EvdevInitProperty(DeviceIntPtr dev);
@@ -479,7 +479,7 @@ EvdevProcessValuators(InputInfoPtr pInfo)
 
         for (i = 0; i < REL_CNT; i++)
         {
-            int map = pEvdev->axis_map[i];
+            int map = pEvdev->rel_axis_map[i];
             if (pEvdev->delta[i] && map != -1)
                 valuator_mask_set(pEvdev->vals, map, pEvdev->delta[i]);
         }
@@ -701,7 +701,7 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
 
             pEvdev->rel_queued = 1;
             pEvdev->delta[ev->code] += value;
-            map = pEvdev->axis_map[ev->code];
+            map = pEvdev->rel_axis_map[ev->code];
             valuator_mask_set(pEvdev->vals, map, value);
             break;
     }
@@ -787,7 +787,7 @@ EvdevProcessTouchEvent(InputInfoPtr pInfo, struct input_event *ev)
             } else
                 pEvdev->slot_state = SLOTSTATE_CLOSE;
         } else {
-            map = pEvdev->axis_map[ev->code];
+            map = pEvdev->abs_axis_map[ev->code];
             valuator_mask_set(pEvdev->mt_mask, map, ev->value);
             if (slot_index >= 0)
                 valuator_mask_set(pEvdev->last_mt_vals[slot_index], map,
@@ -827,7 +827,7 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
         EvdevProcessTouchEvent(pInfo, ev);
         pEvdev->abs_queued = 1;
     } else if (!pEvdev->mt_mask) {
-        map = pEvdev->axis_map[ev->code];
+        map = pEvdev->abs_axis_map[ev->code];
         valuator_mask_set(pEvdev->vals, map, value);
         pEvdev->abs_queued = 1;
     }
@@ -1330,7 +1330,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
         int j;
 #endif
         int mapping;
-        pEvdev->axis_map[axis] = -1;
+        pEvdev->abs_axis_map[axis] = -1;
         if (!EvdevBitIsSet(pEvdev->abs_bitmask, axis) ||
             is_blacklisted_axis(axis))
             continue;
@@ -1347,7 +1347,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
                 mapping = mt_axis_mappings[j].mapping;
         }
 #endif
-        pEvdev->axis_map[axis] = mapping;
+        pEvdev->abs_axis_map[axis] = mapping;
         if (mapping == i)
             i++;
     }
@@ -1380,11 +1380,11 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
 
         for (i = 0; i < num_slots(pEvdev); i++) {
             for (axis = ABS_MT_TOUCH_MAJOR; axis < ABS_MAX; axis++) {
-                if (pEvdev->axis_map[axis] >= 0) {
+                if (pEvdev->abs_axis_map[axis] >= 0) {
                     /* XXX: read initial values from mtdev when it adds support
                      *      for doing so. */
                     valuator_mask_set(pEvdev->last_mt_vals[i],
-                                      pEvdev->axis_map[axis], 0);
+                                      pEvdev->abs_axis_map[axis], 0);
                 }
             }
         }
@@ -1392,7 +1392,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
 #endif
 
     for (axis = ABS_X; axis < ABS_MT_SLOT; axis++) {
-        int axnum = pEvdev->axis_map[axis];
+        int axnum = pEvdev->abs_axis_map[axis];
         int resolution = 0;
 
         if (axnum == -1)
@@ -1414,7 +1414,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
 
 #ifdef MULTITOUCH
     for (axis = ABS_MT_TOUCH_MAJOR; axis <= ABS_MAX; axis++) {
-        int axnum = pEvdev->axis_map[axis];
+        int axnum = pEvdev->abs_axis_map[axis];
         int resolution = 0;
         int j;
         BOOL skip = FALSE;
@@ -1544,7 +1544,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
 
     for (axis = REL_X; i < MAX_VALUATORS && axis <= REL_MAX; axis++)
     {
-        pEvdev->axis_map[axis] = -1;
+        pEvdev->rel_axis_map[axis] = -1;
 #ifndef HAVE_SMOOTH_SCROLLING
         /* We don't post wheel events, so ignore them here too */
         if (axis == REL_WHEEL || axis == REL_HWHEEL || axis == REL_DIAL)
@@ -1552,7 +1552,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
 #endif
         if (!EvdevBitIsSet(pEvdev->rel_bitmask, axis))
             continue;
-        pEvdev->axis_map[axis] = i;
+        pEvdev->rel_axis_map[axis] = i;
         i++;
     }
 
@@ -1572,7 +1572,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
 
     for (axis = REL_X; axis <= REL_MAX; axis++)
     {
-        int axnum = pEvdev->axis_map[axis];
+        int axnum = pEvdev->rel_axis_map[axis];
 
         if (axnum == -1)
             continue;
@@ -1739,17 +1739,12 @@ EvdevInitTouchDevice(DeviceIntPtr device, EvdevPtr pEvdev)
 static int
 EvdevInit(DeviceIntPtr device)
 {
-    int i;
     InputInfoPtr pInfo;
     EvdevPtr pEvdev;
 
     pInfo = device->public.devicePrivate;
     pEvdev = pInfo->private;
 
-    /* clear all axis_map entries */
-    for(i = 0; i < max(ABS_CNT,REL_CNT); i++)
-      pEvdev->axis_map[i]=-1;
-
     if (pEvdev->flags & EVDEV_KEYBOARD_EVENTS)
 	EvdevAddKeyClass(device);
     if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
@@ -2480,8 +2475,10 @@ EvdevAlloc(void)
     pEvdev->cur_slot = -1;
 #endif
 
-    for (i = 0; i < ArrayLength(pEvdev->axis_map); i++)
-        pEvdev->axis_map[i] = -1;
+    for (i = 0; i < ArrayLength(pEvdev->rel_axis_map); i++)
+        pEvdev->rel_axis_map[i] = -1;
+    for (i = 0; i < ArrayLength(pEvdev->abs_axis_map); i++)
+        pEvdev->abs_axis_map[i] = -1;
 
     return pEvdev;
 }
@@ -2626,43 +2623,32 @@ EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code)
     }
 }
 
-static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int axis,
+static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int mapped_axis,
                                   const char **labels, int label_idx, Atom *atoms)
 {
     Atom atom;
 
-    if (pEvdev->axis_map[axis] == -1)
+    if (mapped_axis == -1)
         return;
 
     atom = XIGetKnownProperty(labels[label_idx]);
     if (!atom) /* Should not happen */
         return;
 
-    atoms[pEvdev->axis_map[axis]] = atom;
+    atoms[mapped_axis] = atom;
 }
 
 static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms)
 {
     int axis;
-    const char **labels;
-    int labels_len = 0;
-
-    if (mode == Absolute)
-    {
-        labels     = abs_labels;
-        labels_len = ArrayLength(abs_labels);
-    } else if (mode == Relative)
-    {
-        labels     = rel_labels;
-        labels_len = ArrayLength(rel_labels);
-    } else
-        return;
 
     memset(atoms, 0, natoms * sizeof(Atom));
 
-    /* Now fill the ones we know */
-    for (axis = 0; axis < labels_len; axis++)
-        EvdevInitOneAxisLabel(pEvdev, axis, labels, axis, atoms);
+    for (axis = 0; axis < ArrayLength(rel_labels); axis++)
+        EvdevInitOneAxisLabel(pEvdev, pEvdev->rel_axis_map[axis], rel_labels, axis, atoms);
+
+    for (axis = 0; axis < ArrayLength(abs_labels); axis++)
+        EvdevInitOneAxisLabel(pEvdev, pEvdev->abs_axis_map[axis], abs_labels, axis, atoms);
 }
 
 static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms)
diff --git a/src/evdev.h b/src/evdev.h
index 51b7fa0..63c3bfa 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -158,7 +158,8 @@ typedef struct {
 
     int num_vals;           /* number of valuators */
     int num_mt_vals;        /* number of multitouch valuators */
-    int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
+    int abs_axis_map[ABS_CNT]; /* Map evdev ABS_* to index */
+    int rel_axis_map[REL_CNT]; /* Map evdev REL_* to index */
     ValuatorMask *vals;     /* new values coming in */
     ValuatorMask *old_vals; /* old values for calculating relative motion */
     ValuatorMask *prox;     /* last values set while not in proximity */

commit ffc0a34642d5ab573c2ae63c873a5befd8688493
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jan 15 16:15:47 2013 +1000

    Move some stuff into the new alloc function
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index baa7ac1..a9b1fd2 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2464,7 +2464,25 @@ EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 static EvdevPtr
 EvdevAlloc(void)
 {
+    int i;
     EvdevPtr pEvdev = calloc(sizeof(EvdevRec), 1);
+
+    if (!pEvdev)
+        return NULL;
+    /*
+     * We initialize pEvdev->in_proximity to 1 so that device that doesn't use
+     * proximity will still report events.
+     */
+    pEvdev->in_proximity = 1;
+    pEvdev->use_proximity = 1;
+
+#ifdef MULTITOUCH
+    pEvdev->cur_slot = -1;
+#endif
+
+    for (i = 0; i < ArrayLength(pEvdev->axis_map); i++)
+        pEvdev->axis_map[i] = -1;
+
     return pEvdev;
 }
 
@@ -2487,17 +2505,6 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     if (rc != Success)
         goto error;
 
-#ifdef MULTITOUCH
-    pEvdev->cur_slot = -1;
-#endif
-
-    /*
-     * We initialize pEvdev->in_proximity to 1 so that device that doesn't use
-     * proximity will still report events.
-     */
-    pEvdev->in_proximity = 1;
-    pEvdev->use_proximity = 1;
-
     /* Grabbing the event device stops in-kernel event forwarding. In other
        words, it disables rfkill and the "Macintosh mouse button emulation".
        Note that this needs a server that sets the console to RAW mode. */

commit 93de7b0b73d4c5f6f68e3a2ffe8f76b5212ee016
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jan 15 16:11:16 2013 +1000

    Move allocation of EvdevRec into a helper function
    
    Makes it easier to initialise everything to the right values.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 5667dc1..baa7ac1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2461,13 +2461,20 @@ EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     xf86DeleteInput(pInfo, flags);
 }
 
+static EvdevPtr
+EvdevAlloc(void)
+{
+    EvdevPtr pEvdev = calloc(sizeof(EvdevRec), 1);
+    return pEvdev;
+}
+
 static int
 EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {


Reply to: