touchpad: make palm detection logging a bit easier
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 23 Mar 2017 03:55:32 +0000 (13:55 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 21 Apr 2017 00:03:16 +0000 (10:03 +1000)
Nested trinary conditions are fun, but...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad.c

index e891dea..3fd1f29 100644 (file)
@@ -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*