diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-08-26 14:56:07 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-04-29 09:43:14 +1000 |
commit | 1a031657b96c60606f5b66e465054888f61b29d6 (patch) | |
tree | 616e0790924f7be5726425cc6627b9c90b926b99 | |
parent | 51575b60b14d414490d31ff23f07c30431525667 (diff) |
Fix wheel emulation for absolute device (#68415)
wheel emulation, for some reasons beyond time, got the value from
pEvdev->vals, then set the value back into pEvdev->vals. Alas, that value is
always 0, hence oldValue is zero and the delta is nil.
If we're not in relative (touchpad) mode, store the current value in
old_vals, so they're retrievable for the next event.
X.Org Bug 68415 <http://bugs.freedesktop.org/show_bug.cgi?id=68415>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit f6fcad8b107e834e26fb3da2c89e05294ff0a74c)
-rw-r--r-- | src/emuWheel.c | 11 | ||||
-rw-r--r-- | src/evdev.c | 52 |
2 files changed, 37 insertions, 26 deletions
diff --git a/src/emuWheel.c b/src/emuWheel.c index 81b777f..857f029 100644 --- a/src/emuWheel.c +++ b/src/emuWheel.c @@ -97,7 +97,6 @@ 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,9 +117,13 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv) /* We don't want to intercept real mouse wheel events */ if(pEv->type == EV_ABS) { int axis = pEvdev->abs_axis_map[pEv->code]; - oldValue = valuator_mask_get(pEvdev->vals, axis); - valuator_mask_set(pEvdev->vals, axis, value); - value -= oldValue; /* make value into a differential measurement */ + int oldValue; + + if (axis > -1 && valuator_mask_fetch(pEvdev->old_vals, axis, &oldValue)) { + valuator_mask_set(pEvdev->vals, axis, value); + value -= oldValue; /* make value into a differential measurement */ + } else + value = 0; /* avoid a jump on the first touch */ } switch(pEv->code) { diff --git a/src/evdev.c b/src/evdev.c index af4aba3..16a0358 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -493,31 +493,39 @@ EvdevProcessValuators(InputInfoPtr pInfo) EvdevPtr pEvdev = pInfo->private; int *delta = pEvdev->delta; - /* convert to relative motion for touchpads */ - if (pEvdev->abs_queued && (pEvdev->flags & EVDEV_RELATIVE_MODE)) { - if (pEvdev->in_proximity) { - if (valuator_mask_isset(pEvdev->vals, 0)) - { - if (valuator_mask_isset(pEvdev->old_vals, 0)) - delta[REL_X] = valuator_mask_get(pEvdev->vals, 0) - - valuator_mask_get(pEvdev->old_vals, 0); - valuator_mask_set(pEvdev->old_vals, 0, - valuator_mask_get(pEvdev->vals, 0)); - } - if (valuator_mask_isset(pEvdev->vals, 1)) - { - if (valuator_mask_isset(pEvdev->old_vals, 1)) - delta[REL_Y] = valuator_mask_get(pEvdev->vals, 1) - - valuator_mask_get(pEvdev->old_vals, 1); - valuator_mask_set(pEvdev->old_vals, 1, - valuator_mask_get(pEvdev->vals, 1)); + if (pEvdev->abs_queued) { + /* convert to relative motion for touchpads */ + if (pEvdev->flags & EVDEV_RELATIVE_MODE) { + if (pEvdev->in_proximity) { + if (valuator_mask_isset(pEvdev->vals, 0)) + { + if (valuator_mask_isset(pEvdev->old_vals, 0)) + delta[REL_X] = valuator_mask_get(pEvdev->vals, 0) - + valuator_mask_get(pEvdev->old_vals, 0); + valuator_mask_set(pEvdev->old_vals, 0, + valuator_mask_get(pEvdev->vals, 0)); + } + if (valuator_mask_isset(pEvdev->vals, 1)) + { + if (valuator_mask_isset(pEvdev->old_vals, 1)) + delta[REL_Y] = valuator_mask_get(pEvdev->vals, 1) - + valuator_mask_get(pEvdev->old_vals, 1); + valuator_mask_set(pEvdev->old_vals, 1, + valuator_mask_get(pEvdev->vals, 1)); + } + } else { + valuator_mask_zero(pEvdev->old_vals); } + valuator_mask_zero(pEvdev->vals); + pEvdev->abs_queued = 0; + pEvdev->rel_queued = 1; } else { - valuator_mask_zero(pEvdev->old_vals); + int val; + if (valuator_mask_fetch(pEvdev->vals, 0, &val)) + valuator_mask_set(pEvdev->old_vals, 0, val); + if (valuator_mask_fetch(pEvdev->vals, 1, &val)) + valuator_mask_set(pEvdev->old_vals, 1, val); } - valuator_mask_zero(pEvdev->vals); - pEvdev->abs_queued = 0; - pEvdev->rel_queued = 1; } if (pEvdev->rel_queued) { |