[PATCH libinput 06/11] touchpad: scale thumb pressure threshold with the resolution
Hans de Goede
hdegoede at redhat.com
Wed Jul 22 06:48:59 PDT 2015
Hi,
On 22-07-15 07:09, Peter Hutterer wrote:
> On touchpads with a higher resolution we also see higher pressure values.
> Scale accordingly, but use the T440s as reference and don't go below that
> device's threshold. A false positive is worse than a false negative when it
> comes to thumb detection.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=91362
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Tricky, feels a bit like black magic, I cannot think of a better approach though,
so lets see how this works out:
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
Regards,
Hans
> ---
> src/evdev-mt-touchpad.c | 13 ++++++++++---
> test/touchpad.c | 20 ++++++++++----------
> 2 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index b4399d2..c7f55c3 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -1534,6 +1534,8 @@ tp_init_thumb(struct tp_dispatch *tp)
> struct evdev_device *device = tp->device;
> const struct input_absinfo *abs;
> double w = 0.0, h = 0.0;
> + int xres, yres;
> + double threshold;
>
> if (!tp->buttons.is_clickpad)
> return 0;
> @@ -1552,12 +1554,17 @@ tp_init_thumb(struct tp_dispatch *tp)
> if (h < 50)
> return 0;
>
> - /* The touchpads we looked at so far have a clear thumb threshold of
> - * ~100, you don't reach that with a normal finger interaction.
> + /* Our reference touchpad is the T440s with 42x42 resolution.
> + * Higher-res touchpads exhibit higher pressure for the same
> + * interaction. On the T440s, the threshold value is 100, you don't
> + * reach that with a normal finger interaction.
> * Note: "thumb" means massive touch that should not interact, not
> * "using the tip of my thumb for a pinch gestures".
> */
> - tp->thumb.threshold = 100;
> + xres = tp->device->abs.absinfo_x->resolution;
> + yres = tp->device->abs.absinfo_y->resolution;
> + threshold = 100.0 * hypot(xres, yres)/hypot(42, 42);
> + tp->thumb.threshold = max(100, threshold);
> tp->thumb.detect_thumbs = true;
>
> return 0;
> diff --git a/test/touchpad.c b/test/touchpad.c
> index 7b8324c..27485ae 100644
> --- a/test/touchpad.c
> +++ b/test/touchpad.c
> @@ -4017,7 +4017,7 @@ START_TEST(touchpad_thumb_begin_no_motion)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4041,7 +4041,7 @@ START_TEST(touchpad_thumb_update_no_motion)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4071,7 +4071,7 @@ START_TEST(touchpad_thumb_clickfinger)
> struct libinput_event *event;
> struct libinput_event_pointer *ptrev;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4128,7 +4128,7 @@ START_TEST(touchpad_thumb_btnarea)
> struct libinput_event *event;
> struct libinput_event_pointer *ptrev;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4164,7 +4164,7 @@ START_TEST(touchpad_thumb_edgescroll)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4195,7 +4195,7 @@ START_TEST(touchpad_thumb_tap_begin)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4225,7 +4225,7 @@ START_TEST(touchpad_thumb_tap_touch)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4255,7 +4255,7 @@ START_TEST(touchpad_thumb_tap_hold)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4286,7 +4286,7 @@ START_TEST(touchpad_thumb_tap_hold_2ndfg)
> struct litest_device *dev = litest_current_device();
> struct libinput *li = dev->libinput;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
> @@ -4333,7 +4333,7 @@ START_TEST(touchpad_thumb_tap_hold_2ndfg_tap)
> struct libinput_event *event;
> struct libinput_event_pointer *ptrev;
> struct axis_replacement axes[] = {
> - { ABS_MT_PRESSURE, 100 },
> + { ABS_MT_PRESSURE, 190 },
> { -1, 0 }
> };
>
>
More information about the wayland-devel
mailing list