From: Peter Hutterer Date: Tue, 28 Jul 2015 03:25:45 +0000 (+1000) Subject: touchpad: always enable the bottom-most area for thumb detection X-Git-Tag: 0.21.0~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f03f447590d12f1a9bcc52065a3e476df67479d6;p=platform%2Fupstream%2Flibinput.git 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 Reviewed-by: Hans de Goede --- diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 64ec4466..a683d9a4 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -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;