[PATCH v2 libinput 3/3] touchpad: change tap motion threshold to 3 mm

Hans de Goede hdegoede at redhat.com
Fri Mar 6 02:41:44 PST 2015


Hi,

On 06-03-15 06:42, Peter Hutterer wrote:
> Previous code used a device coordinate threshold of 300 which won't work on
> Elantech touchpads (1280 vs the ~4000 that synaptics has).
> Convert to normalized DPI and reduce the threshold to 3mm.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=89206
>
> [note that because of the MAGIC in the accel code this is currently
> more than 3mm]
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Changes to v1:
> - use the new macro instead

Looks good, but please use the new new TP_MM_TO_DPI_NORMALIZED macro instead,
then you can drop the comment about the MAGIC stuff. You likely want to change the
threshold to a different value then too, say 5 mm (3 / MAGIC = 7.5 but that seems
a bit much).

With that changes this is:

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

Regards,

Hans


>
>   src/evdev-mt-touchpad-tap.c | 11 ++++++++---
>   src/evdev-mt-touchpad.h     |  1 +
>   2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
> index 228eb84..d2728ee 100644
> --- a/src/evdev-mt-touchpad-tap.c
> +++ b/src/evdev-mt-touchpad-tap.c
> @@ -37,7 +37,7 @@
>   #define CASE_RETURN_STRING(a) case a: return #a;
>
>   #define DEFAULT_TAP_TIMEOUT_PERIOD 180
> -#define DEFAULT_TAP_MOVE_THRESHOLD 30
> +#define DEFAULT_TAP_MOVE_THRESHOLD MM_TO_DPI_NORMALIZED(3)
>
>   enum tap_event {
>   	TAP_EVENT_TOUCH = 12,
> @@ -527,12 +527,15 @@ tp_tap_handle_event(struct tp_dispatch *tp,
>   }
>
>   static bool
> -tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp, struct tp_touch *t)
> +tp_tap_exceeds_motion_threshold(struct tp_dispatch *tp,
> +				struct tp_touch *t)
>   {
>   	int threshold = DEFAULT_TAP_MOVE_THRESHOLD;
>   	double dx, dy;
>
> -	tp_get_delta(t, &dx, &dy);
> +	dx = abs(t->tap.initial_x - t->x);
> +	dy = abs(t->tap.initial_y - t->y);
> +	tp_normalize_delta(tp, &dx, &dy);
>
>   	return dx * dx + dy * dy > threshold * threshold;
>   }
> @@ -568,6 +571,8 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
>
>   		if (t->state == TOUCH_BEGIN) {
>   			t->tap.state = TAP_TOUCH_STATE_TOUCH;
> +			t->tap.initial_x = t->x;
> +			t->tap.initial_y = t->y;
>   			tp_tap_handle_event(tp, t, TAP_EVENT_TOUCH, time);
>   		} else if (t->state == TOUCH_END) {
>   			tp_tap_handle_event(tp, t, TAP_EVENT_RELEASE, time);
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index 1b8b560..65581ae 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -162,6 +162,7 @@ struct tp_touch {
>
>   	struct {
>   		enum tp_tap_touch_state state;
> +		int32_t initial_x, initial_y;
>   	} tap;
>
>   	struct {
>


More information about the wayland-devel mailing list