[PATCH libinput 2/3] touchpad: return normalized deltas from tp_get_delta

Peter Hutterer peter.hutterer at who-t.net
Thu Mar 5 13:45:27 PST 2015


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 <peter.hutterer at who-t.net>
---
 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 b90d84c..9b06522 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 f04cc11..1b8b560 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);
 
-- 
2.1.0



More information about the wayland-devel mailing list