Commit a1effa16 authored by Peter Hutterer's avatar Peter Hutterer Committed by Matt Mayfield

touchpad: clean up the thumb pressure handling out a bit

Use a boolean for whether we need to use it and drop the unneded absinfo
assignment (together with the goto).
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 65f890a3
......@@ -1132,7 +1132,8 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
* A finger that remains at the very bottom of the touchpad becomes
* a thumb.
*/
if (t->pressure > tp->thumb.threshold)
if (tp->thumb.use_pressure &&
t->pressure > tp->thumb.pressure_threshold)
t->thumb.state = THUMB_STATE_YES;
else if (t->point.y > tp->thumb.lower_thumb_line &&
tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE &&
......@@ -3082,7 +3083,6 @@ static void
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;
struct device_coords edges;
struct phys_coords mm = { 0.0, 0.0 };
......@@ -3101,7 +3101,8 @@ tp_init_thumb(struct tp_dispatch *tp)
return;
tp->thumb.detect_thumbs = true;
tp->thumb.threshold = INT_MAX;
tp->thumb.use_pressure = false;
tp->thumb.pressure_threshold = INT_MAX;
/* detect thumbs by pressure in the bottom 15mm, detect thumbs by
* lingering in the bottom 8mm */
......@@ -3113,22 +3114,23 @@ tp_init_thumb(struct tp_dispatch *tp)
edges = evdev_device_mm_to_units(device, &mm);
tp->thumb.lower_thumb_line = edges.y;
abs = libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE);
if (!abs)
goto out;
quirks = evdev_libinput_context(device)->quirks;
q = quirks_fetch_for_device(quirks, device->udev_device);
if (quirks_get_uint32(q,
QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
&threshold))
tp->thumb.threshold = threshold;
if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_MT_PRESSURE)) {
if (quirks_get_uint32(q,
QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
&threshold)) {
tp->thumb.use_pressure = true;
tp->thumb.pressure_threshold = threshold;
}
}
quirks_unref(q);
out:
evdev_log_debug(device,
"thumb: enabled thumb detection%s\n",
tp->thumb.threshold != INT_MAX ? " (+pressure)" : "");
tp->thumb.use_pressure ? " (+pressure)" : "");
}
static bool
......
......@@ -441,9 +441,11 @@ struct tp_dispatch {
struct {
bool detect_thumbs;
int threshold;
int upper_thumb_line;
int lower_thumb_line;
bool use_pressure;
int pressure_threshold;
} thumb;
struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment