OK, here's the new patch. Much smaller now. There's some spaces-vs-tabs inconsistency in emuWheel.c, and it took me a few tries to make sure that this patch wasn't touching those. Might make sense to do another patch to clean up the whitespace.
Dima On Mon, 7 Dec 2009 12:36:54 +1000 Peter Hutterer <[email protected]> wrote: > On Sun, Dec 06, 2009 at 06:23:28PM -0800, Dima Kogan wrote: > > Hi Peter. > > > > I specifically didn't do it that way because I didn't want to assume > > that REL_X == ABS_X and REL_Y == ABS_Y. I don't know how set in > > stone those definitions are. I'd like you to confirm that this > > assumption will hold for the foreseeable future, and if so, I will > > redo the patch. Let me know. Thanks. > > pretty much set in stone. if the kernel changes the definitions for > those, a lot of things will break. > of course, you could do #if trickery for the case but let's not worry > about it. > > Cheers, > Peter
>From 0dbf72dfdf7ff6acedb8315a79c52535c5cad754 Mon Sep 17 00:00:00 2001 From: Dima Kogan <[email protected]> Date: Sat, 5 Dec 2009 02:05:19 -0800 Subject: [PATCH] allow wheel emulation to work with absolute-position devices Signed-off-by: Dima Kogan <[email protected]> --- src/emuWheel.c | 20 +++++++++++++++----- src/evdev.c | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/emuWheel.c b/src/emuWheel.c index e7b2f98..b644d66 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 81a0bd5..1e0f9e2 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -524,6 +524,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; -- 1.6.5.2
_______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
