summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-04-03 13:58:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-04-21 10:03:58 +1000
commit9495713b05d244b0293cbf4fc5e6a7094ee50e27 (patch)
tree4bb6a23fa9c3108bc3164e20bb620d0ae3618cd7 /src
parent7d1a047b7c2f7acf6fdce5ac5d352bd909605234 (diff)
touchpad: add MT_TOOL-based palm detection
If the touchpad driver tells us something is a palm, go with that. https://bugs.freedesktop.org/show_bug.cgi?id=100243 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad.c41
-rw-r--r--src/evdev-mt-touchpad.h4
2 files changed, 45 insertions, 0 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index f41dd68..8585351 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -341,6 +341,11 @@ tp_process_absolute(struct tp_dispatch *tp,
t->dirty = true;
tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
break;
+ case ABS_MT_TOOL_TYPE:
+ t->is_tool_palm = e->value == MT_TOOL_PALM;
+ t->dirty = true;
+ tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
+ break;
}
}
@@ -622,6 +627,31 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp,
return false;
}
+static bool
+tp_palm_detect_tool_triggered(struct tp_dispatch *tp,
+ struct tp_touch *t,
+ uint64_t time)
+{
+ if (!tp->palm.use_mt_tool)
+ return false;
+
+ if (t->palm.state != PALM_NONE &&
+ t->palm.state != PALM_TOOL_PALM)
+ return false;
+
+ if (t->palm.state == PALM_NONE &&
+ t->is_tool_palm)
+ t->palm.state = PALM_TOOL_PALM;
+ else if (t->palm.state == PALM_TOOL_PALM &&
+ !t->is_tool_palm)
+ t->palm.state = PALM_NONE;
+
+ if (t->palm.state == PALM_TOOL_PALM)
+ tp_stop_actions(tp, time);
+
+ return t->palm.state == PALM_TOOL_PALM;
+}
+
static inline bool
tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp,
struct tp_touch *t,
@@ -732,6 +762,9 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
if (tp_palm_detect_trackpoint_triggered(tp, t, time))
goto out;
+ if (tp_palm_detect_tool_triggered(tp, t, time))
+ goto out;
+
if (tp_palm_detect_edge(tp, t, time))
goto out;
@@ -750,6 +783,9 @@ out:
case PALM_TRACKPOINT:
palm_state = "trackpoint";
break;
+ case PALM_TOOL_PALM:
+ palm_state = "tool-palm";
+ break;
case PALM_NONE:
default:
abort();
@@ -2267,6 +2303,11 @@ tp_init_palmdetect(struct tp_dispatch *tp,
tp->palm.monitor_trackpoint = true;
+ if (libevdev_has_event_code(device->evdev,
+ EV_ABS,
+ ABS_MT_TOOL_TYPE))
+ tp->palm.use_mt_tool = true;
+
tp_init_palmdetect_edge(tp, device);
}
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 2d531b5..93dd37b 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -66,6 +66,7 @@ enum touch_palm_state {
PALM_EDGE,
PALM_TYPING,
PALM_TRACKPOINT,
+ PALM_TOOL_PALM,
};
enum button_event {
@@ -154,6 +155,7 @@ struct tp_touch {
struct device_coords point;
uint64_t millis;
int pressure;
+ bool is_tool_palm; /* MT_TOOL_PALM */
bool was_down; /* if distance == 0, false for pure hovering
touches */
@@ -347,6 +349,8 @@ struct tp_dispatch {
uint64_t trackpoint_last_event_time;
uint32_t trackpoint_event_count;
bool monitor_trackpoint;
+
+ bool use_mt_tool;
} palm;
struct {