mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 21:30:13 +01:00
touchpad: always enable the bottom-most area for thumb detection
If the touchpad is higher than 50mm, enable bottom area thumb detection. This only applies to the bottom-most 8mm and only if the touch remains unmoving in that area. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
d823a3da0a
commit
f03f447590
1 changed files with 20 additions and 16 deletions
|
|
@ -1765,13 +1765,6 @@ tp_init_thumb(struct tp_dispatch *tp)
|
|||
if (!tp->buttons.is_clickpad)
|
||||
return 0;
|
||||
|
||||
abs = libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE);
|
||||
if (!abs)
|
||||
return 0;
|
||||
|
||||
if (abs->maximum - abs->minimum < 255)
|
||||
return 0;
|
||||
|
||||
/* if the touchpad is less than 50mm high, skip thumb detection.
|
||||
* it's too small to meaningfully interact with a thumb on the
|
||||
* touchpad */
|
||||
|
|
@ -1779,6 +1772,23 @@ tp_init_thumb(struct tp_dispatch *tp)
|
|||
if (h < 50)
|
||||
return 0;
|
||||
|
||||
tp->thumb.detect_thumbs = true;
|
||||
tp->thumb.threshold = INT_MAX;
|
||||
|
||||
/* detect thumbs by pressure in the bottom 15mm, detect thumbs by
|
||||
* lingering in the bottom 8mm */
|
||||
ymax = tp->device->abs.absinfo_y->maximum;
|
||||
yres = tp->device->abs.absinfo_y->resolution;
|
||||
tp->thumb.upper_thumb_line = ymax - yres * 15;
|
||||
tp->thumb.lower_thumb_line = ymax - yres * 8;
|
||||
|
||||
abs = libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE);
|
||||
if (!abs)
|
||||
goto out;
|
||||
|
||||
if (abs->maximum - abs->minimum < 255)
|
||||
goto out;
|
||||
|
||||
/* 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
|
||||
|
|
@ -1790,17 +1800,11 @@ tp_init_thumb(struct tp_dispatch *tp)
|
|||
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;
|
||||
|
||||
/* detect thumbs by pressure in the bottom 15mm, detect thumbs by
|
||||
* lingering in the bottom 8mm */
|
||||
ymax = tp->device->abs.absinfo_y->maximum;
|
||||
yres = tp->device->abs.absinfo_y->resolution;
|
||||
tp->thumb.upper_thumb_line = ymax - yres * 15;
|
||||
tp->thumb.lower_thumb_line = ymax - yres * 8;
|
||||
|
||||
out:
|
||||
log_debug(tp_libinput_context(tp),
|
||||
"thumb: enabled thumb detection on '%s'\n",
|
||||
"thumb: enabled thumb detection%s on '%s'\n",
|
||||
tp->thumb.threshold != INT_MAX ? " (+pressure)" : "",
|
||||
device->devname);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue