[PATCH libinput 1/4] evdev: move the hysteresis code to a more generic location

Jonas Ådahl jadahl at gmail.com
Fri Apr 15 06:07:33 UTC 2016


On Fri, Apr 15, 2016 at 03:38:43PM +1000, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/evdev-mt-touchpad.c | 12 ++++++------
>  src/evdev.h             | 13 +++++++++++++
>  2 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index cf5fffe..48edb80 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -105,12 +105,12 @@ tp_motion_hysteresis(struct tp_dispatch *tp,
>  	if (t->history.count == 0) {
>  		t->hysteresis_center = t->point;
>  	} else {
> -		x = tp_hysteresis(x,
> -				  t->hysteresis_center.x,
> -				  tp->hysteresis_margin.x);
> -		y = tp_hysteresis(y,
> -				  t->hysteresis_center.y,
> -				  tp->hysteresis_margin.y);

Shouldn't you remove tp_hysteresis() now? I can't see where its use
other than these too calls. Other than that this is Reviewed-by: Jonas
Ådahl <jadahl at gmail.com> .


Jonas

> +		x = evdev_hysteresis(x,
> +				     t->hysteresis_center.x,
> +				     tp->hysteresis_margin.x);
> +		y = evdev_hysteresis(y,
> +				     t->hysteresis_center.y,
> +				     tp->hysteresis_margin.y);
>  		t->hysteresis_center.x = x;
>  		t->hysteresis_center.y = y;
>  		t->point.x = x;
> diff --git a/src/evdev.h b/src/evdev.h
> index 0e08f6d..4171c8a 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -469,4 +469,17 @@ evdev_to_left_handed(struct evdev_device *device,
>  	return button;
>  }
>  
> +static inline int
> +evdev_hysteresis(int in, int center, int margin)
> +{
> +	int diff = in - center;
> +	if (abs(diff) <= margin)
> +		return center;
> +
> +	if (diff > margin)
> +		return center + diff - margin;
> +	else
> +		return center + diff + margin;
> +}
> +
>  #endif /* EVDEV_H */
> -- 
> 2.5.5
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list