touchpad: add gesture state debug helper
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 10 Jul 2015 05:03:42 +0000 (15:03 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 13 Jul 2015 00:22:16 +0000 (10:22 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad-gestures.c

index 81bbd4d..768d3ec 100644 (file)
 #define DEFAULT_GESTURE_SWITCH_TIMEOUT 100 /* ms */
 #define DEFAULT_GESTURE_2FG_SCROLL_TIMEOUT 1000 /* ms */
 
+#define CASE_RETURN_STRING(a) case a: return #a
+
+static inline const char*
+gesture_state_to_str(enum tp_gesture_2fg_state state)
+{
+       switch (state) {
+       CASE_RETURN_STRING(GESTURE_2FG_STATE_NONE);
+       CASE_RETURN_STRING(GESTURE_2FG_STATE_UNKNOWN);
+       CASE_RETURN_STRING(GESTURE_2FG_STATE_SCROLL);
+       CASE_RETURN_STRING(GESTURE_2FG_STATE_PINCH);
+       }
+       return NULL;
+}
+
 static struct normalized_coords
 tp_get_touches_delta(struct tp_dispatch *tp, bool average)
 {
@@ -380,6 +394,8 @@ tp_gesture_twofinger_handle_state_pinch(struct tp_dispatch *tp, uint64_t time)
 static void
 tp_gesture_post_twofinger(struct tp_dispatch *tp, uint64_t time)
 {
+       enum tp_gesture_2fg_state oldstate = tp->gesture.twofinger_state;
+
        if (tp->gesture.twofinger_state == GESTURE_2FG_STATE_NONE)
                tp->gesture.twofinger_state =
                        tp_gesture_twofinger_handle_state_none(tp, time);
@@ -395,6 +411,11 @@ tp_gesture_post_twofinger(struct tp_dispatch *tp, uint64_t time)
        if (tp->gesture.twofinger_state == GESTURE_2FG_STATE_PINCH)
                tp->gesture.twofinger_state =
                        tp_gesture_twofinger_handle_state_pinch(tp, time);
+
+       log_debug(tp_libinput_context(tp),
+                 "gesture state: %s → %s\n",
+                 gesture_state_to_str(oldstate),
+                 gesture_state_to_str(tp->gesture.twofinger_state));
 }
 
 static void