[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 aff7228d972eedd556b13f06d8db0b5ffb622b46
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 24 15:13:23 2009 +1000

    evdev 2.2.1

diff --git a/configure.ac b/configure.ac
index c1549eb..52d892d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-evdev],
-        2.2.0,
+        2.2.1,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-evdev)
 

commit c695234c5c5fd54a6afd12db46a0926ccdd83301
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 17 14:08:29 2009 +1000

    Fix jumpy touchpads by updating old_vals only when reported by the device.
    
    Remember whether ABS_X or ABS_Y were reported before the SYN event and only
    update the old_vals[0, 1] if we got data for them.
    Touchpads that reported pressure data before x/y would otherwise update
    old_x/y with bogus values, leading to jumps when the first x/y coordinates
    were actually reported.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit d9809d7edd2be714a15115b990286554e2979fb6)

diff --git a/src/evdev.c b/src/evdev.c
index 1d34827..482f7fd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -342,6 +342,9 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
     return 100; /* come back in 100 ms */
 }
 
+#define ABS_X_VALUE 0x1
+#define ABS_Y_VALUE 0x2
+#define ABS_VALUE   0x4
 /**
  * Take one input event and process it accordingly.
  */
@@ -392,7 +395,12 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
             if (ev->code > ABS_MAX)
                 break;
             pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
-            abs = 1;
+            if (ev->code == ABS_X)
+                abs |= ABS_X_VALUE;
+            else if (ev->code == ABS_Y)
+                abs |= ABS_Y_VALUE;
+            else
+                abs |= ABS_VALUE;
             break;
 
         case EV_KEY:
@@ -443,18 +451,20 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
         case EV_SYN:
             /* convert to relative motion for touchpads */
             if (abs && (pEvdev->flags & EVDEV_TOUCHPAD)) {
-                abs = 0;
-                rel = 1;
                 if (pEvdev->tool) { /* meaning, touch is active */
                     if (pEvdev->old_vals[0] != -1)
                         delta[REL_X] = pEvdev->vals[0] - pEvdev->old_vals[0];
                     if (pEvdev->old_vals[1] != -1)
                         delta[REL_Y] = pEvdev->vals[1] - pEvdev->old_vals[1];
-                    pEvdev->old_vals[0] = pEvdev->vals[0];
-                    pEvdev->old_vals[1] = pEvdev->vals[1];
+                    if (abs & ABS_X_VALUE)
+                        pEvdev->old_vals[0] = pEvdev->vals[0];
+                    if (abs & ABS_Y_VALUE)
+                        pEvdev->old_vals[1] = pEvdev->vals[1];
                 } else {
                     pEvdev->old_vals[0] = pEvdev->old_vals[1] = -1;
                 }
+                abs = 0;
+                rel = 1;
             }
 
             if (rel) {
@@ -537,6 +547,10 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
     }
 }
 
+#undef ABS_X_VALUE
+#undef ABS_Y_VALUE
+#undef ABS_VALUE
+
 /* just a magic number to reduce the number of reads */
 #define NUM_EVENTS 16
 

commit 79d4956add44d1150e835cbb0d44d3d1c9077203
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 17 13:25:58 2009 +1000

    If we have a touchpad, print so, don't claim we're configuring a tablet.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit b11439a1763b5f210460b492dd4f47e973f90a3a)

diff --git a/src/evdev.c b/src/evdev.c
index 6aafce2..1d34827 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1505,7 +1505,10 @@ EvdevProbe(InputInfoPtr pInfo)
     if (has_axes && num_buttons) {
         pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
                         XI86_CONFIGURED;
-        if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask)) {
+	if (pEvdev->flags & EVDEV_TOUCHPAD) {
+	    xf86Msg(X_INFO, "%s: Configuring as touchpad\n", pInfo->name);
+	    pInfo->type_name = XI_TOUCHPAD;
+	} else if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask)) {
 	    xf86Msg(X_INFO, "%s: Configuring as tablet\n", pInfo->name);
 	    pInfo->type_name = XI_TABLET;
 	} else {

commit 7e9809837c41a9ad0822a9bbc59362a3ba666696
Author: Jeremy Jay <dinkumator@gmail.com>
Date:   Mon Mar 16 23:19:54 2009 -0400

    make sure to clear all axis_map entries
    
    don't use uninitialized axis_map entries, ie axis_map[ABS_PRESSURE]
    
    Signed-off-by: Jeremy Jay <dinkumator@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 740dc202f735106532dce581deabe2b95c52759f)

diff --git a/src/evdev.c b/src/evdev.c
index 6ec7374..6aafce2 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1136,12 +1136,17 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
 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)

commit d07692a4af507504b2d3c5a2172b8b23a4d7e2f4
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 17 08:02:00 2009 +1000

    Assume touchscreen/touchpad if we have _either_ ABS_PRESSURE or BTN_TOUCH
    
    Touchpads have pressure or touch and also BTN_TOOL_FINGER.
    Touchscreens have either pressure or touch, but no finger.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 7ac0c4456dc0846f7e09f334a26f9536e20065df)

diff --git a/src/evdev.c b/src/evdev.c
index fd4ad2d..6ec7374 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1472,9 +1472,9 @@ EvdevProbe(InputInfoPtr pInfo)
         TestBit(ABS_Y, pEvdev->abs_bitmask)) {
         xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
         pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
-        if (!TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) &&
-             TestBit(BTN_TOUCH, pEvdev->key_bitmask)) {
-            if (num_buttons) {
+        if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) ||
+            TestBit(BTN_TOUCH, pEvdev->key_bitmask)) {
+            if (num_buttons || TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask)) {
                 xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
                 pEvdev->flags |= EVDEV_TOUCHPAD;
                 memset(pEvdev->old_vals, -1, sizeof(int) * pEvdev->num_vals);

commit 1073cd4fdca2152898d9e27d7d237452a37d9f81
Author: Jeremy Jay <dinkumator@gmail.com>
Date:   Mon Mar 16 08:36:53 2009 +1000

    Set "rel" when converting absolute touchpad coordinates to relative (#20661)
    
    We unset "abs" and convert to relative, but never set "rel" so the events
    don't get posted. This bit got broken in 43dd2a959243877.
    
    X.Org Bug 20661 <http://bugs.freedesktop.org/show_bug.cgi?id=20661>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit a3ea979c2b70d166d62422b4ba450ce2910389c3)

diff --git a/src/evdev.c b/src/evdev.c
index bc29ac9..fd4ad2d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -444,6 +444,7 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
             /* convert to relative motion for touchpads */
             if (abs && (pEvdev->flags & EVDEV_TOUCHPAD)) {
                 abs = 0;
+                rel = 1;
                 if (pEvdev->tool) { /* meaning, touch is active */
                     if (pEvdev->old_vals[0] != -1)
                         delta[REL_X] = pEvdev->vals[0] - pEvdev->old_vals[0];

commit 486bbdc481a6eb337b57a7b85a99267cf2879aae
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Mar 10 15:17:53 2009 +1000

    Restore repeat-filtering for server 1.5 and earlier.
    
    Letting the server deal with key repeats is fine if we have server 1.6. For
    earlier servers, we need to pass on the repeat events (except for modifier
    keys).
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Tested-by: Marty Jack <martyj19@comcast.net>
    (cherry picked from commit a7fb654a68a26ad5f019a902312c6b94dbe9c3ea)

diff --git a/src/evdev.c b/src/evdev.c
index 04bce96..bc29ac9 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -263,8 +263,17 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
     static char warned[KEY_CNT];
 
     /* Filter all repeated events from device.
-       We'll do softrepeat in the server */
-    if (value == 2)
+       We'll do softrepeat in the server, but only since 1.6 */
+    if (value == 2
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) <= 2
+        && (ev->code == KEY_LEFTCTRL || ev->code == KEY_RIGHTCTRL ||
+            ev->code == KEY_LEFTSHIFT || ev->code == KEY_RIGHTSHIFT ||
+            ev->code == KEY_LEFTALT || ev->code == KEY_RIGHTALT ||
+            ev->code == KEY_LEFTMETA || ev->code == KEY_RIGHTMETA ||
+            ev->code == KEY_CAPSLOCK || ev->code == KEY_NUMLOCK ||
+            ev->code == KEY_SCROLLLOCK) /* XXX windows keys? */
+#endif
+            )
 	return;
 
     if (code > 255)

commit 73e5eba8cd9ef885542c94b72b783366228ce0df
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 9 09:27:19 2009 +1000

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

diff --git a/configure.ac b/configure.ac
index d3a51a6..c1549eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-evdev],
-        2.1.99.1,
+        2.2.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-evdev)
 

commit 31853c39bfae7bb1035485407fd245cd11337d4f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 9 09:29:48 2009 +1000

    Define MAX_VALUATORS if it's missing to allow for builds against 1.5.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.h b/src/evdev.h
index bd25a26..6745a07 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -59,6 +59,11 @@
 #define HAVE_PROPERTIES 1
 #endif
 
+#ifndef MAX_VALUATORS
+#define MAX_VALUATORS 36
+#endif
+
+
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
 typedef struct {
     char *rules;

commit 2c49e21a815632fc1addd04dde96592237757a2e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 9 09:05:10 2009 +1000

    Check button label before fetching the Atom from the server.  (#20524)
    
    The server doesn't like NULL names, so don't call XIGetKnownProperty for
    labels that don't exist.
    
    X.Org Bug 20524 <http://bugs.freedesktop.org/show_bug.cgi?id=20524>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Tested-by: Peter Henriksson

diff --git a/src/evdev.c b/src/evdev.c
index 519fd6a..04bce96 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2002,6 +2002,9 @@ EvdevInitProperty(DeviceIntPtr dev)
                     int group = (button % 0x100)/16;
                     int idx = button - ((button/16) * 16);
 
+                    if (!btn_labels[group][idx])
+                        continue;
+
                     atom = XIGetKnownProperty(btn_labels[group][idx]);
                     if (!atom)
                         continue;

commit 4361b3efa0da5e85da7f0506c81dba31e59dc897
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Mar 6 08:13:36 2009 +1000

    Fix duplicate wheel button up mapping.
    
    Reported by Simon Thum.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Simon Thum <simon.thum@gmx.de>

diff --git a/src/evdev.c b/src/evdev.c
index 8332500..519fd6a 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2014,7 +2014,7 @@ EvdevInitProperty(DeviceIntPtr dev)
 
             /* wheel buttons, hardcoded anyway */
             atoms[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
-            atoms[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+            atoms[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
             atoms[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
             atoms[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
 

commit 281a7b4b88015c768639b7ae960b62f3539f012b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Mar 2 16:27:47 2009 +1000

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

diff --git a/configure.ac b/configure.ac
index eeabecb..d3a51a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-evdev],
-        2.1.99,
+        2.1.99.1,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-evdev)
 

commit 051cb8b528f6eddddccee44842bcb2152ed0e418
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 26 12:14:20 2009 +1000

    Add support for button labelling.
    
    Buttons 4/5 and 6/7 are hardcoded for wheel buttons.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index baae3a4..8332500 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -122,6 +122,7 @@ static Atom prop_reopen = 0;
 static Atom prop_calibration = 0;
 static Atom prop_swap = 0;
 static Atom prop_axis_label = 0;
+static Atom prop_btn_label = 0;
 #endif
 
 /* All devices the evdev driver has allocated and knows about.
@@ -1799,6 +1800,88 @@ static char* rel_labels[] = {
     AXIS_LABEL_PROP_REL_WHEEL,
     AXIS_LABEL_PROP_REL_MISC
 };
+
+static char* btn_labels[][16] = {
+    { /* BTN_MISC group                 offset 0x100*/
+        BTN_LABEL_PROP_BTN_0,           /* 0x00 */
+        BTN_LABEL_PROP_BTN_1,           /* 0x01 */
+        BTN_LABEL_PROP_BTN_2,           /* 0x02 */
+        BTN_LABEL_PROP_BTN_3,           /* 0x03 */
+        BTN_LABEL_PROP_BTN_4,           /* 0x04 */
+        BTN_LABEL_PROP_BTN_5,           /* 0x05 */
+        BTN_LABEL_PROP_BTN_6,           /* 0x06 */
+        BTN_LABEL_PROP_BTN_7,           /* 0x07 */
+        BTN_LABEL_PROP_BTN_8,           /* 0x08 */
+        BTN_LABEL_PROP_BTN_9            /* 0x09 */
+    },
+    { /* BTN_MOUSE group                offset 0x110 */
+        BTN_LABEL_PROP_BTN_LEFT,        /* 0x00 */
+        BTN_LABEL_PROP_BTN_RIGHT,       /* 0x01 */
+        BTN_LABEL_PROP_BTN_MIDDLE,      /* 0x02 */
+        BTN_LABEL_PROP_BTN_SIDE,        /* 0x03 */
+        BTN_LABEL_PROP_BTN_EXTRA,       /* 0x04 */
+        BTN_LABEL_PROP_BTN_FORWARD,     /* 0x05 */
+        BTN_LABEL_PROP_BTN_BACK,        /* 0x06 */
+        BTN_LABEL_PROP_BTN_TASK         /* 0x07 */
+    },
+    { /* BTN_JOYSTICK group             offset 0x120 */
+        BTN_LABEL_PROP_BTN_TRIGGER,     /* 0x00 */
+        BTN_LABEL_PROP_BTN_THUMB,       /* 0x01 */
+        BTN_LABEL_PROP_BTN_THUMB2,      /* 0x02 */
+        BTN_LABEL_PROP_BTN_TOP,         /* 0x03 */
+        BTN_LABEL_PROP_BTN_TOP2,        /* 0x04 */
+        BTN_LABEL_PROP_BTN_PINKIE,      /* 0x05 */
+        BTN_LABEL_PROP_BTN_BASE,        /* 0x06 */
+        BTN_LABEL_PROP_BTN_BASE2,       /* 0x07 */
+        BTN_LABEL_PROP_BTN_BASE3,       /* 0x08 */
+        BTN_LABEL_PROP_BTN_BASE4,       /* 0x09 */
+        BTN_LABEL_PROP_BTN_BASE5,       /* 0x0a */
+        BTN_LABEL_PROP_BTN_BASE6,       /* 0x0b */
+        NULL,
+        NULL,
+        NULL,
+        BTN_LABEL_PROP_BTN_DEAD         /* 0x0f */
+    },
+    { /* BTN_GAMEPAD group              offset 0x130 */
+        BTN_LABEL_PROP_BTN_A,           /* 0x00 */
+        BTN_LABEL_PROP_BTN_B,           /* 0x01 */
+        BTN_LABEL_PROP_BTN_C,           /* 0x02 */
+        BTN_LABEL_PROP_BTN_X,           /* 0x03 */
+        BTN_LABEL_PROP_BTN_Y,           /* 0x04 */
+        BTN_LABEL_PROP_BTN_Z,           /* 0x05 */
+        BTN_LABEL_PROP_BTN_TL,          /* 0x06 */
+        BTN_LABEL_PROP_BTN_TR,          /* 0x07 */
+        BTN_LABEL_PROP_BTN_TL2,         /* 0x08 */
+        BTN_LABEL_PROP_BTN_TR2,         /* 0x09 */
+        BTN_LABEL_PROP_BTN_SELECT,      /* 0x0a */
+        BTN_LABEL_PROP_BTN_START,       /* 0x0b */
+        BTN_LABEL_PROP_BTN_MODE,        /* 0x0c */
+        BTN_LABEL_PROP_BTN_THUMBL,      /* 0x0d */
+        BTN_LABEL_PROP_BTN_THUMBR       /* 0x0e */
+    },
+    { /* BTN_DIGI group                         offset 0x140 */
+        BTN_LABEL_PROP_BTN_TOOL_PEN,            /* 0x00 */
+        BTN_LABEL_PROP_BTN_TOOL_RUBBER,         /* 0x01 */
+        BTN_LABEL_PROP_BTN_TOOL_BRUSH,          /* 0x02 */
+        BTN_LABEL_PROP_BTN_TOOL_PENCIL,         /* 0x03 */
+        BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH,       /* 0x04 */
+        BTN_LABEL_PROP_BTN_TOOL_FINGER,         /* 0x05 */
+        BTN_LABEL_PROP_BTN_TOOL_MOUSE,          /* 0x06 */
+        BTN_LABEL_PROP_BTN_TOOL_LENS,           /* 0x07 */
+        NULL,
+        NULL,
+        BTN_LABEL_PROP_BTN_TOUCH,               /* 0x0a */
+        BTN_LABEL_PROP_BTN_STYLUS,              /* 0x0b */
+        BTN_LABEL_PROP_BTN_STYLUS2,             /* 0x0c */
+        BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP,      /* 0x0d */
+        BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP       /* 0x0e */
+    },
+    { /* BTN_WHEEL group                        offset 0x150 */
+        BTN_LABEL_PROP_BTN_GEAR_DOWN,           /* 0x00 */
+        BTN_LABEL_PROP_BTN_GEAR_UP              /* 0x01 */
+    }
+};
+
 #endif /* HAVE_LABELS */
 
 
@@ -1901,6 +1984,44 @@ EvdevInitProperty(DeviceIntPtr dev)
                                    PropModeReplace, natoms, &atoms, FALSE);
             XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
         }
+        /* Button labelling */
+        if ((prop_btn_label = XIGetKnownProperty(BTN_LABEL_PROP)))
+        {
+            Atom atom, atoms[pEvdev->buttons];
+            int button, bmap;
+
+            /* First, make sure all atoms are initialized */
+            atom = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+            for (button = 0; button < pEvdev->buttons; button++)
+                atoms[button] = atom;
+
+            for (button = BTN_MISC; button < BTN_JOYSTICK; button++)
+            {
+                if (TestBit(button, pEvdev->key_bitmask))
+                {
+                    int group = (button % 0x100)/16;
+                    int idx = button - ((button/16) * 16);
+
+                    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;
+                }
+            }
+
+            /* wheel buttons, hardcoded anyway */
+            atoms[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+            atoms[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+            atoms[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+            atoms[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+
+            XIChangeDeviceProperty(dev, prop_btn_label, XA_ATOM, 32,
+                                   PropModeReplace, pEvdev->buttons, &atoms, FALSE);
+            XISetDevicePropertyDeletable(dev, prop_btn_label, FALSE);
+        }
 #endif /* HAVE_LABELS */
     }
 
@@ -1966,8 +2087,8 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
 
         if (!checkonly)
             pEvdev->swap_axes = *((BOOL*)val->data);
-    } else if (atom == prop_axis_label)
-        return BadAccess; /* Axis labels can't be changed */
+    } else if (atom == prop_axis_label || atom == prop_btn_label)
+        return BadAccess; /* Axis/Button labels can't be changed */
 
     return Success;
 }

commit 1abcc881715327614e248e9047c5fbd29a945c03
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 26 10:48:06 2009 +1000

    Rename prop_label to prop_axis_label.

diff --git a/src/evdev.c b/src/evdev.c
index 048315f..baae3a4 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -121,7 +121,7 @@ static Atom prop_invert = 0;
 static Atom prop_reopen = 0;
 static Atom prop_calibration = 0;
 static Atom prop_swap = 0;
-static Atom prop_label = 0;
+static Atom prop_axis_label = 0;
 #endif
 
 /* All devices the evdev driver has allocated and knows about.
@@ -1858,7 +1858,7 @@ EvdevInitProperty(DeviceIntPtr dev)
 
 #ifdef HAVE_LABELS
         /* Axis labelling */
-        if ((prop_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
+        if ((prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
         {
             Atom atom, atoms[pEvdev->num_vals];
             int natoms = pEvdev->num_vals;
@@ -1897,9 +1897,9 @@ EvdevInitProperty(DeviceIntPtr dev)
                 atoms[pEvdev->axis_map[axis]] = atom;
             }
 
-            XIChangeDeviceProperty(dev, prop_label, XA_ATOM, 32,
+            XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
                                    PropModeReplace, natoms, &atoms, FALSE);
-            XISetDevicePropertyDeletable(dev, prop_label, FALSE);
+            XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
         }
 #endif /* HAVE_LABELS */
     }
@@ -1966,7 +1966,7 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
 
         if (!checkonly)
             pEvdev->swap_axes = *((BOOL*)val->data);
-    } else if (atom == prop_label)
+    } else if (atom == prop_axis_label)
         return BadAccess; /* Axis labels can't be changed */
 
     return Success;

commit c89bbf80be65eb9d0d20871761d22c6d6d76708b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 26 12:14:03 2009 +1000

    Don't double-assign the UKNOWN axis label.
    
    All labels default to unknown anyway.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index c53e3af..048315f 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1892,7 +1892,7 @@ EvdevInitProperty(DeviceIntPtr dev)
 
                 atom = XIGetKnownProperty(labels[axis]);
                 if (!atom) /* Should not happen */
-                    atom = XIGetKnownProperty(misc_label);
+                    continue;
 
                 atoms[pEvdev->axis_map[axis]] = atom;
             }

commit 178435832f5f6988e58fddc4ffe82ddc032d9dce
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 26 12:09:33 2009 +1000

    If scrollwheels are found, bump the button number by 4 (or up to 7).
    
    Scrollwheel data is always posted as buttons, so we need to advertise at least
    enough buttons to accommodate for 6/7 (horizontal wheel).
    
    Note that this may mean that if you have a device that has scroll wheels and
    axes, but no buttons, it may be interpreted as a mouse.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index d9e1367..c53e3af 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1450,6 +1450,11 @@ EvdevProbe(InputInfoPtr pInfo)
         TestBit(REL_HWHEEL, pEvdev->rel_bitmask)) {
         xf86Msg(X_INFO, "%s: Found scroll wheel(s)\n", pInfo->name);
         has_scroll = TRUE;
+        if (!num_buttons)
+            xf86Msg(X_INFO, "%s: Forcing buttons for scroll wheel(s)\n",
+                    pInfo->name);
+        num_buttons = (num_buttons < 3) ? 7 : num_buttons + 4;
+        pEvdev->buttons = num_buttons;
     }
 
     if (TestBit(ABS_X, pEvdev->abs_bitmask) &&

commit c9cab83bac32275f6851d2616bb749b3b2621ed6
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 24 11:32:40 2009 +1000

    Ignore REL_WHEEL, REL_HWHEEL and REL_DIAL during axis initialisation.
    
    We don't post the events for them anyway, so lets ignore them completely.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 7112c11..d9e1367 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1012,6 +1012,15 @@ EvdevAddRelClass(DeviceIntPtr device)
     if (num_axes < 1)
         return !Success;
 
+    /* Wheels are special, we post them as button events. So let's ignore them
+     * in the axes list too */
+    if (TestBit(REL_WHEEL, pEvdev->rel_bitmask))
+        num_axes--;
+    if (TestBit(REL_HWHEEL, pEvdev->rel_bitmask))
+        num_axes--;
+    if (TestBit(REL_DIAL, pEvdev->rel_bitmask))
+        num_axes--;
+
     pEvdev->num_vals = num_axes;
     memset(pEvdev->vals, 0, num_axes * sizeof(int));
 
@@ -1024,7 +1033,11 @@ EvdevAddRelClass(DeviceIntPtr device)
 
     for (axis = REL_X; axis <= REL_MAX; axis++)
     {
+
         pEvdev->axis_map[axis] = -1;
+        /* We don't post wheel events, so ignore them here too */
+        if (axis == REL_WHEEL || axis == REL_HWHEEL || axis == REL_DIAL)
+            continue;
         if (!TestBit(axis, pEvdev->rel_bitmask))
             continue;
         pEvdev->axis_map[axis] = i;

commit 43dd2a959243877c1628a08b4fc6c07c9ae6bac0
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 24 10:36:41 2009 +1000

    Pass on all relative events, not just x/y.
    
    9620fe776 added generic axes support for relativ values, but values from such
    axes didn't get passed on to the server. Fix this.
    
    Note that wheel events are not posted as motion events.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index c9fd53b..7112c11 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -338,8 +338,9 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
 static void
 EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
 {
-    static int dx, dy, tmp, value;
-    static unsigned int abs;
+    static int delta[REL_CNT];
+    static int tmp, value;
+    static unsigned int abs, rel;
     unsigned int button;
     EvdevPtr pEvdev = pInfo->private;
 
@@ -352,15 +353,9 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
             if (EvdevWheelEmuFilterMotion(pInfo, ev))
                 break;
 
-            switch (ev->code) {
-                case REL_X:
-                    dx += value;
-                    break;
-
-                case REL_Y:
-                    dy += value;
-                    break;
+            rel = 1;
 
+            switch (ev->code) {
                 case REL_WHEEL:
                     if (value > 0)
                         PostButtonClicks(pInfo, wheel_up_button, value);
@@ -375,6 +370,11 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
                     else if (value < 0)
                         PostButtonClicks(pInfo, wheel_left_button, -value);
                     break;
+
+                /* We don't post wheel events as axis motion. */
+                default:
+                    delta[ev->code] += value;
+                    break;
             }
             break;
 
@@ -436,9 +436,9 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
                 abs = 0;
                 if (pEvdev->tool) { /* meaning, touch is active */
                     if (pEvdev->old_vals[0] != -1)
-                        dx = pEvdev->vals[0] - pEvdev->old_vals[0];
+                        delta[REL_X] = pEvdev->vals[0] - pEvdev->old_vals[0];
                     if (pEvdev->old_vals[1] != -1)
-                        dy = pEvdev->vals[1] - pEvdev->old_vals[1];
+                        delta[REL_Y] = pEvdev->vals[1] - pEvdev->old_vals[1];
                     pEvdev->old_vals[0] = pEvdev->vals[0];
                     pEvdev->old_vals[1] = pEvdev->vals[1];
                 } else {
@@ -446,17 +446,36 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
                 }
             }
 
-            if (dx != 0 || dy != 0) {
+            if (rel) {
+                int post_deltas[REL_CNT] = {0}; /* axis-mapped deltas */
+                int first = REL_CNT, last = 0;
+                int i;
+
                 if (pEvdev->swap_axes) {
-                    tmp = dx;
-                    dx = dy;
-                    dy = tmp;
+                    tmp = delta[REL_X];
+                    delta[REL_X] = delta[REL_Y];
+                    delta[REL_Y] = tmp;
                 }
                 if (pEvdev->invert_x)
-                    dx *= -1;
+                    delta[REL_X] *= -1;
                 if (pEvdev->invert_y)
-                    dy *= -1;
-                xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, dx, dy);
+                    delta[REL_Y] *= -1;
+
+                for (i = 0; i < REL_CNT; i++)
+                {
+                    int map = pEvdev->axis_map[i];
+                    if (delta[i] && map != -1)
+                    {
+                        post_deltas[map] = delta[i];
+                        if (map < first)
+                            first = map;
+                        if (map > last)
+                            last = map;
+                    }
+                }
+
+                xf86PostMotionEventP(pInfo->dev, FALSE, first,
+                                     (last - first + 1), &post_deltas[first]);
             }
 
             /*
@@ -500,10 +519,10 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
                 xf86PostMotionEventP(pInfo->dev, TRUE, 0, pEvdev->num_vals, v);
             }
 
-            dx = 0;
-            dy = 0;
+            memset(delta, 0, sizeof(delta));
             tmp = 0;
             abs = 0;
+            rel = 0;
     }
 }
 

commit 7977947e0df6ea6379dab76805b06be6bdd71947
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Feb 24 10:08:22 2009 +1000

    Reduce the number of read calls in ReadInput.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Adam Jackson <ajax@redhat.com>

diff --git a/src/evdev.c b/src/evdev.c
index 50ca103..c9fd53b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -507,23 +507,21 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
     }
 }
 
+/* just a magic number to reduce the number of reads */
+#define NUM_EVENTS 16
+
 static void
 EvdevReadInput(InputInfoPtr pInfo)
 {
-    struct input_event ev;
-    int len;
+    struct input_event ev[NUM_EVENTS];
+    int i, len = sizeof(ev);
     EvdevPtr pEvdev = pInfo->private;
 
-    while (1) {
-        len = read(pInfo->fd, &ev, sizeof ev);
-        if (len != sizeof ev) {
-	    if (errno == EAGAIN)
-		break;
-
-            /* The kernel promises that we always only read a complete
-             * event, so len != sizeof ev is an error. */
-            xf86Msg(X_ERROR, "%s: Read error: %s\n", pInfo->name, strerror(errno));
-
+    while (len == sizeof(ev))
+    {
+        len = read(pInfo->fd, &ev, sizeof(ev));
+        if (len == 0)
+        {
             if (errno == ENODEV) /* May happen after resume */
             {
                 xf86RemoveEnabledDevice(pInfo);
@@ -531,11 +529,21 @@ EvdevReadInput(InputInfoPtr pInfo)
                 pInfo->fd = -1;
                 pEvdev->reopen_left = pEvdev->reopen_attempts;
                 pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo);
-            }
+            } else if (errno != EAGAIN)
+                xf86Msg(X_ERROR, "%s: Read error: %s\n", pInfo->name,
+                        strerror(errno));
+            break;
+        }
+
+        if (len % sizeof(ev[0])) {
+            /* The kernel promises that we always only read a complete
+             * event, so len != sizeof ev is an error. */
+            xf86Msg(X_ERROR, "%s: Read error: %s\n", pInfo->name, strerror(errno));
             break;
         }
 
-        EvdevProcessEvent(pInfo, &ev);
+        for (i = 0; i < len/sizeof(ev[0]); i++)
+            EvdevProcessEvent(pInfo, &ev[i]);
     }
 }
 

commit 11a56d4a176a2c5b2f8794147d4bafd88477b80b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Feb 24 09:39:01 2009 +1000

    Split ReadInput into ReadInput and ProcessEvent.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 4af9c03..50ca103 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -332,20 +332,187 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
     return 100; /* come back in 100 ms */
 }
 
+/**
+ * Take one input event and process it accordingly.
+ */
 static void
-EvdevReadInput(InputInfoPtr pInfo)
+EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
 {
-    struct input_event ev;
-    int len, value;
-    int dx, dy, tmp;
-    unsigned int abs;
+    static int dx, dy, tmp, value;
+    static unsigned int abs;
     unsigned int button;
     EvdevPtr pEvdev = pInfo->private;
 
-    dx = 0;
-    dy = 0;
-    tmp = 0;
-    abs = 0;
+    /* Get the signed value, earlier kernels had this as unsigned */
+    value = ev->value;
+
+    switch (ev->type) {
+        case EV_REL:
+            /* Handle mouse wheel emulation */
+            if (EvdevWheelEmuFilterMotion(pInfo, ev))
+                break;
+
+            switch (ev->code) {
+                case REL_X:
+                    dx += value;
+                    break;
+
+                case REL_Y:
+                    dy += value;
+                    break;
+
+                case REL_WHEEL:
+                    if (value > 0)
+                        PostButtonClicks(pInfo, wheel_up_button, value);
+                    else if (value < 0)
+                        PostButtonClicks(pInfo, wheel_down_button, -value);
+                    break;
+
+                case REL_DIAL:
+                case REL_HWHEEL:
+                    if (value > 0)
+                        PostButtonClicks(pInfo, wheel_right_button, value);
+                    else if (value < 0)
+                        PostButtonClicks(pInfo, wheel_left_button, -value);
+                    break;
+            }
+            break;
+
+        case EV_ABS:
+            if (ev->code > ABS_MAX)
+                break;
+            pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
+            abs = 1;
+            break;
+
+        case EV_KEY:
+            /* don't repeat mouse buttons */
+            if (ev->code >= BTN_MOUSE && ev->code < KEY_OK)
+                if (value == 2)
+                    break;
+
+            switch (ev->code) {
+                case BTN_TOUCH:
+                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:
+                    pEvdev->tool = value ? ev->code : 0;
+                    if (!(pEvdev->flags & EVDEV_TOUCHSCREEN))
+                        break;
+                    /* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
+                     * BTN_LEFT. */
+                    ev->code = BTN_LEFT;
+                    /* Intentional fallthrough! */
+


Reply to: