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

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



 .gitignore                                                                |    1 
 COPYING                                                                   |   99 +
 ChangeLog                                                                 |  744 ++++++++-
 Makefile.am                                                               |    5 
 configure.ac                                                              |   28 
 debian/changelog                                                          |   11 
 debian/patches/include-the-proper-header-for-XkbSetRulesDflts-and-X.patch |   21 
 debian/patches/series                                                     |    1 
 include/Makefile.am                                                       |    2 
 include/evdev-properties.h                                                |   69 
 man/Makefile.am                                                           |    2 
 man/evdev.man                                                             |  155 +
 src/Makefile.am                                                           |    7 
 src/draglock.c                                                            |  318 +++
 src/emuMB.c                                                               |  102 +
 src/emuWheel.c                                                            |  466 +++++
 src/evdev.c                                                               |  813 ++++++++--
 src/evdev.h                                                               |   83 -
 xorg-evdev.pc.in                                                          |    6 
 19 files changed, 2664 insertions(+), 269 deletions(-)

New commits:
commit c4037996e6aa87057132b10938b2d26bc3d9d7d4
Author: Julien Cristau <jcristau@debian.org>
Date:   Wed Nov 12 00:08:29 2008 +0100

    Drop patch, update changelog for new upstream

diff --git a/debian/changelog b/debian/changelog
index 9f56a3a..8d24ae8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,15 @@
-xserver-xorg-input-evdev (1:2.0.4-1) UNRELEASED; urgency=low
+xserver-xorg-input-evdev (1:2.0.99.3-1) UNRELEASED; urgency=low
 
-  * New upstream release.
+  [ Timo Aaltonen ]
   * rules: Clean config.h.in.
 
+  [ Julien Cristau ]
+  * New upstream release.
+    + don't grab the device by default
+    + close the device on DEVICE_OFF, and reopen it on DEVICE_ON
+      (closes: #496101, #492146)
+  * Drop patch included upstream.
+
  -- Timo Aaltonen <tepsipakki@ubuntu.com>  Fri, 12 Sep 2008 14:52:54 +0300
 
 xserver-xorg-input-evdev (1:2.0.3-2) experimental; urgency=low
diff --git a/debian/patches/include-the-proper-header-for-XkbSetRulesDflts-and-X.patch b/debian/patches/include-the-proper-header-for-XkbSetRulesDflts-and-X.patch
deleted file mode 100644
index 8b3d7d4..0000000
--- a/debian/patches/include-the-proper-header-for-XkbSetRulesDflts-and-X.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-From 9007585c1fce21e786372c2f1ca1c7776f3eafdb Mon Sep 17 00:00:00 2001
-From: Julien Cristau <jcristau@debian.org>
-Date: Thu, 22 May 2008 20:54:02 +0200
-Subject: [PATCH] include the proper header for XkbSetRulesDflts and XkbInitKeyboardDeviceStruct
-
----
- src/evdev.h |    3 +--
- 1 files changed, 1 insertions(+), 2 deletions(-)
-
---- xserver-xorg-input-evdev.orig/src/evdev.h
-+++ xserver-xorg-input-evdev/src/evdev.h
-@@ -36,8 +36,7 @@
- #include <xf86_OSproc.h>
- 
- #if defined(XKB)
--/* XXX VERY WRONG.  this is a client side header. */
--#include <X11/extensions/XKBstr.h>
-+#include <xkbsrv.h>
- #endif
- 
- typedef struct {
diff --git a/debian/patches/series b/debian/patches/series
index 0bc726b..e69de29 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +0,0 @@
-include-the-proper-header-for-XkbSetRulesDflts-and-X.patch

commit 7ef4e2c5e14e558f41fb7f411e2976f517b6b526
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Mon Nov 3 13:47:15 2008 +1030

    evdev 2.1 RC 3
    
    That's it, no more new features. Now it's down to bugfixing only.

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

commit dd0eeacc24a80893209f24d9ad028a6bc7e3a390
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Mon Nov 3 13:25:06 2008 +1030

    Add support for axes swapping.
    
    New option: SwapAxes (boolean)
    New property: EVDEV_PROP_SWAP_AXES.
    
    Actual swapping code written by Donnie Berkholz.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
    (cherry picked from commit 4826969f23a0b298da2750c2e23a92b9d91819dd)

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index be4307b..31f6c66 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -62,4 +62,8 @@
 /* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */
 #define EVDEV_PROP_CALIBRATION "Evdev Axis Calibration"
 
+/* Swap x and y axis. */
+/* BOOL */
+#define EVDEV_PROP_SWAP_AXES "Evdev Axes Swap"
+
 #endif
diff --git a/man/evdev.man b/man/evdev.man
index fc8a96a..cf087e8 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -147,6 +147,9 @@ waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
 .BI "Option \*qInvertY\*q \*q" Bool \*q
 Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
 .TP 7
+.BI "Option \*qSwapAxes\*q \*q" Bool \*q
+Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
+.TP 7
 .BI "Option \*qGrabDevice\*q \*q" boolean \*q
 Force a grab on the event device. Doing so will ensure that no other driver
 can initialise the same device and it will also stop the device from sending
@@ -191,6 +194,9 @@ value.
 run-time axis calibration. This feature is required for devices that need to
 scale to a different coordinate system than originally reported to the X
 server, such as touchscreens that require run-time calibration.
+.TP 7
+.BI "Evdev Axis Swap"
+1 boolean values (8 bit, 0 or 1). 1 swaps x/y axes.
 
 .SH AUTHORS
 Kristian Høgsberg.
diff --git a/src/evdev.c b/src/evdev.c
index aa8a10d..638831d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -109,6 +109,7 @@ static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
 static Atom prop_invert = 0;
 static Atom prop_reopen = 0;
 static Atom prop_calibration = 0;
+static Atom prop_swap = 0;
 #endif
 
 
@@ -227,13 +228,14 @@ EvdevReadInput(InputInfoPtr pInfo)
 {
     struct input_event ev;
     int len, value;
-    int dx, dy;
+    int dx, dy, tmp;
     unsigned int abs;
     unsigned int button;
     EvdevPtr pEvdev = pInfo->private;
 
     dx = 0;
     dy = 0;
+    tmp = 0;
     abs = 0;
 
     while (xf86WaitForInput (pInfo->fd, 0) > 0) {
@@ -369,6 +371,11 @@ EvdevReadInput(InputInfoPtr pInfo)
     }
 
     if (dx != 0 || dy != 0) {
+        if (pEvdev->swap_axes) {
+            tmp = dx;
+            dx = dy;
+            dy = tmp;
+        }
         if (pEvdev->invert_x)
             dx *= -1;
         if (pEvdev->invert_y)
@@ -387,8 +394,8 @@ EvdevReadInput(InputInfoPtr pInfo)
      */
     if (abs && pEvdev->tool) {
         int abs_x, abs_y;
-        abs_x = pEvdev->abs_x;
-        abs_y = pEvdev->abs_y;
+        abs_x = (pEvdev->swap_axes) ? pEvdev->abs_y : pEvdev->abs_x;
+        abs_y = (pEvdev->swap_axes) ? pEvdev->abs_x : pEvdev->abs_y;
 
         if (pEvdev->flags & EVDEV_CALIBRATED)
         {
@@ -1382,6 +1389,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     pEvdev->reopen_attempts = xf86SetIntOption(pInfo->options, "ReopenAttempts", 10);
     pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
     pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
+    pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
 
     /* Grabbing the event device stops in-kernel event forwarding. In other
        words, it disables rfkill and the "Macintosh mouse button emulation".
@@ -1565,6 +1573,16 @@ EvdevInitProperty(DeviceIntPtr dev)
         return;
 
     XISetDevicePropertyDeletable(dev, prop_calibration, FALSE);
+
+    prop_swap = MakeAtom(EVDEV_PROP_SWAP_AXES,
+                         strlen(EVDEV_PROP_SWAP_AXES), TRUE);
+
+    rc = XIChangeDeviceProperty(dev, prop_swap, XA_INTEGER, 8,
+                                PropModeReplace, 1, &pEvdev->swap_axes, FALSE);
+    if (rc != Success)
+        return;
+
+    XISetDevicePropertyDeletable(dev, prop_swap, FALSE);
 }
 
 static int
@@ -1620,6 +1638,13 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
                 pEvdev->calibration.max_y = vals[3];
             }
         }
+    } else if (atom == prop_swap)
+    {
+        if (val->format != 8 || val->type != XA_INTEGER || val->size != 1)
+            return BadMatch;
+
+        if (!checkonly)
+            pEvdev->swap_axes = *((BOOL*)val->data);
     }
 
     return Success;
diff --git a/src/evdev.h b/src/evdev.h
index 5696978..32da81c 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -64,6 +64,7 @@ typedef struct {
     int flags;
     int tool;
     int buttons;            /* number of buttons */
+    BOOL swap_axes;
     BOOL invert_x;
     BOOL invert_y;
 

commit 67c0ea6c9421a5226c1b8bc3a198b1cb01f6b355
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Thu Oct 30 16:55:29 2008 +1030

    Add support for run-time calibration.
    
    Some devices require run-time axis calibration. We can't change the min/max
    ranges once we've initialised the valuator structs though, so in-driver
    run-time calibration is required.
    
    If the property is set, the driver scales from the calibrated range to the
    values reported to the X server (which then may scale to screen coordinates).
    If the property is not set (i.e. zero items) no scaling is performed.
    (cherry picked from commit 33eb36f26663c09c873acede1b35e91ef4c64479)

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index 89f25f1..be4307b 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -58,4 +58,8 @@
 /* CARD8 */
 #define EVDEV_PROP_REOPEN "Evdev Reopen Attempts"
 
+/* Run-time calibration */
+/* CARD32, 4 values [minx, maxx, miny, maxy], or no values for unset */
+#define EVDEV_PROP_CALIBRATION "Evdev Axis Calibration"
+
 #endif
diff --git a/man/evdev.man b/man/evdev.man
index 9d336fc..fc8a96a 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -186,6 +186,11 @@ value.
 .TP 7
 .BI "Evdev Axis Inversion"
 2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
+.BI "Evdev Axis Calibration"
+4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable
+run-time axis calibration. This feature is required for devices that need to
+scale to a different coordinate system than originally reported to the X
+server, such as touchscreens that require run-time calibration.
 
 .SH AUTHORS
 Kristian Høgsberg.
diff --git a/src/evdev.c b/src/evdev.c
index 9ef2829..aa8a10d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -76,6 +76,7 @@
 #define EVDEV_TOUCHPAD		(1 << 4)
 #define EVDEV_INITIALIZED	(1 << 5) /* WheelInit etc. called already? */
 #define EVDEV_TOUCHSCREEN	(1 << 6)
+#define EVDEV_CALIBRATED	(1 << 7) /* run-time calibrated? */
 
 #define MIN_KEYCODE 8
 #define GLYPHS_PER_KEY 2
@@ -107,6 +108,7 @@ static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
                             XIPropertyValuePtr val, BOOL checkonly);
 static Atom prop_invert = 0;
 static Atom prop_reopen = 0;
+static Atom prop_calibration = 0;
 #endif
 
 
@@ -387,6 +389,17 @@ EvdevReadInput(InputInfoPtr pInfo)
         int abs_x, abs_y;
         abs_x = pEvdev->abs_x;
         abs_y = pEvdev->abs_y;
+
+        if (pEvdev->flags & EVDEV_CALIBRATED)
+        {
+            abs_x = xf86ScaleAxis(abs_x,
+                    pEvdev->max_x, pEvdev->min_x,
+                    pEvdev->calibration.max_x, pEvdev->calibration.min_x);
+            abs_y = xf86ScaleAxis(abs_y,
+                    pEvdev->max_y, pEvdev->min_y,
+                    pEvdev->calibration.max_y, pEvdev->calibration.min_y);
+        }
+
         if (pEvdev->invert_x)
             abs_x = pEvdev->max_x - (abs_x - pEvdev->min_x);
         if (pEvdev->invert_y)
@@ -1542,6 +1555,16 @@ EvdevInitProperty(DeviceIntPtr dev)
         return;
 
     XISetDevicePropertyDeletable(dev, prop_reopen, FALSE);
+
+
+    prop_calibration = MakeAtom(EVDEV_PROP_CALIBRATION,
+                                strlen(EVDEV_PROP_CALIBRATION), TRUE);
+    rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER, 32,
+                                PropModeReplace, 0, NULL, FALSE);
+    if (rc != Success)
+        return;
+
+    XISetDevicePropertyDeletable(dev, prop_calibration, FALSE);
 }
 
 static int
@@ -1570,6 +1593,33 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
 
         if (!checkonly)
             pEvdev->reopen_attempts = *((CARD8*)val->data);
+    } else if (atom == prop_calibration)
+    {
+        if (val->format != 32 || val->type != XA_INTEGER)
+            return BadMatch;
+        if (val->size != 4 && val->size != 0)
+            return BadMatch;
+
+        if (!checkonly)
+        {
+            if (val->size == 0)
+            {
+                pEvdev->flags &= ~EVDEV_CALIBRATED;
+                pEvdev->calibration.min_x = 0;
+                pEvdev->calibration.max_x = 0;
+                pEvdev->calibration.min_y = 0;
+                pEvdev->calibration.max_y = 0;
+            } else if (val->size == 4)
+            {
+                CARD32 *vals = (CARD32*)val->data;
+
+                pEvdev->flags |= EVDEV_CALIBRATED;
+                pEvdev->calibration.min_x = vals[0];
+                pEvdev->calibration.max_x = vals[1];
+                pEvdev->calibration.min_y = vals[2];
+                pEvdev->calibration.max_y = vals[3];
+            }
+        }
     }
 
     return Success;
diff --git a/src/evdev.h b/src/evdev.h
index 5a97185..5696978 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -102,6 +102,13 @@ typedef struct {
         Time                expires;     /* time of expiry */
         Time                timeout;
     } emulateWheel;
+    /* run-time calibration */
+    struct {
+        int                 min_x;
+        int                 max_x;
+        int                 min_y;
+        int                 max_y;
+    } calibration;
 
     unsigned char btnmap[32];           /* config-file specified button mapping */
 

commit 6bcbbc0411cf3466edeb1fcbb393290cadfd3082
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Wed Oct 29 13:50:07 2008 +1030

    Treat BTN_[0-2] as LMR buttons if necessary.
    
    Treat BTN_[0-2] as LMR buttons on devices that do not advertise BTN_LEFT,
    BTN_MIDDLE, BTN_RIGHT (e.g. 3Dconnexion SpaceNavigator).
    
    Otherwise, treat BTN_[0+n] as button 5+n. Note: This causes duplicate
    mappings for BTN_0 + n and  BTN_SIDE + n.
    
    This also fixes a bug where we could end up with negative button numbers after
    trying to map BTN_0.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
    (cherry picked from commit 64554e4799a697d37dfd8be480f8eee636b9bea1)

diff --git a/src/evdev.c b/src/evdev.c
index cc072d8..9ef2829 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -326,7 +326,7 @@ EvdevReadInput(InputInfoPtr pInfo)
                 /* Intentional fallthrough! */
 
             default:
-		button = EvdevUtilButtonEventToButtonNumber(ev.code);
+		button = EvdevUtilButtonEventToButtonNumber(pEvdev, ev.code);
 
 		/* Handle drag lock */
 		if (EvdevDragLockFilterEvent(pInfo, button, value))
@@ -1448,7 +1448,7 @@ _X_EXPORT XF86ModuleData evdevModuleData =
  * returns 0 on non-button event.
  */
 unsigned int
-EvdevUtilButtonEventToButtonNumber(int code)
+EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code)
 {
     unsigned int button = 0;
 
@@ -1465,6 +1465,21 @@ EvdevUtilButtonEventToButtonNumber(int code)
 	button = 2;
 	break;
 
+        /* Treat BTN_[0-2] as LMR buttons on devices that do not advertise
+           BTN_LEFT, BTN_MIDDLE, BTN_RIGHT.
+           Otherwise, treat BTN_[0+n] as button 5+n.
+           XXX: This causes duplicate mappings for BTN_0 + n and BTN_SIDE + n
+         */
+    case BTN_0:
+        button = (TestBit(BTN_LEFT, pEvdev->key_bitmask)) ?  8 : 1;
+        break;
+    case BTN_1:
+        button = (TestBit(BTN_MIDDLE, pEvdev->key_bitmask)) ?  9 : 2;
+        break;
+    case BTN_2:
+        button = (TestBit(BTN_RIGHT, pEvdev->key_bitmask)) ?  10 : 3;
+        break;
+
     case BTN_SIDE:
     case BTN_EXTRA:
     case BTN_FORWARD:
@@ -1475,8 +1490,12 @@ EvdevUtilButtonEventToButtonNumber(int code)
 
     default:
 	if ((code > BTN_TASK) && (code < KEY_OK)) {
-	    if (code < BTN_JOYSTICK)
-		button = (code - BTN_LEFT + 5);
+	    if (code < BTN_JOYSTICK) {
+                if (code < BTN_MOUSE)
+                    button = (code - BTN_0 + 5);
+                else
+                    button = (code - BTN_LEFT + 5);
+            }
 	}
     }
 
diff --git a/src/evdev.h b/src/evdev.h
index 7e1da15..5a97185 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -119,7 +119,7 @@ typedef struct {
     struct input_absinfo absinfo[ABS_MAX];
 } EvdevRec, *EvdevPtr;
 
-unsigned int EvdevUtilButtonEventToButtonNumber(int code);
+unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);
 
 /* Middle Button emulation */
 int  EvdevMBEmuTimer(InputInfoPtr);

commit 534a3734d088ff0155ebc7fca7ab246635cd725a
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Wed Oct 29 13:28:19 2008 +1030

    Remove obsolete FIXME
    
    xkeyboard-config's maps are perfectly able to cope with evdev now.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
    (cherry picked from commit b77f9398570fb8eae1fcf50bc3c10c9c390c6bac)

diff --git a/src/evdev.c b/src/evdev.c
index ea83afc..cc072d8 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -404,9 +404,6 @@ EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)
     /* Nothing to do, dix handles all settings */
 }
 
-/* FIXME: this map works with evdev keyboards, but all the xkb maps
- * probably don't.  The easiest is to remap the event keycodes.  */
-
 static KeySym map[] = {
     /* 0x00 */  NoSymbol,       NoSymbol,
     /* 0x01 */  XK_Escape,      NoSymbol,

commit 215c230d5c036e7d5c8e2621cf272a078149d969
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Tue Oct 28 12:09:26 2008 +1030

    Flush input after re-opening the fd.
    
    Suggested by Julien Cristau.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
    (cherry picked from commit a43ab4999b9cad10f77aa6c703d3c61b754f1fd4)

diff --git a/src/evdev.c b/src/evdev.c
index 26ae0a1..ea83afc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1007,6 +1007,7 @@ EvdevOn(DeviceIntPtr device)
         pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo);
     } else
     {
+        xf86FlushInput(pInfo->fd);
         xf86AddEnabledDevice(pInfo);
         EvdevMBEmuOn(pInfo);
         pEvdev->flags |= EVDEV_INITIALIZED;

commit 8f96530449b264e7f1f21ab1d030c5b361937774
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Mon Oct 27 15:54:49 2008 +1030

    emuMB: add EvdevMBEmuOn and call from EvdevOn to register wakeup handlers.
    
    This got broken in b0737bdbd1f6e601eb4984b6f4cb49279190984c, when the
    EmuMBPreInit call was removed from EvdevOn. As a result, VT switching away and
    back wouldn't restore the wakeup handlers and mouse button presses
    disappeared.
    (cherry picked from commit af096e8c5d8b425f725a37bf4a98e205e70716e9)

diff --git a/src/emuMB.c b/src/emuMB.c
index 4af0791..e5a767a 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -317,6 +317,11 @@ EvdevMBEmuPreInit(InputInfoPtr pInfo)
 
     pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
                                                  "Emulate3Timeout", 50);
+}
+
+void
+EvdevMBEmuOn(InputInfoPtr pInfo)
+{
     RegisterBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
                                     EvdevMBEmuWakeupHandler,
                                     (pointer)pInfo);
diff --git a/src/evdev.c b/src/evdev.c
index d112efe..26ae0a1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1008,6 +1008,7 @@ EvdevOn(DeviceIntPtr device)
     } else
     {
         xf86AddEnabledDevice(pInfo);
+        EvdevMBEmuOn(pInfo);
         pEvdev->flags |= EVDEV_INITIALIZED;
         device->public.on = TRUE;
     }
diff --git a/src/evdev.h b/src/evdev.h
index c2f614a..7e1da15 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -127,6 +127,7 @@ BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
 void EvdevMBEmuWakeupHandler(pointer, int, pointer);
 void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
 void EvdevMBEmuPreInit(InputInfoPtr);
+void EvdevMBEmuOn(InputInfoPtr);
 void EvdevMBEmuFinalize(InputInfoPtr);
 void EvdevMBEmuEnable(InputInfoPtr, BOOL);
 

commit 4fb97edcd4e3de23a8476ca4d0267f55293cccad
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Fri Oct 24 13:09:46 2008 +1030

    Fix axis inversion for absolute coordinates.
    
    If min_x/y was not equal to 0, the inverted calculated range was off and leads
    to inaccessible or out-of-range areas.
    (cherry picked from commit 12498042fcc08e34aef0117ce84192f59542fd56)

diff --git a/src/evdev.c b/src/evdev.c
index 482f95e..d112efe 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -388,9 +388,9 @@ EvdevReadInput(InputInfoPtr pInfo)
         abs_x = pEvdev->abs_x;
         abs_y = pEvdev->abs_y;
         if (pEvdev->invert_x)
-            abs_x = pEvdev->max_x - abs_x;
+            abs_x = pEvdev->max_x - (abs_x - pEvdev->min_x);
         if (pEvdev->invert_y)
-            abs_y = pEvdev->max_y - abs_y;
+            abs_y = pEvdev->max_y - (abs_y - pEvdev->min_y);
 
 	xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, abs_x, abs_y);
     }

commit 4e86393bc0873235c1381faee5559b1aeba63be5
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Fri Oct 24 09:21:36 2008 +1030

    emulate MB: fix confusing log message.
    
    If we're forcing MB emulation behaviour as per config, then at least state
    whether we're forcing it off or on.
    
    Found by Michel Dänzer.
    (cherry picked from commit 0f8fcfccb3251ee3df80d90ae5d7df638722d24e)

diff --git a/src/emuMB.c b/src/emuMB.c
index 8a3967c..4af0791 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -311,8 +311,8 @@ EvdevMBEmuPreInit(InputInfoPtr pInfo)
         pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
                                                       "Emulate3Buttons",
                                                       MBEMU_ENABLED);
-        xf86Msg(X_INFO, "%s: Forcing middle mouse button emulation.\n",
-                        pInfo->name);
+        xf86Msg(X_INFO, "%s: Forcing middle mouse button emulation %s.\n",
+                pInfo->name, (pEvdev->emulateMB.enabled) ? "on" : "off");
     }
 
     pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,

commit a64a78791f8350a01193ae216341fbb3d3d66567
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Thu Oct 23 17:16:36 2008 +1030

    evdev 2.1 RC 2

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

commit 09b2a5e87b9f05cb2cb7e794e49ba9650dd94eab
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Thu Oct 23 14:05:41 2008 +1030

    Silence compiler warning by memsetting the struct properly.
    (cherry picked from commit 0ab4c09e504ba3822c5e030732b770140165e725)

diff --git a/src/evdev.c b/src/evdev.c
index e119bb9..482f95e 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -672,9 +672,11 @@ EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
     };
 
     InputInfoPtr pInfo;
-    struct input_event ev[ArrayLength(bits)] = {0};
+    struct input_event ev[ArrayLength(bits)];
     int i;
 
+    memset(ev, 0, sizeof(ev));
+
     pInfo = device->public.devicePrivate;
     for (i = 0; i < ArrayLength(bits); i++) {
         ev[i].type = EV_LED;

commit fa18a4a38d3cdf9ab94dcc5586cade3016a97616
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Thu Oct 23 13:22:17 2008 +1030

    MB emulation timeout is stored as Time, make the property 32-bit too.
    (cherry picked from commit d348eb8ce78640363c159e1a4fdbfa9b596fa5bb)

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index b2b3f4b..89f25f1 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -31,7 +31,7 @@
 /* Middle mouse button emulation */
 /* BOOL */
 #define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation"
-/* CARD16 */
+/* CARD32 */
 #define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout"
 
 /* Wheel emulation */
diff --git a/src/emuMB.c b/src/emuMB.c
index ab6dae9..8a3967c 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -358,11 +358,11 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
             pEvdev->emulateMB.enabled = *((BOOL*)val->data);
     } else if (atom == prop_mbtimeout)
     {
-        if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
+        if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
             return BadMatch;
 
         if (!checkonly)
-            pEvdev->emulateMB.timeout = *((INT16*)val->data);
+            pEvdev->emulateMB.timeout = *((CARD32*)val->data);
     }
 
     return Success;
@@ -393,7 +393,7 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
     prop_mbtimeout = MakeAtom(EVDEV_PROP_MIDBUTTON_TIMEOUT,
                               strlen(EVDEV_PROP_MIDBUTTON_TIMEOUT),
                               TRUE);
-    rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 16, PropModeReplace, 1,
+    rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 32, PropModeReplace, 1,
                                 &pEvdev->emulateMB.timeout, FALSE);
 
     if (rc != Success)

commit 172523d74557f4c82209f9dd4869d7735944c9e7
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Wed Oct 22 18:01:58 2008 +1030

    Init ioctl bitmasks to 0, shuts up valgrind too.
    (cherry picked from commit 2c1698fa615a083de7dd647622a302d5de77dc0c)

diff --git a/src/evdev.c b/src/evdev.c
index ce79cf7..e119bb9 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -672,7 +672,7 @@ EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
     };
 
     InputInfoPtr pInfo;
-    struct input_event ev[ArrayLength(bits)];
+    struct input_event ev[ArrayLength(bits)] = {0};
     int i;
 
     pInfo = device->public.devicePrivate;
@@ -1179,9 +1179,9 @@ error:
 static int
 EvdevProbe(InputInfoPtr pInfo)
 {
-    long key_bitmask[NBITS(KEY_MAX)];
-    long rel_bitmask[NBITS(REL_MAX)];
-    long abs_bitmask[NBITS(ABS_MAX)];
+    long key_bitmask[NBITS(KEY_MAX)] = {0};
+    long rel_bitmask[NBITS(REL_MAX)] = {0};
+    long abs_bitmask[NBITS(ABS_MAX)] = {0};
     int i, has_axes, has_keys, num_buttons;
     int kernel24 = 0;
     EvdevPtr pEvdev = pInfo->private;

commit 8fb820ffafdc8962ed747f918c6ecc1c4f451b0e
Author: Søren Hauberg <hauberg@gmail.com>
Date:   Wed Oct 1 11:06:31 2008 +0930

    Add touchscreen support.
    
    Touchscreens are devices that do not have buttons and only advertise
    BTN_TOUCH. Add a new flag to note the device type.
    
    If BTN_TOUCH is detected, change it to BTN_LEFT and process it normally.
    (cherry picked from commit 8c39302594445ba774ea3fec66417492cc5643e0)

diff --git a/src/evdev.c b/src/evdev.c
index 9ad96f9..ce79cf7 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -75,6 +75,7 @@
 #define EVDEV_ABSOLUTE_EVENTS	(1 << 3)
 #define EVDEV_TOUCHPAD		(1 << 4)
 #define EVDEV_INITIALIZED	(1 << 5) /* WheelInit etc. called already? */
+#define EVDEV_TOUCHSCREEN	(1 << 6)
 
 #define MIN_KEYCODE 8
 #define GLYPHS_PER_KEY 2
@@ -317,7 +318,12 @@ EvdevReadInput(InputInfoPtr pInfo)
 	    case BTN_TOOL_MOUSE:
 	    case BTN_TOOL_LENS:
 		pEvdev->tool = value ? ev.code : 0;
-		break;
+		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! */
 
             default:
 		button = EvdevUtilButtonEventToButtonNumber(ev.code);
@@ -1215,23 +1221,6 @@ EvdevProbe(InputInfoPtr pInfo)
     has_keys = FALSE;
     num_buttons = 0;
 
-    if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
-        xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
-	pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
-	has_axes = TRUE;
-    }
-
-    if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
-        xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
-	pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
-	if (TestBit(BTN_TOUCH, key_bitmask)) {
-	    xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
-	    pEvdev->flags |= EVDEV_TOUCHPAD;
-	    pEvdev->old_x = pEvdev->old_y = -1;
-	}
-	has_axes = TRUE;
-    }
-
     /* count all buttons */
     for (i = BTN_MISC; i < BTN_JOYSTICK; i++)
     {
@@ -1247,6 +1236,29 @@ EvdevProbe(InputInfoPtr pInfo)
                 num_buttons);
     }
 
+    if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
+        xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
+	pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
+	has_axes = TRUE;
+    }
+
+    if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
+        xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
+	pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
+	if (TestBit(BTN_TOUCH, key_bitmask)) {
+            if (num_buttons) {
+                xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
+                pEvdev->flags |= EVDEV_TOUCHPAD;
+                pEvdev->old_x = pEvdev->old_y = -1;
+            } else {
+                xf86Msg(X_INFO, "%s: Found absolute touchscreen\n", pInfo->name);
+                pEvdev->flags |= EVDEV_TOUCHSCREEN;
+                pEvdev->flags |= EVDEV_BUTTON_EVENTS;
+            }
+	}
+	has_axes = TRUE;
+    }
+
     for (i = 0; i < BTN_MISC; i++)
         if (TestBit(i, key_bitmask))
             break;
@@ -1264,6 +1276,13 @@ EvdevProbe(InputInfoPtr pInfo)
 	pInfo->type_name = XI_MOUSE;
     }
 
+    if (pEvdev->flags & EVDEV_TOUCHSCREEN) {
+        xf86Msg(X_INFO, "%s: Configuring as touchscreen\n", pInfo->name);
+        pInfo->type_name = XI_TOUCHSCREEN;
+        pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
+                        XI86_CONFIGURED;
+    }
+
     if (has_keys) {
         if (kernel24) {
             xf86Msg(X_INFO, "%s: Kernel < 2.6 is too old, ignoring keyboard\n",

commit c7893b212d4d633c3229901bace6571d67ec1315
Author: Julien Cristau <jcristau@debian.org>
Date:   Tue Oct 21 19:21:21 2008 +0200

    Fix TestBit() on 64bit
    
    Reported by Albert Damen <albrt@gmx.net>
    X.Org Bug#18150 <http://bugs.freedesktop.org/show_bug.cgi?id=18150>
    (cherry picked from commit f57e8face94c9e6986b35ca2ec231e284b9f58cf)

diff --git a/src/evdev.c b/src/evdev.c
index 1a664ac..9ad96f9 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -390,7 +390,7 @@ EvdevReadInput(InputInfoPtr pInfo)
     }
 }
 
-#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1 << ((bit) % LONG_BITS))
+#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1L << ((bit) % LONG_BITS))
 
 static void
 EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)

commit e9dd721e2dd24e9bdc5092bcc0bbe94a2ac065ff
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Thu Oct 16 15:23:06 2008 +1030

    Add option "GrabDevice", don't grab the device by default.
    
    We now have the matching code in the server to set the console to RAW mode and
    don't need to grab the devices anymore.
    
    This is an updated version of e8534d47c8524ac081c2e3e6ebaabe4c6b274a18, which
    was reverted in 6dc41991557fa55a9e2f5aaf0fe40c70a08d41fd.
    (cherry picked from commit 4912e2aa7f867a86d383010023b8426c881fb3b0)

diff --git a/man/evdev.man b/man/evdev.man
index 899ca71..9d336fc 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -11,6 +11,7 @@ evdev \- Generic Linux input driver
 .BI "  Option \*qDevice\*q   \*q" devpath \*q
 .BI "  Option \*qEmulate3Buttons\*q     \*q" True \*q
 .BI "  Option \*qEmulate3Timeout\*q     \*q" 50 \*q
+.BI "  Option \*qGrabDevice\*q     \*q" False \*q
 \ \ ...
 .B EndSection
 .fi
@@ -145,6 +146,13 @@ waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
 .TP 7
 .BI "Option \*qInvertY\*q \*q" Bool \*q
 Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
+.TP 7
+.BI "Option \*qGrabDevice\*q \*q" boolean \*q
+Force a grab on the event device. Doing so will ensure that no other driver
+can initialise the same device and it will also stop the device from sending
+events to /dev/kbd or /dev/input/mice. Events from this device will not be
+sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).
+Default disabled.
 
 .SH SUPPORTED PROPERTIES
 The following properties are provided by the
diff --git a/src/evdev.c b/src/evdev.c
index 865b451..1a664ac 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -979,7 +979,7 @@ EvdevOn(DeviceIntPtr device)
     pInfo = device->public.devicePrivate;
     pEvdev = pInfo->private;
 
-    if (pInfo->fd != -1 && !pEvdev->kernel24 &&
+    if (pInfo->fd != -1 && pEvdev->grabDevice &&
         (rc = ioctl(pInfo->fd, EVIOCGRAB, (void *)1)))
     {
         xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
@@ -1028,7 +1028,7 @@ EvdevProc(DeviceIntPtr device, int what)
     case DEVICE_OFF:
         if (pInfo->fd != -1)
         {
-            if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
+            if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
                 xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
                         strerror(errno));
             xf86RemoveEnabledDevice(pInfo);
@@ -1177,17 +1177,19 @@ EvdevProbe(InputInfoPtr pInfo)
     long rel_bitmask[NBITS(REL_MAX)];
     long abs_bitmask[NBITS(ABS_MAX)];
     int i, has_axes, has_keys, num_buttons;
+    int kernel24 = 0;
     EvdevPtr pEvdev = pInfo->private;
 
-    if (ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
+    if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
         if (errno == EINVAL) {
             /* keyboards are unsafe in 2.4 */
-            pEvdev->kernel24 = 1;
+            kernel24 = 1;
+            pEvdev->grabDevice = 0;
         } else {
             xf86Msg(X_ERROR, "Grab failed. Device already configured?\n");
             return 1;
         }
-    } else {
+    } else if (pEvdev->grabDevice) {


Reply to: