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

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



 configure.ac |    2 
 src/evdev.c  |  518 ++++++++++++++++++++++++++++++++++++++---------------------
 src/evdev.h  |   11 -
 3 files changed, 343 insertions(+), 188 deletions(-)

New commits:
commit 31ba99e9edd28ff81437e0167c5322b9f619c52a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 19 14:27:09 2010 +1000

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

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

commit a4aefca2ed52e675e6151a0fb0742a9e19565a41
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Oct 25 11:05:18 2010 +1000

    Reshuffle to avoid the need for XI86_CONFIGURED.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>

diff --git a/src/evdev.c b/src/evdev.c
index 018843f..040cfdc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -63,7 +63,6 @@
 
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
 /* removed from server, purge when dropping support for server 1.10 */
-#define XI86_CONFIGURED         0x02
 #define XI86_SEND_DRAG_EVENTS   0x08
 #endif
 
@@ -1916,6 +1915,7 @@ EvdevProbe(InputInfoPtr pInfo)
     int has_lmr; /* left middle right */
     int ignore_abs = 0, ignore_rel = 0;
     EvdevPtr pEvdev = pInfo->private;
+    int rc = 1;
 
     /* Trinary state for ignoring axes:
        - unset: do the normal thing.
@@ -2082,7 +2082,7 @@ EvdevProbe(InputInfoPtr pInfo)
     }
 
     if (has_rel_axes || has_abs_axes || num_buttons) {
-        pInfo->flags |= XI86_SEND_DRAG_EVENTS | XI86_CONFIGURED;
+        pInfo->flags |= XI86_SEND_DRAG_EVENTS;
 	if (pEvdev->flags & EVDEV_TOUCHPAD) {
 	    xf86Msg(X_INFO, "%s: Configuring as touchpad\n", pInfo->name);
 	    pInfo->type_name = XI_TOUCHPAD;
@@ -2096,29 +2096,29 @@ EvdevProbe(InputInfoPtr pInfo)
 	    xf86Msg(X_INFO, "%s: Configuring as mouse\n", pInfo->name);
 	    pInfo->type_name = XI_MOUSE;
 	}
+
+        rc = 0;
     }
 
     if (has_keys) {
         xf86Msg(X_INFO, "%s: Configuring as keyboard\n", pInfo->name);
-        pInfo->flags |= XI86_CONFIGURED;
         pInfo->type_name = XI_KEYBOARD;
+        rc = 0;
     }
 
-    if (has_scroll && (pInfo->flags & XI86_CONFIGURED) &&
-        (has_rel_axes || has_abs_axes))
+    if (has_scroll &&
+        (has_rel_axes || has_abs_axes || num_buttons || has_keys))
     {
         xf86Msg(X_INFO, "%s: Adding scrollwheel support\n", pInfo->name);
         pEvdev->flags |= EVDEV_BUTTON_EVENTS;
         pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
     }
 
-    if ((pInfo->flags & XI86_CONFIGURED) == 0) {
+    if (rc)
         xf86Msg(X_WARNING, "%s: Don't know how to use device\n",
 		pInfo->name);
-        return 1;
-    }
 
-    return 0;
+    return rc;
 }
 
 static void
@@ -2214,7 +2214,11 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     xf86ProcessCommonOptions(pInfo, pInfo->options);
 
     if (NewEvdevPreInit(drv, pInfo, flags) == Success)
+    {
+        pInfo->flags |= XI86_CONFIGURED;
         return pInfo;
+    }
+
 
     xf86DeleteInput(pInfo, 0);
     return NULL;

commit 20d7a0a4aab64232712186811ae55c40d2b7d161
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Oct 25 10:38:21 2010 +1000

    Input API 12 requires a valuator mode for each axis.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>

diff --git a/src/evdev.c b/src/evdev.c
index 32253a2..018843f 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1333,7 +1333,11 @@ EvdevAddAbsClass(DeviceIntPtr device)
 #endif
                                    pEvdev->absinfo[axis].minimum,
                                    pEvdev->absinfo[axis].maximum,
-                                   resolution, 0, resolution);
+                                   resolution, 0, resolution
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+                                   , Absolute
+#endif
+                                   );
         xf86InitValuatorDefaults(device, axnum);
         pEvdev->old_vals[axnum] = -1;
     }
@@ -1449,7 +1453,11 @@ EvdevAddRelClass(DeviceIntPtr device)
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
                 atoms[axnum],
 #endif
-                -1, -1, 1, 0, 1);
+                -1, -1, 1, 0, 1
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
+                                   , Relative
+#endif
+                );
         xf86InitValuatorDefaults(device, axnum);
     }
 

commit 5e26ba8641809addc63e783e1cefac0f8524b020
Author: Nikolai Kondrashov <spbnick@gmail.com>
Date:   Wed Oct 20 23:31:30 2010 +0400

    Extend button mapping to full ranges
    
    Extend button code to number mapping to cover full BTN_MOUSE and BTN_MISC
    ranges, including undefined codes.
    
    This extends mapping introduced with 0367e387 to the following:
    
            1       BTN_LEFT        BTN_0       BTN_TOUCH
            2       BTN_MIDDLE      BTN_1       BTN_STYLUS
            3       BTN_RIGHT       BTN_2       BTN_STYLUS2
    
            8       BTN_SIDE        BTN_3
            9       BTN_EXTRA       BTN_4
            10      BTN_FORWARD     BTN_5
            11      BTN_BACK        BTN_6
            12      BTN_TASK        BTN_7
            13      0x118           BTN_8
            14      0x119           BTN_9
            15      0x11A           0x10A
            16      0x11B           0x10B
            17      0x11C           0x10C
            18      0x11D           0x10D
            19      0x11E           0x10E
            20      0x11F           0x10F
    
    This should fix https://bugs.freedesktop.org/show_bug.cgi?id=30336
    
    Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 3c5fa89..32253a2 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2345,13 +2345,13 @@ EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code)
             return 2;
         case BTN_RIGHT:
             return 3;
-        case BTN_SIDE ... BTN_TASK:
+        case BTN_SIDE ... BTN_JOYSTICK - 1:
             return 8 + code - BTN_SIDE;
 
         /* Generic buttons */
         case BTN_0 ... BTN_2:
             return 1 + code - BTN_0;
-        case BTN_3 ... BTN_9:
+        case BTN_3 ... BTN_MOUSE - 1:
             return 8 + code - BTN_3;
 
         /* Tablet stylus buttons */

commit 71dd18f72889ef6998a1bd699630da583dcb775a
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Oct 19 10:22:55 2010 +1000

    Rename CountBits to EvdevCountBits.
    
    Avoid name collision with the server.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/src/evdev.c b/src/evdev.c
index 626bb43..3c5fa89 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -165,7 +165,7 @@ static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode)
     return Success;
 }
 
-static size_t CountBits(unsigned long *array, size_t nlongs)
+static size_t EvdevCountBits(unsigned long *array, size_t nlongs)
 {
     unsigned int i;
     size_t count = 0;
@@ -1280,7 +1280,7 @@ EvdevAddAbsClass(DeviceIntPtr device)
     if (!TestBit(EV_ABS, pEvdev->bitmask))
             return !Success;
 
-    num_axes = CountBits(pEvdev->abs_bitmask, NLONGS(ABS_MAX));
+    num_axes = EvdevCountBits(pEvdev->abs_bitmask, NLONGS(ABS_MAX));
     if (num_axes < 1)
         return !Success;
 
@@ -1387,7 +1387,7 @@ EvdevAddRelClass(DeviceIntPtr device)
     if (!TestBit(EV_REL, pEvdev->bitmask))
         return !Success;
 
-    num_axes = CountBits(pEvdev->rel_bitmask, NLONGS(REL_MAX));
+    num_axes = EvdevCountBits(pEvdev->rel_bitmask, NLONGS(REL_MAX));
     if (num_axes < 1)
         return !Success;
 

commit c3e49f2b95d3e40f97d6bffdaf8a6c036093fa91
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Oct 20 10:33:39 2010 +1000

    Use an array for the proximity bits.
    
    Instead of two lists that need to be kept in sync, just store the bits in an
    array and run through them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
    Reviewed-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/src/evdev.c b/src/evdev.c
index 0cf01ab..626bb43 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -95,6 +95,18 @@ static char *evdevDefaults[] = {
     NULL
 };
 
+/* Any of those triggers a proximity event */
+static int proximity_bits[] = {
+        BTN_TOOL_PEN,
+        BTN_TOOL_RUBBER,
+        BTN_TOOL_BRUSH,
+        BTN_TOOL_PENCIL,
+        BTN_TOOL_AIRBRUSH,
+        BTN_TOOL_FINGER,
+        BTN_TOOL_MOUSE,
+        BTN_TOOL_LENS,
+};
+
 static int EvdevOn(DeviceIntPtr);
 static int EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare);
 static void EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl);
@@ -646,7 +658,7 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
 static void
 EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
 {
-    int value;
+    int value, i;
     EvdevPtr pEvdev = pInfo->private;
 
     /* Get the signed value, earlier kernels had this as unsigned */
@@ -657,19 +669,16 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
         if (value == 2)
             return;
 
-    switch (ev->code) {
-        /* keep this list in sync with InitProximityClassDeviceStruct */
-        case BTN_TOOL_PEN:
-        case BTN_TOOL_RUBBER:
-        case BTN_TOOL_BRUSH:
-        case BTN_TOOL_PENCIL:
-        case BTN_TOOL_AIRBRUSH:
-        case BTN_TOOL_FINGER:
-        case BTN_TOOL_MOUSE:
-        case BTN_TOOL_LENS:
+    for (i = 0; i < ArrayLength(proximity_bits); i++)
+    {
+        if (ev->code == proximity_bits[i])
+        {
             EvdevProcessProximityEvent(pInfo, ev);
-            break;
+            return;
+        }
+    }
 
+    switch (ev->code) {
         case BTN_TOUCH:
             if (!(pEvdev->flags & (EVDEV_TOUCHSCREEN | EVDEV_TABLET)))
                 break;
@@ -1331,16 +1340,14 @@ EvdevAddAbsClass(DeviceIntPtr device)
 
     free(atoms);
 
-    /* keep this list in sync with EvdevProcessKeyEvent */
-    if (TestBit(BTN_TOOL_PEN, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_RUBBER, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_BRUSH, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_PENCIL, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_AIRBRUSH, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_MOUSE, pEvdev->key_bitmask) ||
-        TestBit(BTN_TOOL_LENS, pEvdev->key_bitmask))
-        InitProximityClassDeviceStruct(device);
+    for (i = 0; i < ArrayLength(proximity_bits); i++)
+    {
+        if (TestBit(proximity_bits[i], pEvdev->key_bitmask))
+        {
+            InitProximityClassDeviceStruct(device);
+            break;
+        }
+    }
 
     if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc))
         return !Success;

commit b06d3ffdcdb14978201af5b24a7292ee73b65318
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Oct 20 10:20:26 2010 +1000

    Rename abs/rel/prox to abs_queued/rel_queued/prox_queued.
    
    Mainly to avoid confusing between pEvdev->prox and pEvdev->proximity and to
    better express what these fields are actually holding.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>
    Reviewed-by: Daniel Stone <daniel@fooishbar.org>

diff --git a/src/evdev.c b/src/evdev.c
index 717c03c..0cf01ab 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -373,24 +373,24 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
     *num_v = *first_v = 0;
 
     /* convert to relative motion for touchpads */
-    if (pEvdev->abs && (pEvdev->flags & EVDEV_RELATIVE_MODE)) {
+    if (pEvdev->abs_queued && (pEvdev->flags & EVDEV_RELATIVE_MODE)) {
         if (pEvdev->proximity) {
             if (pEvdev->old_vals[0] != -1)
                 pEvdev->delta[REL_X] = pEvdev->vals[0] - pEvdev->old_vals[0];
             if (pEvdev->old_vals[1] != -1)
                 pEvdev->delta[REL_Y] = pEvdev->vals[1] - pEvdev->old_vals[1];
-            if (pEvdev->abs & ABS_X_VALUE)
+            if (pEvdev->abs_queued & ABS_X_VALUE)
                 pEvdev->old_vals[0] = pEvdev->vals[0];
-            if (pEvdev->abs & ABS_Y_VALUE)
+            if (pEvdev->abs_queued & ABS_Y_VALUE)
                 pEvdev->old_vals[1] = pEvdev->vals[1];
         } else {
             pEvdev->old_vals[0] = pEvdev->old_vals[1] = -1;
         }
-        pEvdev->abs = 0;
-        pEvdev->rel = 1;
+        pEvdev->abs_queued = 0;
+        pEvdev->rel_queued = 1;
     }
 
-    if (pEvdev->rel) {
+    if (pEvdev->rel_queued) {
         int first = REL_CNT, last = 0;
         int i;
 
@@ -429,7 +429,7 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
      * initialized to 1 so devices that doesn't use this scheme still
      * just works.
      */
-    else if (pEvdev->abs && pEvdev->proximity) {
+    else if (pEvdev->abs_queued && pEvdev->proximity) {
         memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
 
         if (pEvdev->swap_axes) {
@@ -475,7 +475,7 @@ EvdevProcessProximityEvent(InputInfoPtr pInfo, struct input_event *ev)
 {
     EvdevPtr pEvdev = pInfo->private;
 
-    pEvdev->prox = 1;
+    pEvdev->prox_queued = 1;
 
     EvdevQueueProximityEvent(pInfo, ev->value);
 }
@@ -502,10 +502,10 @@ EvdevProcessProximityState(InputInfoPtr pInfo)
     int i;
 
     /* no proximity change in the queue */
-    if (!pEvdev->prox)
+    if (!pEvdev->prox_queued)
     {
-        if (pEvdev->abs && !pEvdev->proximity)
-            pEvdev->abs_prox = pEvdev->abs;
+        if (pEvdev->abs_queued && !pEvdev->proximity)
+            pEvdev->abs_prox = pEvdev->abs_queued;
         return 0;
     }
 
@@ -523,9 +523,9 @@ EvdevProcessProximityState(InputInfoPtr pInfo)
     {
         /* We're about to go into/out of proximity but have no abs events
          * within the EV_SYN. Use the last coordinates we have. */
-        if (!pEvdev->abs && pEvdev->abs_prox)
+        if (!pEvdev->abs_queued && pEvdev->abs_prox)
         {
-            pEvdev->abs = pEvdev->abs_prox;
+            pEvdev->abs_queued = pEvdev->abs_prox;
             pEvdev->abs_prox = 0;
         }
     }
@@ -603,7 +603,7 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
             if (EvdevWheelEmuFilterMotion(pInfo, ev))
                 return;
 
-            pEvdev->rel = 1;
+            pEvdev->rel_queued = 1;
             pEvdev->delta[ev->code] += value;
             break;
     }
@@ -633,11 +633,11 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
 
     pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
     if (ev->code == ABS_X)
-        pEvdev->abs |= ABS_X_VALUE;
+        pEvdev->abs_queued |= ABS_X_VALUE;
     else if (ev->code == ABS_Y)
-        pEvdev->abs |= ABS_Y_VALUE;
+        pEvdev->abs_queued |= ABS_Y_VALUE;
     else
-        pEvdev->abs |= ABS_VALUE;
+        pEvdev->abs_queued |= ABS_VALUE;
 }
 
 /**
@@ -693,7 +693,7 @@ EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
 {
     EvdevPtr pEvdev = pInfo->private;
 
-    if (pEvdev->rel) {
+    if (pEvdev->rel_queued) {
         xf86PostMotionEventP(pInfo->dev, FALSE, first_v, num_v, v + first_v);
     }
 }
@@ -716,7 +716,7 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
      * initialized to 1 so devices that don't use this scheme still
      * just work.
      */
-    if (pEvdev->abs && pEvdev->proximity) {
+    if (pEvdev->abs_queued && pEvdev->proximity) {
         xf86PostMotionEventP(pInfo->dev, TRUE, first_v, num_v, v + first_v);
     }
 }
@@ -728,7 +728,7 @@ EvdevPostProximityEvents(InputInfoPtr pInfo, int which, int num_v, int first_v,
     int i;
     EvdevPtr pEvdev = pInfo->private;
 
-    for (i = 0; pEvdev->prox && i < pEvdev->num_queue; i++) {
+    for (i = 0; pEvdev->prox_queued && i < pEvdev->num_queue; i++) {
         switch (pEvdev->queue[i].type) {
             case EV_QUEUE_KEY:
             case EV_QUEUE_BTN:
@@ -759,7 +759,7 @@ static void EvdevPostQueuedEvents(InputInfoPtr pInfo, int num_v, int first_v,
             break;
         case EV_QUEUE_BTN:
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
-            if (pEvdev->abs && pEvdev->proximity) {
+            if (pEvdev->abs_queued && pEvdev->proximity) {
                 xf86PostButtonEventP(pInfo->dev, 1, pEvdev->queue[i].key,
                                      pEvdev->queue[i].val, first_v, num_v,
                                      v + first_v);
@@ -799,9 +799,9 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
     memset(pEvdev->delta, 0, sizeof(pEvdev->delta));
     memset(pEvdev->queue, 0, sizeof(pEvdev->queue));
     pEvdev->num_queue = 0;
-    pEvdev->abs = 0;
-    pEvdev->rel = 0;
-    pEvdev->prox = 0;
+    pEvdev->abs_queued = 0;
+    pEvdev->rel_queued = 0;
+    pEvdev->prox_queued = 0;
 
 }
 
diff --git a/src/evdev.h b/src/evdev.h
index af93d41..7c17ca4 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -132,7 +132,7 @@ typedef struct {
     BOOL invert_y;
 
     int delta[REL_CNT];
-    unsigned int abs, rel, prox;
+    unsigned int abs_queued, rel_queued, prox_queued;
     unsigned int abs_prox;  /* valuators posted while out of prox? */
 
     /* XKB stuff has to be per-device rather than per-driver */

commit 3646371eefae63678876f45daa0eea2ac522f2e2
Author: Benjamin Tissoires <tissoire@cena.fr>
Date:   Sat Oct 16 20:20:31 2010 +0200

    Add the names of the valuators for the multitouch properties
    
    Thoses definitions have been included in the kernel and in the X server.
    However, the evdev driver has not been updated accordingly.
    
    Without these definitions, the multitouch axes are not correctly labelled.
    
    Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index ef54443..717c03c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2397,6 +2397,35 @@ static char* abs_labels[] = {
     AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
     AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
     AXIS_LABEL_PROP_ABS_VOLUME          /* 0x20 */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+    AXIS_LABEL_PROP_ABS_MISC,           /* undefined */
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 10
+    AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR, /* 0x30 */
+    AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR, /* 0x31 */
+    AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR, /* 0x32 */
+    AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR, /* 0x33 */
+    AXIS_LABEL_PROP_ABS_MT_ORIENTATION, /* 0x34 */
+    AXIS_LABEL_PROP_ABS_MT_POSITION_X,  /* 0x35 */
+    AXIS_LABEL_PROP_ABS_MT_POSITION_Y,  /* 0x36 */
+    AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE,   /* 0x37 */
+    AXIS_LABEL_PROP_ABS_MT_BLOB_ID,     /* 0x38 */
+    AXIS_LABEL_PROP_ABS_MT_TRACKING_ID, /* 0x39 */
+    AXIS_LABEL_PROP_ABS_MT_PRESSURE,    /* 0x3a */
+#endif
 };
 
 static char* rel_labels[] = {

commit b48f4c41c0d3386bba3e9d8fa3da91f18aae190b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Oct 11 09:33:28 2010 +1000

    Add proximity support.
    
    When one of the tools comes into proximity, queue up a proximity event and
    send it accordingly.
    
    Includes special handling for tablets that do not send axes with tools
    (#29645)
    
    Some tablets send axis values, then EV_SYN, and in the next event the
    BTN_TOOL_PEN/BTN_TOUCH, etc. For these tablets, the cursor doesn't move as
    coordinates while not in proximity are ignored.
    
    Buffer coordinates received while out-of-proximity and if we get a proximity
    event without other coordinates, re-use the last ones received.
    
    X.Org Bug 29645 <http://bugs.freedesktop.org/show_bug.cgi?id=29645>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>

diff --git a/src/evdev.c b/src/evdev.c
index 9e1fb10..ef54443 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -322,7 +322,18 @@ EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value)
         pQueue->key = button;
         pQueue->val = value;
     }
+}
 
+void
+EvdevQueueProximityEvent(InputInfoPtr pInfo, int value)
+{
+    EventQueuePtr pQueue;
+    if ((pQueue = EvdevNextInQueue(pInfo)))
+    {
+        pQueue->type = EV_QUEUE_PROXIMITY;
+        pQueue->key = 0;
+        pQueue->val = value;
+    }
 }
 
 /**
@@ -459,6 +470,70 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
     }
 }
 
+static void
+EvdevProcessProximityEvent(InputInfoPtr pInfo, struct input_event *ev)
+{
+    EvdevPtr pEvdev = pInfo->private;
+
+    pEvdev->prox = 1;
+
+    EvdevQueueProximityEvent(pInfo, ev->value);
+}
+
+/**
+ * Proximity handling is rather weird because of tablet-specific issues.
+ * Some tablets, notably Wacoms, send a 0/0 coordinate in the same EV_SYN as
+ * the out-of-proximity notify. We need to ignore those, hence we only
+ * actually post valuator events when we're in proximity.
+ *
+ * Other tablets send the x/y coordinates, then EV_SYN, then the proximity
+ * event. For those, we need to remember x/y to post it when the proximity
+ * comes.
+ *
+ * If we're not in proximity and we get valuator events, remember that, they
+ * won't be posted though. If we move into proximity without valuators, use
+ * the last ones we got and let the rest of the code post them.
+ */
+static int
+EvdevProcessProximityState(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    int prox_state = 0;
+    int i;
+
+    /* no proximity change in the queue */
+    if (!pEvdev->prox)
+    {
+        if (pEvdev->abs && !pEvdev->proximity)
+            pEvdev->abs_prox = pEvdev->abs;
+        return 0;
+    }
+
+    for (i = 0; i < pEvdev->num_queue; i++)
+    {
+        if (pEvdev->queue[i].type == EV_QUEUE_PROXIMITY)
+        {
+            prox_state = pEvdev->queue[i].val;
+            break;
+        }
+    }
+
+    if ((prox_state && !pEvdev->proximity) ||
+        (!prox_state && pEvdev->proximity))
+    {
+        /* We're about to go into/out of proximity but have no abs events
+         * within the EV_SYN. Use the last coordinates we have. */
+        if (!pEvdev->abs && pEvdev->abs_prox)
+        {
+            pEvdev->abs = pEvdev->abs_prox;
+            pEvdev->abs_prox = 0;
+        }
+    }
+
+    pEvdev->proximity = prox_state;
+    return 1;
+}
+
 /**
  * Take a button input event and process it accordingly.
  */
@@ -583,6 +658,7 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
             return;
 
     switch (ev->code) {
+        /* keep this list in sync with InitProximityClassDeviceStruct */
         case BTN_TOOL_PEN:
         case BTN_TOOL_RUBBER:
         case BTN_TOOL_BRUSH:
@@ -591,7 +667,7 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
         case BTN_TOOL_FINGER:
         case BTN_TOOL_MOUSE:
         case BTN_TOOL_LENS:
-            pEvdev->proximity = value ? ev->code : 0;
+            EvdevProcessProximityEvent(pInfo, ev);
             break;
 
         case BTN_TOUCH:
@@ -645,6 +721,27 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
     }
 }
 
+static void
+EvdevPostProximityEvents(InputInfoPtr pInfo, int which, int num_v, int first_v,
+                                  int v[MAX_VALUATORS])
+{
+    int i;
+    EvdevPtr pEvdev = pInfo->private;
+
+    for (i = 0; pEvdev->prox && i < pEvdev->num_queue; i++) {
+        switch (pEvdev->queue[i].type) {
+            case EV_QUEUE_KEY:
+            case EV_QUEUE_BTN:
+                break;
+            case EV_QUEUE_PROXIMITY:
+                if (pEvdev->queue[i].val == which)
+                    xf86PostProximityEventP(pInfo->dev, which, first_v, num_v,
+                            v + first_v);
+                break;
+        }
+    }
+}
+
 /**
  * Post the queued key/button events.
  */
@@ -672,6 +769,8 @@ static void EvdevPostQueuedEvents(InputInfoPtr pInfo, int num_v, int first_v,
                 xf86PostButtonEvent(pInfo->dev, 0, pEvdev->queue[i].key,
                                     pEvdev->queue[i].val, 0, 0);
             break;
+        case EV_QUEUE_PROXIMITY:
+            break;
         }
     }
 }
@@ -687,17 +786,23 @@ EvdevProcessSyncEvent(InputInfoPtr pInfo, struct input_event *ev)
     int v[MAX_VALUATORS] = {};
     EvdevPtr pEvdev = pInfo->private;
 
+    EvdevProcessProximityState(pInfo);
+
     EvdevProcessValuators(pInfo, v, &num_v, &first_v);
 
+    EvdevPostProximityEvents(pInfo, TRUE, num_v, first_v, v);
     EvdevPostRelativeMotionEvents(pInfo, num_v, first_v, v);
     EvdevPostAbsoluteMotionEvents(pInfo, num_v, first_v, v);
     EvdevPostQueuedEvents(pInfo, num_v, first_v, v);
+    EvdevPostProximityEvents(pInfo, FALSE, num_v, first_v, v);
 
     memset(pEvdev->delta, 0, sizeof(pEvdev->delta));
     memset(pEvdev->queue, 0, sizeof(pEvdev->queue));
     pEvdev->num_queue = 0;
     pEvdev->abs = 0;
     pEvdev->rel = 0;
+    pEvdev->prox = 0;
+
 }
 
 /**
@@ -1226,6 +1331,17 @@ EvdevAddAbsClass(DeviceIntPtr device)
 
     free(atoms);
 
+    /* keep this list in sync with EvdevProcessKeyEvent */
+    if (TestBit(BTN_TOOL_PEN, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_RUBBER, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_BRUSH, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_PENCIL, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_AIRBRUSH, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_MOUSE, pEvdev->key_bitmask) ||
+        TestBit(BTN_TOOL_LENS, pEvdev->key_bitmask))
+        InitProximityClassDeviceStruct(device);
+
     if (!InitPtrFeedbackClassDeviceStruct(device, EvdevPtrCtrlProc))
         return !Success;
 
diff --git a/src/evdev.h b/src/evdev.h
index b382670..af93d41 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -109,6 +109,7 @@ typedef struct {
     enum {
         EV_QUEUE_KEY,	/* xf86PostKeyboardEvent() */
         EV_QUEUE_BTN,	/* xf86PostButtonEvent() */
+        EV_QUEUE_PROXIMITY, /* xf86PostProximityEvent() */
     } type;
     int key;		/* May be either a key code or button number. */
     int val;		/* State of the key/button; pressed or released. */
@@ -131,7 +132,8 @@ typedef struct {
     BOOL invert_y;
 
     int delta[REL_CNT];
-    unsigned int abs, rel;
+    unsigned int abs, rel, prox;
+    unsigned int abs_prox;  /* valuators posted while out of prox? */
 
     /* XKB stuff has to be per-device rather than per-driver */
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
@@ -198,6 +200,7 @@ typedef struct {
 /* Event posting functions */
 void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
 void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
+void EvdevQueueProximityEvent(InputInfoPtr pInfo, int value);
 void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value);
 void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
 void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,

commit 185ad42078a3bcb423b83e41ebeddbb7541fe26c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Sep 8 10:47:34 2010 +1000

    Rename evdev->tool to evdev->proximity.
    
    evdev doesn't care about the actual tool used, only that it is used as an
    indicator for proximity. Rename the field accordingly to make the code more
    obvious to read.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>

diff --git a/src/evdev.c b/src/evdev.c
index 1720f96..9e1fb10 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -363,7 +363,7 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
 
     /* convert to relative motion for touchpads */
     if (pEvdev->abs && (pEvdev->flags & EVDEV_RELATIVE_MODE)) {
-        if (pEvdev->tool) { /* meaning, touch is active */
+        if (pEvdev->proximity) {
             if (pEvdev->old_vals[0] != -1)
                 pEvdev->delta[REL_X] = pEvdev->vals[0] - pEvdev->old_vals[0];
             if (pEvdev->old_vals[1] != -1)
@@ -414,11 +414,11 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
      * pressed.  On wacom tablets, this means that the pen is in
      * proximity of the tablet.  After the pen is removed, BTN_TOOL_PEN is
      * released, and a (0, 0) absolute event is generated.  Checking
-     * pEvdev->tool here, lets us ignore that event.  pEvdev is
+     * pEvdev->proximity here lets us ignore that event.  pEvdev is
      * initialized to 1 so devices that doesn't use this scheme still
      * just works.
      */
-    else if (pEvdev->abs && pEvdev->tool) {
+    else if (pEvdev->abs && pEvdev->proximity) {
         memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
 
         if (pEvdev->swap_axes) {
@@ -591,7 +591,7 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
         case BTN_TOOL_FINGER:
         case BTN_TOOL_MOUSE:
         case BTN_TOOL_LENS:
-            pEvdev->tool = value ? ev->code : 0;
+            pEvdev->proximity = value ? ev->code : 0;
             break;
 
         case BTN_TOUCH:
@@ -636,11 +636,11 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
      * pressed.  On wacom tablets, this means that the pen is in
      * proximity of the tablet.  After the pen is removed, BTN_TOOL_PEN is
      * released, and a (0, 0) absolute event is generated.  Checking
-     * pEvdev->tool here, lets us ignore that event.  pEvdev->tool is
+     * pEvdev->proximity here lets us ignore that event. pEvdev->proximity is
      * initialized to 1 so devices that don't use this scheme still
      * just work.
      */
-    if (pEvdev->abs && pEvdev->tool) {
+    if (pEvdev->abs && pEvdev->proximity) {
         xf86PostMotionEventP(pInfo->dev, TRUE, first_v, num_v, v + first_v);
     }
 }
@@ -662,7 +662,7 @@ static void EvdevPostQueuedEvents(InputInfoPtr pInfo, int num_v, int first_v,
             break;
         case EV_QUEUE_BTN:
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
-            if (pEvdev->abs && pEvdev->tool) {
+            if (pEvdev->abs && pEvdev->proximity) {
                 xf86PostButtonEventP(pInfo->dev, 1, pEvdev->queue[i].key,
                                      pEvdev->queue[i].val, first_v, num_v,
                                      v + first_v);
@@ -2112,10 +2112,10 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
         goto error;
 
     /*
-     * We initialize pEvdev->tool to 1 so that device that doesn't use
+     * We initialize pEvdev->proximity to 1 so that device that doesn't use
      * proximity will still report events.
      */
-    pEvdev->tool = 1;
+    pEvdev->proximity = 1;
 
     /* Grabbing the event device stops in-kernel event forwarding. In other
        words, it disables rfkill and the "Macintosh mouse button emulation".
diff --git a/src/evdev.h b/src/evdev.h
index ce7f5f8..b382670 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -124,7 +124,7 @@ typedef struct {
     int old_vals[MAX_VALUATORS]; /* Translate absolute inputs to relative */
 
     int flags;
-    int tool;
+    int proximity;
     int num_buttons;            /* number of buttons */
     BOOL swap_axes;
     BOOL invert_x;

commit 7282e3ac6c3b23cce927271fb9ca34b2acd36fd3
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Sep 8 11:30:14 2010 +1000

    When posting buttons, post absolute valuators if we have them.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>

diff --git a/src/evdev.c b/src/evdev.c
index 1775ad9..1720f96 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -661,11 +661,16 @@ static void EvdevPostQueuedEvents(InputInfoPtr pInfo, int num_v, int first_v,
                                   pEvdev->queue[i].val);
             break;
         case EV_QUEUE_BTN:
-            /* FIXME: Add xf86PostButtonEventP to the X server so that we may
-             * pass the valuators on ButtonPress/Release events, too.  Currently
-             * only MotionNotify events contain the pointer position. */
-            xf86PostButtonEvent(pInfo->dev, 0, pEvdev->queue[i].key,
-                                pEvdev->queue[i].val, 0, 0);
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
+            if (pEvdev->abs && pEvdev->tool) {
+                xf86PostButtonEventP(pInfo->dev, 1, pEvdev->queue[i].key,
+                                     pEvdev->queue[i].val, first_v, num_v,
+                                     v + first_v);
+
+            } else
+#endif
+                xf86PostButtonEvent(pInfo->dev, 0, pEvdev->queue[i].key,
+                                    pEvdev->queue[i].val, 0, 0);
             break;
         }
     }

commit c504852aa27239a57445ca1de013b5bfefa68276
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Sep 8 11:29:11 2010 +1000

    Fix valuator offset when posting absolute motion events.
    
    If first_v was not zero, the values passed to xf86PostMotionEventP were
    wrong.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Benjamin Tissoires <tissoire@cena.fr>

diff --git a/src/evdev.c b/src/evdev.c
index b634ab4..1775ad9 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -641,7 +641,7 @@ EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int num_v, int first_v,
      * just work.
      */
     if (pEvdev->abs && pEvdev->tool) {
-        xf86PostMotionEventP(pInfo->dev, TRUE, first_v, num_v, v);
+        xf86PostMotionEventP(pInfo->dev, TRUE, first_v, num_v, v + first_v);
     }
 }
 

commit 4bbf9c9125db51394870c86413fe18a0c8ec7068
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Sep 8 11:28:27 2010 +1000

    Don't pass pointers around to first_v and num_v.


Reply to: