Hi,

On 03-08-15 06:29, Peter Hutterer wrote:
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 <[email protected]>

LGTM: Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans


---
  src/evdev-mt-touchpad.c | 36 ++++++++++++++++++++----------------
  1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 64ec446..a683d9a 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;

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to