touchpad: always enable the bottom-most area for thumb detection
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 28 Jul 2015 03:25:45 +0000 (13:25 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 3 Aug 2015 21:37:26 +0000 (07:37 +1000)
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>
src/evdev-mt-touchpad.c

index 64ec4466021ba20b9e50d88b2079a96a03879570..a683d9a4bacf17f1eb691eb50b5697d1fb6da2b7 100644 (file)
@@ -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;