From 3f7efc134e689811dd3dc062ecfb0084fc36ef33 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 5 Mar 2015 16:48:47 +1000 Subject: [PATCH] touchpad: return normalized deltas from tp_get_delta All callers except the tap motion threshold call tp_get_delta() followed by tp_filter_motion() - the latter normalized it before calling into the accleration code. Move the normalization into tp_get_delta() so we don't deal with device-specific coordinates but normalized deltas instead. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad.c | 5 +++-- src/evdev-mt-touchpad.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index b90d84c5..9b065221 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -64,8 +64,8 @@ tp_filter_motion(struct tp_dispatch *tp, { struct motion_params motion; - motion.dx = *dx * tp->accel.x_scale_coeff; - motion.dy = *dy * tp->accel.y_scale_coeff; + motion.dx = *dx; + motion.dy = *dy; if (dx_unaccel) *dx_unaccel = motion.dx; @@ -269,6 +269,7 @@ tp_get_delta(struct tp_touch *t, double *dx, double *dy) tp_motion_history_offset(t, 1)->y, tp_motion_history_offset(t, 2)->y, tp_motion_history_offset(t, 3)->y); + tp_normalize_delta(t->tp, dx, dy); } static void diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index f04cc112..1b8b560f 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -283,6 +283,13 @@ struct tp_dispatch { #define tp_for_each_touch(_tp, _t) \ for (unsigned int _i = 0; _i < (_tp)->ntouches && (_t = &(_tp)->touches[_i]); _i++) +static inline void +tp_normalize_delta(struct tp_dispatch *tp, double *dx, double *dy) +{ + *dx = *dx * tp->accel.x_scale_coeff; + *dy = *dy * tp->accel.y_scale_coeff; +} + void tp_get_delta(struct tp_touch *t, double *dx, double *dy);