summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDima Kogan <dkogan@cds.caltech.edu>2009-12-05 02:05:19 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2009-12-08 11:02:05 +1000
commitd6beb16be26df65cd65eaeb146fde0d355521535 (patch)
tree7484a5879e841f7261c84cc36361ec403a7a01c9
parent2f5a0fb6988809a91c4e6821aaed46ba27c9855c (diff)
allow wheel emulation to work with absolute-position devices
Signed-off-by: Dima Kogan <dkogan@cds.caltech.edu> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/emuWheel.c20
-rw-r--r--src/evdev.c3
2 files changed, 18 insertions, 5 deletions
diff --git a/src/emuWheel.c b/src/emuWheel.c
index e7b2f98..3f0dfd4 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -100,6 +100,7 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
WheelAxisPtr pAxis = NULL, pOtherAxis = NULL;
int value = pEv->value;
+ int oldValue;
/* Has wheel emulation been configured to be enabled? */
if (!pEvdev->emulateWheel.enabled)
@@ -118,12 +119,21 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
}
/* We don't want to intercept real mouse wheel events */
+ if(pEv->type == EV_ABS) {
+ oldValue = pEvdev->vals[pEvdev->axis_map[pEv->code]];
+ pEvdev->vals[pEvdev->axis_map[pEv->code]] = value;
+ value -= oldValue; /* make value into a differential measurement */
+ }
+
switch(pEv->code) {
+
+ /* ABS_X has the same value as REL_X, so this case catches both */
case REL_X:
pAxis = &(pEvdev->emulateWheel.X);
pOtherAxis = &(pEvdev->emulateWheel.Y);
break;
+ /* ABS_Y has the same value as REL_Y, so this case catches both */
case REL_Y:
pAxis = &(pEvdev->emulateWheel.Y);
pOtherAxis = &(pEvdev->emulateWheel.X);
@@ -133,11 +143,11 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
break;
}
- /* 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 we found REL_X, REL_Y, ABS_X or ABS_Y then 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)
{
if (EvdevWheelEmuInertia(pInfo, pAxis, value))
diff --git a/src/evdev.c b/src/evdev.c
index 9345d96..7e65c69 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -525,6 +525,9 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
if (ev->code > ABS_MAX)
return;
+ if (EvdevWheelEmuFilterMotion(pInfo, ev))
+ return;
+
pEvdev->vals[pEvdev->axis_map[ev->code]] = value;
if (ev->code == ABS_X)
pEvdev->abs |= ABS_X_VALUE;