From 5a63c82822bbeae7b97708204893b9a0f40e0d1e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 23 Mar 2017 13:55:32 +1000 Subject: [PATCH] touchpad: make palm detection logging a bit easier Nested trinary conditions are fun, but... Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index e891dea..3fd1f29 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -715,6 +715,8 @@ tp_palm_detect_edge(struct tp_dispatch *tp, static void tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) { + const char *palm_state; + enum touch_palm_state oldstate = t->palm.state; if (tp_palm_detect_dwt_triggered(tp, t, time)) goto out; @@ -726,12 +728,28 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) goto out; return; - out: + if (oldstate == t->palm.state) + return; + + switch (t->palm.state) { + case PALM_EDGE: + palm_state = "edge"; + break; + case PALM_TYPING: + palm_state = "typing"; + break; + case PALM_TRACKPOINT: + palm_state = "trackpoint"; + break; + case PALM_NONE: + default: + abort(); + break; + } evdev_log_debug(tp->device, "palm: palm detected (%s)\n", - t->palm.state == PALM_EDGE ? "edge" : - t->palm.state == PALM_TYPING ? "typing" : "trackpoint"); + palm_state); } static inline const char* -- 2.7.4