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

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



Rebased ref, commits from common ancestor:
commit 61b4e88e01f32e976f85e7970a7f5b21fcd84f97
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Sep 21 16:56:28 2009 +1000

    emuWheel: fix signed/unsigned screwup
    
    This patch fixes wheel emulation on buttons other than 0.
    
    Reported-by: Andy Neitzke
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/emuWheel.c b/src/emuWheel.c
index 178b01b..e7b2f98 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -110,9 +110,11 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
      */
     if (pEvdev->emulateWheel.button_state || !pEvdev->emulateWheel.button) {
         /* Just return if the timeout hasn't expired yet */
-        if (pEvdev->emulateWheel.button &&
-            pEvdev->emulateWheel.expires - GetTimeInMillis() > 0) {
-            return TRUE;
+        if (pEvdev->emulateWheel.button)
+        {
+            int ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
+            if (ms > 0)
+                return TRUE;
         }
 
 	/* We don't want to intercept real mouse wheel events */

commit 9ee70943ec304b08b8e4651c512a8e65fa13cc9c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Sep 11 09:57:22 2009 +1000

    Require xorg-macros 1.3 and XORG_DEFAULT_OPTIONS
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index ee706a1..8eb2ada 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,16 +32,16 @@ AM_INIT_AUTOMAKE([dist-bzip2])
 
 AM_MAINTAINER_MODE
 
-# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
-m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.2)
+# Require xorg-macros: XORG_DEFAULT_OPTIONS
+m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.3)
 AM_CONFIG_HEADER([config.h])
 
 # Checks for programs.
 AC_DISABLE_STATIC
 AC_PROG_LIBTOOL
 AC_PROG_CC
-XORG_CWARNFLAGS
+XORG_DEFAULT_OPTIONS
 
 AH_TOP([#include "xorg-server.h"])
 
@@ -70,10 +70,6 @@ AC_HEADER_STDC
 DRIVER_NAME=evdev
 AC_SUBST([DRIVER_NAME])
 
-XORG_MANPAGE_SECTIONS
-XORG_RELEASE_VERSION
-XORG_CHANGELOG
-
 AC_OUTPUT([Makefile
            src/Makefile
            man/Makefile

commit 415b6ffa958e3103eeb52af4ccd881497169eed4
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Aug 20 11:02:31 2009 +1000

    Only take the driver-internal button mapping to count buttons (#23405)
    
    Regression:
        If a user has multiple buttons mapped to the same button number, the
        number of buttons counted is set to a wrong value.  e.g. a button
        mapping of 1 1 1 for a mouse with three buttons would only initialize 1
        button to the X server.
    
        In the future, the user cannot change this button mapping as the server
        only knows about one button.
    
    The user-supplied button map (option ButtonMapping) shouldn't matter when
    counting the buttons. Only the driver-internal mapping (BTN_0 -> button 1,
    etc.) matters.
    
    X.Org Bug 23405 <http://bugs.freedesktop.org/show_bug.cgi?id=23405>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 98f2f1b..5da8960 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1804,8 +1804,7 @@ EvdevProbe(InputInfoPtr pInfo)
         int mapping = 0;
         if (TestBit(i, pEvdev->key_bitmask))
         {
-            mapping =
-                pEvdev->btnmap[EvdevUtilButtonEventToButtonNumber(pEvdev, i)];
+            mapping = EvdevUtilButtonEventToButtonNumber(pEvdev, i);
             if (mapping > num_buttons)
                 num_buttons = mapping;
         }

commit f4ba2bd785b25fd522967abd7775925d5fded70f
Author: Dima Kogan <dkogan@secretsauce.net>
Date:   Sun Aug 16 23:11:50 2009 -0700

    Allow 0 as wheel emulation button for unconditional scrolling (#20529)
    
    If wheel emulation is on and the emulation button is 0, then any x/y motion
    of the device is converted into wheel events. The devices becomes a
    scrolling-only device.
    
    Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index 55c5a39..3e3c194 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -43,7 +43,7 @@
 #define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia"
 /* CARD16 */
 #define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout"
-/* CARD8, value range 0-32  */
+/* CARD8, value range 0-32, 0 to always scroll */
 #define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button"
 
 /* Drag lock */
diff --git a/man/evdev.man b/man/evdev.man
index 07f125a..c3c5551 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -105,7 +105,10 @@ press/release events as specified for the
 .B XAxisMapping
 and
 .B YAxisMapping
-settings.  Default: 4. Property: "Evdev Wheel Emulation Button".
+settings. If the button is 0 and
+.BR EmulateWheel
+is on, any motion of the device is converted into wheel events. Default: 4.
+Property: "Evdev Wheel Emulation Button".
 .TP 7
 .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q
 Specifies how far (in pixels) the pointer must move to generate button
diff --git a/src/emuWheel.c b/src/emuWheel.c
index cc23f1d..178b01b 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -100,18 +100,20 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
     EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
     WheelAxisPtr pAxis = NULL, pOtherAxis = NULL;
     int value = pEv->value;
-    int ms;
 
     /* Has wheel emulation been configured to be enabled? */
     if (!pEvdev->emulateWheel.enabled)
 	return FALSE;
 
-    /* Handle our motion events if the emuWheel button is pressed*/
-    if (pEvdev->emulateWheel.button_state) {
+    /* Handle our motion events if the emuWheel button is pressed
+     * wheel button of 0 means always emulate wheel.
+     */
+    if (pEvdev->emulateWheel.button_state || !pEvdev->emulateWheel.button) {
         /* Just return if the timeout hasn't expired yet */
-        ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
-        if (ms > 0)
+        if (pEvdev->emulateWheel.button &&
+            pEvdev->emulateWheel.expires - GetTimeInMillis() > 0) {
             return TRUE;
+        }
 
 	/* We don't want to intercept real mouse wheel events */
 	switch(pEv->code) {

commit 2e5f68754fd5bc4e6b7fa5b95bdd30e2bb4e57fb
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Aug 17 09:41:11 2009 +1000

    Restrict wheel emulation to a single axis at a time.
    
    Wheel emulation works for both horizontal and vertical axes. Thus, if a
    device doesn't move in perfect straight line, scroll events build up on the
    respective other axis.
    
    In some clients, scroll wheel events have specific meanings other than
    scrolling (e.g. mplayer). In these clients, erroneous scrolling events come
    at a high cost.
    
    Thus, if a scroll wheel event is generated for one axis, reset the inertia
    of the other axis to 0, avoiding the buildup of these erroneous scrolling
    events.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/emuWheel.c b/src/emuWheel.c
index 421477e..cc23f1d 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -54,7 +54,7 @@ static Atom prop_wheel_button   = 0;
 
 /* Local Funciton Prototypes */
 static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
-static void EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
+static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
 
 /* Filter mouse button events */
 BOOL
@@ -98,7 +98,7 @@ BOOL
 EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
 {
     EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
-    WheelAxisPtr pAxis = NULL;
+    WheelAxisPtr pAxis = NULL, pOtherAxis = NULL;
     int value = pEv->value;
     int ms;
 
@@ -117,19 +117,28 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
 	switch(pEv->code) {
 	case REL_X:
 	    pAxis = &(pEvdev->emulateWheel.X);
+	    pOtherAxis = &(pEvdev->emulateWheel.Y);
 	    break;
 
 	case REL_Y:
 	    pAxis = &(pEvdev->emulateWheel.Y);
+	    pOtherAxis = &(pEvdev->emulateWheel.X);
 	    break;
 
 	default:
 	    break;
 	}
 
-	/* If we found REL_X or REL_Y, emulate a mouse wheel */
+	/* If we found REL_X or REL_Y, emulate a mouse wheel.
+           Reset the inertia of the other axis when a scroll event was sent
+           to avoid the buildup of erroneous scroll events if the user
+           doesn't move in a perfectly straight line.
+         */
 	if (pAxis)
-	    EvdevWheelEmuInertia(pInfo, pAxis, value);
+	{
+	    if (EvdevWheelEmuInertia(pInfo, pAxis, value))
+		pOtherAxis->traveled_distance = 0;
+	}
 
 	/* Eat motion events while emulateWheel button pressed. */
 	return TRUE;
@@ -138,17 +147,20 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
     return FALSE;
 }
 
-/* Simulate inertia for our emulated mouse wheel */
-static void
+/* Simulate inertia for our emulated mouse wheel.
+   Returns the number of wheel events generated.
+ */
+static int
 EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
 {
     EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
     int button;
     int inertia;
+    int rc = 0;
 
     /* if this axis has not been configured, just eat the motion */
     if (!axis->up_button)
-	return;
+	return rc;
 
     axis->traveled_distance += value;
 
@@ -164,7 +176,9 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
     while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) {
 	axis->traveled_distance -= inertia;
 	EvdevQueueButtonClicks(pInfo, button, 1);
+	rc++;
     }
+    return rc;
 }
 
 /* Handle button mapping here to avoid code duplication,

commit 8fdb2abb6fe0426cbbfeead2c187092a56792557
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Aug 14 12:59:27 2009 +1000

    man: fix documentation for EVDEV_PROP_WHEEL_BUTTON
    
    0 doesn't disable it, it's still treated like a button number. copy/paste
    error.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/include/evdev-properties.h b/include/evdev-properties.h
index 31f6c66..55c5a39 100644
--- a/include/evdev-properties.h
+++ b/include/evdev-properties.h
@@ -43,7 +43,7 @@
 #define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia"
 /* CARD16 */
 #define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout"
-/* CARD8, value range 0-32, 0 to disable a value */
+/* CARD8, value range 0-32  */
 #define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button"
 
 /* Drag lock */

commit ca0fb396f1a4b87be9f8aa7ad066e0b469c9075d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Aug 14 11:00:12 2009 +1000

    evdev 2.2.99.1

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

commit 7967677789e3ee24733b3514e1ae7a8e12bbc2b5
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Aug 14 09:05:40 2009 +1000

    Treat tablets (BTN_TOOL_PEN devices) differently from touchpads.
    
    The previous checks for BTN_TOOL_FINGER and BTN_TOUCH reported false
    positives for touchpads for most popular tablets.
    As a result, their events were converted to relative events.
    
    Add a new flag EVDEV_TABLET pending presence of BTN_TOOL_PEN and ignore the
    touchpad special casing to report the events as-is.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 9c3a990..98f2f1b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -89,6 +89,7 @@
 #define EVDEV_INITIALIZED	(1 << 5) /* WheelInit etc. called already? */
 #define EVDEV_TOUCHSCREEN	(1 << 6)
 #define EVDEV_CALIBRATED	(1 << 7) /* run-time calibrated? */
+#define EVDEV_TABLET		(1 << 8) /* run-time calibrated? */
 
 #define MIN_KEYCODE 8
 #define GLYPHS_PER_KEY 2
@@ -1469,8 +1470,8 @@ EvdevInitTouchDevice(DeviceIntPtr device, EvdevPtr pEvdev)
 {
     if (pEvdev->flags & EVDEV_RELATIVE_EVENTS) {
 
-        xf86Msg(X_WARNING,"%s: touchpads and touchscreens ignore relative "
-                "axes.\n", device->name);
+        xf86Msg(X_WARNING,"%s: touchpads, tablets and touchscreens ignore "
+                "relative axes.\n", device->name);
 
         pEvdev->flags &= ~EVDEV_RELATIVE_EVENTS;
     }
@@ -1511,7 +1512,7 @@ EvdevInit(DeviceIntPtr device)
      * used and relative axes are ignored.
      */
 
-    if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN))
+    if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN | EVDEV_TABLET))
         EvdevInitTouchDevice(device, pEvdev);
     else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
         EvdevInitRelClass(device, pEvdev);
@@ -1861,10 +1862,14 @@ EvdevProbe(InputInfoPtr pInfo)
         if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
              TestBit(ABS_Y, pEvdev->abs_bitmask))) {
             xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
-            if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) ||
+            if (TestBit(BTN_TOOL_PEN, pEvdev->key_bitmask))
+            {
+                xf86Msg(X_INFO, "%s: Found absolute tablet.\n", pInfo->name);
+                pEvdev->flags |= EVDEV_TABLET;
+            } else 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 or tablet.\n", pInfo->name);
+                    xf86Msg(X_INFO, "%s: Found absolute touchpad.\n", pInfo->name);
                     pEvdev->flags |= EVDEV_TOUCHPAD;
                     memset(pEvdev->old_vals, -1, sizeof(int) * pEvdev->num_vals);
                 } else {
@@ -1892,7 +1897,7 @@ EvdevProbe(InputInfoPtr pInfo)
 	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)) {
+	} else if (pEvdev->flags & EVDEV_TABLET) {
 	    xf86Msg(X_INFO, "%s: Configuring as tablet\n", pInfo->name);
 	    pInfo->type_name = XI_TABLET;
         } else if (pEvdev->flags & EVDEV_TOUCHSCREEN) {

commit 36064dca9097df896b4b1b49c9c68775f1728846
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Aug 13 10:27:16 2009 +1000

    Add EvdevPostButtonEvent API to immediately post a button event (#23269)
    
    The wheel emulation code needs this API. When the timer expires, the event
    must be posted immediately, not enqueued onto the internal event queue.
    Otherwise, the emulated middle button press is enqueued only and no event is
    sent until the next physical event (and its EV_SYN) arrives.
    
    Since the timer is triggered outside of the SIGIO and SIGIO is blocked
    during this period anyway, we could also just enqueue the event and flush by
    simulating an EV_SYN. It's easier this way though.
    
    X.Org Bug 23269 <http://bugs.freedesktop.org/show_bug.cgi?id=23269>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Oliver McFadden <oliver.mcfadden@nokia.com>

diff --git a/src/emuMB.c b/src/emuMB.c
index ac763cd..199c0d7 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -198,7 +198,7 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
 
     pEvdev->emulateMB.pending = FALSE;
     if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
-        EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
+        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
         pEvdev->emulateMB.state =
             stateTab[pEvdev->emulateMB.state][4][2];
     } else {
diff --git a/src/evdev.c b/src/evdev.c
index b653311..9c3a990 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -316,6 +316,16 @@ EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value)
     pEvdev->num_queue++;
 }
 
+/**
+ * Post button event right here, right now.
+ * Interface for MB emulation since these need to post immediately.
+ */
+void
+EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value)
+{
+    xf86PostButtonEvent(pInfo->dev, 0, button, value, 0, 0);
+}
+
 void
 EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count)
 {
diff --git a/src/evdev.h b/src/evdev.h
index a4a1064..38adeaf 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -183,6 +183,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 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,
 				   int v[MAX_VALUATORS]);

commit 8bf93709cbcf9f041cd177e929ff46adce8a6b79
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Aug 13 10:16:18 2009 +1000

    Rename parts of the Post API to a Queue API.
    
    Button and key events aren't posted from EvdevPost*Event, they are simply
    enqueued onto the evdev-internal event queue until the next EV_SYN arrives.
    Rename those interfaces from EvdevPost* to EvdevQueue* and leave only those
    that actually post to the server with a matching "*Post*" name.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Acked-by: Oliver McFadden <oliver.mcfadden@nokia.com>

diff --git a/src/draglock.c b/src/draglock.c
index d89e979..a8bf079 100644
--- a/src/draglock.c
+++ b/src/draglock.c
@@ -158,7 +158,7 @@ EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button)
     state = pEvdev->dragLock.lock_state[button - 1] ? FALSE : TRUE;
     pEvdev->dragLock.lock_state[button - 1] = state;
 
-    EvdevPostButtonEvent(pInfo, button, state);
+    EvdevQueueButtonEvent(pInfo, button, state);
 }
 
 /* Filter button presses looking for either a meta button or the
diff --git a/src/emuMB.c b/src/emuMB.c
index dc689b6..ac763cd 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -198,7 +198,7 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
 
     pEvdev->emulateMB.pending = FALSE;
     if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
-        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
+        EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
         pEvdev->emulateMB.state =
             stateTab[pEvdev->emulateMB.state][4][2];
     } else {
@@ -248,12 +248,12 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
 
     if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0)
     {
-        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
+        EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
         ret = TRUE;
     }
     if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
     {
-        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
+        EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
         ret = TRUE;
     }
 
diff --git a/src/emuWheel.c b/src/emuWheel.c
index b9337de..421477e 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -82,7 +82,7 @@ EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value)
                  * If the button is released early enough emit the button
                  * press/release events
                  */
-                EvdevPostButtonClicks(pInfo, button, 1);
+                EvdevQueueButtonClicks(pInfo, button, 1);
             }
         }
 
@@ -163,7 +163,7 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
     /* Produce button press events for wheel motion */
     while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) {
 	axis->traveled_distance -= inertia;
-	EvdevPostButtonClicks(pInfo, button, 1);
+	EvdevQueueButtonClicks(pInfo, button, 1);
     }
 }
 
diff --git a/src/evdev.c b/src/evdev.c
index e1e1eae..b653311 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -250,7 +250,7 @@ static int wheel_left_button = 6;
 static int wheel_right_button = 7;
 
 void
-EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
+EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
 {
     int code = ev->code + MIN_KEYCODE;
     static char warned[KEY_CNT];
@@ -298,7 +298,7 @@ EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
 }
 
 void
-EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value)
+EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value)
 {
     EventQueuePtr pQueue;
     EvdevPtr pEvdev = pInfo->private;
@@ -317,13 +317,13 @@ EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value)
 }
 
 void
-EvdevPostButtonClicks(InputInfoPtr pInfo, int button, int count)
+EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count)
 {
     int i;
 
     for (i = 0; i < count; i++) {
-        EvdevPostButtonEvent(pInfo, button, 1);
-        EvdevPostButtonEvent(pInfo, button, 0);
+        EvdevQueueButtonEvent(pInfo, button, 1);
+        EvdevQueueButtonEvent(pInfo, button, 0);
     }
 }
 
@@ -507,9 +507,9 @@ EvdevProcessButtonEvent(InputInfoPtr pInfo, struct input_event *ev)
         return;
 
     if (button)
-        EvdevPostButtonEvent(pInfo, button, value);
+        EvdevQueueButtonEvent(pInfo, button, value);
     else
-        EvdevPostKbdEvent(pInfo, ev, value);
+        EvdevQueueKbdEvent(pInfo, ev, value);
 }
 
 /**
@@ -529,17 +529,17 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
     switch (ev->code) {
         case REL_WHEEL:
             if (value > 0)
-                EvdevPostButtonClicks(pInfo, wheel_up_button, value);
+                EvdevQueueButtonClicks(pInfo, wheel_up_button, value);
             else if (value < 0)
-                EvdevPostButtonClicks(pInfo, wheel_down_button, -value);
+                EvdevQueueButtonClicks(pInfo, wheel_down_button, -value);
             break;
 
         case REL_DIAL:
         case REL_HWHEEL:
             if (value > 0)
-                EvdevPostButtonClicks(pInfo, wheel_right_button, value);
+                EvdevQueueButtonClicks(pInfo, wheel_right_button, value);
             else if (value < 0)
-                EvdevPostButtonClicks(pInfo, wheel_left_button, -value);
+                EvdevQueueButtonClicks(pInfo, wheel_left_button, -value);
             break;
 
         /* We don't post wheel events as axis motion. */
diff --git a/src/evdev.h b/src/evdev.h
index 142801c..a4a1064 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -181,9 +181,9 @@ typedef struct {
 } EvdevRec, *EvdevPtr;
 
 /* Event posting functions */
-void EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
-void EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value);
-void EvdevPostButtonClicks(InputInfoPtr pInfo, int button, int count);
+void EvdevQueueKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value);
+void EvdevQueueButtonEvent(InputInfoPtr pInfo, int button, int value);
+void EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count);
 void EvdevPostRelativeMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v,
 				   int v[MAX_VALUATORS]);
 void EvdevPostAbsoluteMotionEvents(InputInfoPtr pInfo, int *num_v, int *first_v,

commit 37373a223b2aeef7041c9c0bb99be613789a3125
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Aug 13 10:26:33 2009 +1000

    comment typo fix
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/draglock.c b/src/draglock.c
index 203f25c..d89e979 100644
--- a/src/draglock.c
+++ b/src/draglock.c
@@ -147,7 +147,7 @@ EvdevDragLockPreInit(InputInfoPtr pInfo)
     }
 }
 
-/* Updates DragLock button state and firest button event messges */
+/* Updates DragLock button state and fires button event messges */
 void
 EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button)
 {

commit d764dded18c47cec009babc075f2324cba1781ce
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Aug 5 18:57:30 2009 +1000

    Skip check for EVDEV_RELATIVE_EVENTS for wheel events.
    
    This patch fixes a regression introduced with 1f641d75e.
    Wheel axis events are posted as button clicks, a device may have no relative
    axes but it does need to post these button clicks.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index bdf7f0a..e1e1eae 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -524,14 +524,6 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
     /* Get the signed value, earlier kernels had this as unsigned */
     value = ev->value;
 
-    /* Ignore EV_REL events if we never set up for them. */
-    if (!(pEvdev->flags & EVDEV_RELATIVE_EVENTS))
-        return;
-
-    /* Handle mouse wheel emulation */
-    if (EvdevWheelEmuFilterMotion(pInfo, ev))
-        return;
-
     pEvdev->rel = 1;
 
     switch (ev->code) {
@@ -552,6 +544,14 @@ EvdevProcessRelativeMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
 
         /* We don't post wheel events as axis motion. */
         default:
+            /* Ignore EV_REL events if we never set up for them. */
+            if (!(pEvdev->flags & EVDEV_RELATIVE_EVENTS))
+                return;
+
+            /* Handle mouse wheel emulation */
+            if (EvdevWheelEmuFilterMotion(pInfo, ev))
+                return;
+
             pEvdev->delta[ev->code] += value;
             break;
     }

commit f352598e45be86f9e24d9dba88c657f03f3b168e
Author: Michael Witten <mfwitten@gmail.com>
Date:   Tue Aug 4 03:11:49 2009 -0500

    evdev.c: Fix/improve discrimination of rel/abs axes
    
    The relevant comment from evdev.c:
    
    We don't allow relative and absolute axes on the same device. The
    reason is that some devices (MS Optical Desktop 2000) register both
    rel and abs axes for x/y.
    
    The abs axes register min/max; this min/max then also applies to the
    relative device (the mouse) and caps it at 0..255 for both axes.
    So, unless you have a small screen, you won't be enjoying it much;
    consequently, absolute axes are generally ignored.
    
    However, currenly only a device with absolute axes can be registered
    as a touch{pad,screen}. Thus, given such a device, absolute axes are
    used and relative axes are ignored.
    
    The code for initializing abs/rel axes has been abstracted out into
    3 functions, so that initialization in EvdevInit(device) is as easy
    as:
    
        if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN))
            EvdevInitTouchDevice(device, pEvdev);
        else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
            EvdevInitRelClass(device, pEvdev);
        else if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
            EvdevInitAbsClass(device, pEvdev);
    
    Signed-off-by: Michael Witten <mfwitten@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/evdev.c b/src/evdev.c
index 9528dbf..bdf7f0a 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1410,6 +1410,64 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
 
 }
 
+static void
+EvdevInitAbsClass(DeviceIntPtr device, EvdevPtr pEvdev)
+{
+    if (EvdevAddAbsClass(device) == Success) {
+
+        xf86Msg(X_INFO,"%s: initialized for absolute axes.\n", device->name);
+
+    } else {
+
+        xf86Msg(X_ERROR,"%s: failed to initialize for absolute axes.\n",
+                device->name);
+
+        pEvdev->flags &= ~EVDEV_ABSOLUTE_EVENTS;
+
+    }
+}
+
+static void
+EvdevInitRelClass(DeviceIntPtr device, EvdevPtr pEvdev)
+{
+    int has_abs_axes = pEvdev->flags & EVDEV_ABSOLUTE_EVENTS;
+
+    if (EvdevAddRelClass(device) == Success) {
+
+        xf86Msg(X_INFO,"%s: initialized for relative axes.\n", device->name);
+
+        if (has_abs_axes) {
+
+            xf86Msg(X_WARNING,"%s: ignoring absolute axes.\n", device->name);
+            pEvdev->flags &= ~EVDEV_ABSOLUTE_EVENTS;
+        }
+
+    } else {
+
+        xf86Msg(X_ERROR,"%s: failed to initialize for relative axes.\n",
+                device->name);
+
+        pEvdev->flags &= ~EVDEV_RELATIVE_EVENTS;
+
+        if (has_abs_axes)
+            EvdevInitAbsClass(device, pEvdev);
+    }
+}
+
+static void
+EvdevInitTouchDevice(DeviceIntPtr device, EvdevPtr pEvdev)
+{
+    if (pEvdev->flags & EVDEV_RELATIVE_EVENTS) {
+
+        xf86Msg(X_WARNING,"%s: touchpads and touchscreens ignore relative "
+                "axes.\n", device->name);
+
+        pEvdev->flags &= ~EVDEV_RELATIVE_EVENTS;
+    }
+
+    EvdevInitAbsClass(device, pEvdev);
+}
+
 static int
 EvdevInit(DeviceIntPtr device)
 {
@@ -1428,28 +1486,27 @@ EvdevInit(DeviceIntPtr device)
 	EvdevAddKeyClass(device);
     if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
 	EvdevAddButtonClass(device);
-    /* We don't allow relative and absolute axes on the same device. Reason
-       Reason being that some devices (MS Optical Desktop 2000) register both
-       rel and abs axes for x/y.
-       The abs axes register min/max, this min/max then also applies to the
-       relative device (the mouse) and caps it at 0..255 for both axis.
-       So unless you have a small screen, you won't be enjoying it much.
-
-        FIXME: somebody volunteer to fix this.
+
+    /* We don't allow relative and absolute axes on the same device. The
+     * reason is that some devices (MS Optical Desktop 2000) register both
+     * rel and abs axes for x/y.
+     *
+     * The abs axes register min/max; this min/max then also applies to the
+     * relative device (the mouse) and caps it at 0..255 for both axes.
+     * So, unless you have a small screen, you won't be enjoying it much;
+     * consequently, absolute axes are generally ignored.
+     *
+     * However, currenly only a device with absolute axes can be registered
+     * as a touch{pad,screen}. Thus, given such a device, absolute axes are
+     * used and relative axes are ignored.
      */
-    if (pEvdev->flags & EVDEV_RELATIVE_EVENTS) {
-        if (EvdevAddRelClass(device) == Success)
-        {
-            if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
-                xf86Msg(X_INFO,"%s: relative axes found, ignoring absolute "
-                        "axes.\n", device->name);
-            pEvdev->flags &= ~EVDEV_ABSOLUTE_EVENTS;
-        } else
-            pEvdev->flags &= ~EVDEV_RELATIVE_EVENTS;
-    }
 
-    if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
-        EvdevAddAbsClass(device);
+    if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN))
+        EvdevInitTouchDevice(device, pEvdev);
+    else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
+        EvdevInitRelClass(device, pEvdev);
+    else if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
+        EvdevInitAbsClass(device, pEvdev);
 
 #ifdef HAVE_PROPERTIES
     /* We drop the return value, the only time we ever want the handlers to

commit 69d6ff3e01263ce2d52ed18b08f054bf3fdb923c
Author: Oliver McFadden <oliver.mcfadden@nokia.com>
Date:   Sun Aug 2 12:03:04 2009 +0300

    evdev: Use the EvdevPost...Event() functions in the emulation code.
    
    This is similar to commit 1f641d75edba7394201c1c53938215bae696791b.
    
    It provides the same functionality of queuing the (in this case
    emulated) events and waiting until an EV_SYN synchronization event is
    received before posting them to the server.
    
    This preserves the order of events (both real and emulated) and ensures
    that MotionNotify events will always be posted first. It also unifies
    the event posting into a few small functions which improves
    maintainability.
    
    From this point on, you should never use the xf86Post...Event()
    functions in new code, but rather the EvdevPost...Event() versions.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/src/draglock.c b/src/draglock.c
index 414166f..203f25c 100644
--- a/src/draglock.c
+++ b/src/draglock.c
@@ -152,13 +152,13 @@ void
 EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button)
 {
     EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
-    BOOL state=0;
+    BOOL state = 0;
 
     /* update button state */
     state = pEvdev->dragLock.lock_state[button - 1] ? FALSE : TRUE;
     pEvdev->dragLock.lock_state[button - 1] = state;
 
-    xf86PostButtonEvent(pInfo->dev, 0, button, state, 0, 0);
+    EvdevPostButtonEvent(pInfo, button, state);
 }
 
 /* Filter button presses looking for either a meta button or the
diff --git a/src/emuMB.c b/src/emuMB.c
index b29f552..dc689b6 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -198,7 +198,7 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
 
     pEvdev->emulateMB.pending = FALSE;
     if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
-        xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
+        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
         pEvdev->emulateMB.state =
             stateTab[pEvdev->emulateMB.state][4][2];
     } else {
@@ -248,12 +248,12 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
 
     if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0)
     {
-        xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
+        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
         ret = TRUE;
     }
     if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
     {
-        xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
+        EvdevPostButtonEvent(pInfo, abs(id), (id >= 0));
         ret = TRUE;
     }
 
diff --git a/src/emuWheel.c b/src/emuWheel.c
index a1c754d..b9337de 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -82,8 +82,7 @@ EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value)
                  * If the button is released early enough emit the button
                  * press/release events
                  */
-                xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0);
-                xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0);
+                EvdevPostButtonClicks(pInfo, button, 1);
             }
         }
 
@@ -163,10 +162,8 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
 
     /* Produce button press events for wheel motion */
     while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) {
-
 	axis->traveled_distance -= inertia;
-	xf86PostButtonEvent(pInfo->dev, 0, button, 1, 0, 0);
-	xf86PostButtonEvent(pInfo->dev, 0, button, 0, 0, 0);
+	EvdevPostButtonClicks(pInfo, button, 1);
     }
 }
 
diff --git a/src/evdev.c b/src/evdev.c
index e4e6d72..9528dbf 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -24,6 +24,7 @@
  *	Kristian Høgsberg (krh@redhat.com)
  *	Adam Jackson (ajax@redhat.com)
  *	Peter Hutterer (peter.hutterer@redhat.com)
+ *	Oliver McFadden (oliver.mcfadden@nokia.com)
  */
 
 #ifdef HAVE_CONFIG_H
@@ -248,8 +249,8 @@ static int wheel_down_button = 5;
 static int wheel_left_button = 6;
 static int wheel_right_button = 7;
 
-static void
-PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
+void
+EvdevPostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
 {
     int code = ev->code + MIN_KEYCODE;
     static char warned[KEY_CNT];
@@ -296,8 +297,8 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
     pEvdev->num_queue++;
 }
 
-static void
-PostButtonEvent(InputInfoPtr pInfo, int button, int value)
+void
+EvdevPostButtonEvent(InputInfoPtr pInfo, int button, int value)
 {


Reply to: