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

Hans de Goede hdegoede at redhat.com
Fri Mar 6 02:35:46 PST 2015


Hi,

On 05-03-15 22:45, Peter Hutterer wrote:
> 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>

Looks good:

Reviewed-by: Hans de Goede <hdegoede at redhat.com>

Regards,

Hans

> ---
>   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);
>
>


More information about the wayland-devel mailing list