summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉric Brunet <Eric.Brunet@lps.ens.fr>2014-09-30 23:04:55 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2014-12-17 14:42:11 +1000
commit511498478b49aa39629615c110c9d0129fa6bbef (patch)
treea5ed26a0d1c30873f75daa2ca68a8c87d1d7fc56
parent3dcf6f123c54fd3104bcb79677cd347972abea4c (diff)
Move EVDEV_RELATIVE_MODE logic earlier
When in EVDEV_RELATIVE_MODE, after converting the absolute valuators, the code unsets pEvdev->abs_queued. This is wrong if there are some absolute valuators which are not positions, such as a pressure valuators, because events on these valuators would be lost. This patch fixes the problem by doing the absolute->relative translation early. This way, abs_queued is not set and then unset when receiving absolute valuators representing positions. Other absolute events now set abs_queued and will be processed. Signed-off-by: Éric Brunet <Eric.Brunet@lps.ens.fr> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev.c49
1 files changed, 16 insertions, 33 deletions
diff --git a/src/evdev.c b/src/evdev.c
index f488f96..7fbf5a0 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -447,39 +447,10 @@ EvdevProcessValuators(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
- int deltaX = 0, deltaY = 0;
-
- if (pEvdev->abs_queued) {
- /* convert to relative motion for touchpads */
- if (pEvdev->flags & EVDEV_RELATIVE_MODE) {
- if (valuator_mask_isset(pEvdev->abs_vals, 0))
- {
- if (valuator_mask_isset(pEvdev->old_vals, 0))
- deltaX = valuator_mask_get(pEvdev->abs_vals, 0) -
- valuator_mask_get(pEvdev->old_vals, 0);
- valuator_mask_set(pEvdev->old_vals, 0,
- valuator_mask_get(pEvdev->abs_vals, 0));
- }
- if (valuator_mask_isset(pEvdev->abs_vals, 1))
- {
- if (valuator_mask_isset(pEvdev->old_vals, 1))
- deltaY = valuator_mask_get(pEvdev->abs_vals, 1) -
- valuator_mask_get(pEvdev->old_vals, 1);
- valuator_mask_set(pEvdev->old_vals, 1,
- valuator_mask_get(pEvdev->abs_vals, 1));
- }
- valuator_mask_zero(pEvdev->abs_vals);
- pEvdev->abs_queued = 0;
- pEvdev->rel_queued = 1;
- }
- }
-
/* Apply transformations on relative coordinates */
if (pEvdev->rel_queued) {
- /* deltaX and deltaY may be non-zero if they got computed
- * because EVDEV_RELATIVE_MODE, but then we don't expect
- * pEvdev->rel_vals also to be set...
- */
+ int deltaX = 0, deltaY = 0;
+
if (valuator_mask_isset(pEvdev->rel_vals, REL_X))
deltaX = valuator_mask_get(pEvdev->rel_vals, REL_X);
if (valuator_mask_isset(pEvdev->rel_vals, REL_Y))
@@ -824,8 +795,20 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
pEvdev->abs_queued = 1;
} else if (!pEvdev->mt_mask) {
map = pEvdev->abs_axis_map[ev->code];
- valuator_mask_set(pEvdev->abs_vals, map, value);
- pEvdev->abs_queued = 1;
+
+ /* check if the event must be translated into relative */
+ if (map < 2 && (pEvdev->flags & EVDEV_RELATIVE_MODE)) {
+ int oldval;
+ if (valuator_mask_fetch(pEvdev->old_vals, map, &oldval)) {
+ valuator_mask_set(pEvdev->rel_vals, map, value - oldval);
+ pEvdev->rel_queued = 1;
+ }
+ valuator_mask_set(pEvdev->old_vals, map, value);
+ } else {
+ /* the normal case: just store the number. */
+ valuator_mask_set(pEvdev->abs_vals, map, value);
+ pEvdev->abs_queued = 1;
+ }
}
}