From: Peter Hutterer Date: Tue, 20 Feb 2018 03:27:10 +0000 (+1000) Subject: touchpad: add a touch index for debugging X-Git-Tag: 1.10.901~192 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd096a50fe318b08077468169f122a407b034369;p=platform%2Fupstream%2Flibinput.git touchpad: add a touch index for debugging Makes debugging a bit easier when you know *which* touch was marked as palm, etc. Signed-off-by: Peter Hutterer --- diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index a0ecefd2..819fecc5 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -448,7 +448,8 @@ tp_button_handle_event(struct tp_dispatch *tp, if (current != t->button.state) evdev_log_debug(tp->device, - "button state: from %s, event %s to %s\n", + "button state: touch %d from %s, event %s to %s\n", + t->index, button_state_to_str(current), button_event_to_str(event), button_state_to_str(t->button.state)); diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index eb47ce73..a29d9aff 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -152,7 +152,8 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: evdev_log_bug_libinput(tp->device, - "unexpected scroll event %d in none state\n", + "edge-scroll: touch %d: unexpected scroll event %d in none state\n", + t->index, event); break; } @@ -166,7 +167,8 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp, switch (event) { case SCROLL_EVENT_TOUCH: evdev_log_bug_libinput(tp->device, - "unexpected scroll event %d in edge new state\n", + "edge-scroll: touch %d: unexpected scroll event %d in edge new state\n", + t->index, event); break; case SCROLL_EVENT_MOTION: @@ -194,7 +196,8 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp, case SCROLL_EVENT_TOUCH: case SCROLL_EVENT_TIMEOUT: evdev_log_bug_libinput(tp->device, - "unexpected scroll event %d in edge state\n", + "edge-scroll: touch %d: unexpected scroll event %d in edge state\n", + t->index, event); break; case SCROLL_EVENT_MOTION: @@ -258,7 +261,8 @@ tp_edge_scroll_handle_event(struct tp_dispatch *tp, } evdev_log_debug(tp->device, - "edge state: %s → %s → %s\n", + "edge-scroll: touch %d state %s → %s → %s\n", + t->index, edge_state_to_str(current), edge_event_to_str(event), edge_state_to_str(t->scroll.edge_state)); diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 14025d2f..eaf3a573 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -102,10 +102,11 @@ tap_event_to_str(enum tap_event event) } static inline void -log_tap_bug(struct tp_dispatch *tp, enum tap_event event) +log_tap_bug(struct tp_dispatch *tp, struct tp_touch *t, enum tap_event event) { evdev_log_bug_libinput(tp->device, - "invalid tap event %s in state %s\n", + "%d: invalid tap event %s in state %s\n", + t->index, tap_event_to_str(event), tap_state_to_str(tp->tap.state)); @@ -173,7 +174,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, case TAP_EVENT_RELEASE: break; case TAP_EVENT_MOTION: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_TIMEOUT: break; @@ -181,7 +182,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, tp->tap.state = TAP_STATE_DEAD; break; case TAP_EVENT_THUMB: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_PALM: tp->tap.state = TAP_STATE_IDLE; @@ -289,7 +290,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_MOTION: case TAP_EVENT_RELEASE: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_DRAGGING_OR_DOUBLETAP; @@ -312,7 +313,7 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_THUMB: case TAP_EVENT_PALM: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_PALM_UP: break; @@ -705,7 +706,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, { switch (event) { case TAP_EVENT_RELEASE: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_MULTITAP_DOWN; @@ -717,7 +718,7 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, tp_tap_set_timer(tp, time); break; case TAP_EVENT_MOTION: - log_tap_bug(tp, event); + log_tap_bug(tp, t, event); break; case TAP_EVENT_TIMEOUT: tp->tap.state = TAP_STATE_IDLE; @@ -913,7 +914,8 @@ tp_tap_handle_event(struct tp_dispatch *tp, tp_tap_clear_timer(tp); evdev_log_debug(tp->device, - "tap state: %s → %s → %s\n", + "tap: touch %d state %s → %s → %s\n", + t ? (int)t->index : -1, tap_state_to_str(current), tap_event_to_str(event), tap_state_to_str(tp->tap.state)); diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index be2df4f0..02ad9dd8 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -666,7 +666,9 @@ tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t) if (!tp_palm_in_edge(tp, t)) return false; - evdev_log_debug(tp->device, "palm: palm-tap detected\n"); + evdev_log_debug(tp->device, + "palm: touch %d: palm-tap detected\n", + t->index); return true; } @@ -694,7 +696,8 @@ tp_palm_detect_dwt_triggered(struct tp_dispatch *tp, t->palm.time > tp->dwt.keyboard_last_press_time) { t->palm.state = PALM_NONE; evdev_log_debug(tp->device, - "palm: touch released, timeout after typing\n"); + "palm: touch %d released, timeout after typing\n", + t->index); } } @@ -722,7 +725,7 @@ tp_palm_detect_trackpoint_triggered(struct tp_dispatch *tp, t->palm.time > tp->palm.trackpoint_last_event_time) { t->palm.state = PALM_NONE; evdev_log_debug(tp->device, - "palm: touch released, timeout after trackpoint\n"); + "palm: touch %d released, timeout after trackpoint\n", t->index); } } @@ -827,7 +830,8 @@ tp_palm_detect_touch_size_triggered(struct tp_dispatch *tp, t->minor > tp->palm.size_threshold) { if (t->palm.state != PALM_TOUCH_SIZE) evdev_log_debug(tp->device, - "palm: touch size exceeded\n"); + "palm: touch %d size exceeded\n", + t->index); t->palm.state = PALM_TOUCH_SIZE; return true; } @@ -844,7 +848,8 @@ tp_palm_detect_edge(struct tp_dispatch *tp, if (tp_palm_detect_multifinger(tp, t, time)) { t->palm.state = PALM_NONE; evdev_log_debug(tp->device, - "palm: touch released, multiple fingers\n"); + "palm: touch %d released, multiple fingers\n", + t->index); /* If labelled a touch as palm, we unlabel as palm when we move out of the palm edge zone within the timeout, provided @@ -853,7 +858,8 @@ tp_palm_detect_edge(struct tp_dispatch *tp, } else if (tp_palm_detect_move_out_of_edge(tp, t, time)) { t->palm.state = PALM_NONE; evdev_log_debug(tp->device, - "palm: touch released, out of edge zone\n"); + "palm: touch %d released, out of edge zone\n", + t->index); } return false; } else if (tp_palm_detect_multifinger(tp, t, time)) { @@ -964,7 +970,8 @@ out: break; } evdev_log_debug(tp->device, - "palm: palm detected (%s)\n", + "palm: touch %d, palm detected (%s)\n", + t->index, palm_state); } @@ -1038,7 +1045,8 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) out: if (t->thumb.state != state) evdev_log_debug(tp->device, - "thumb state: %s → %s\n", + "thumb state: touch %d, %s → %s\n", + t->index, thumb_state_to_str(state), thumb_state_to_str(t->thumb.state)); } @@ -1065,7 +1073,8 @@ tp_unhover_pressure(struct tp_dispatch *tp, uint64_t time) if (t->state == TOUCH_HOVERING) { if (t->pressure >= tp->pressure.high) { evdev_log_debug(tp->device, - "pressure: begin touch\n"); + "pressure: begin touch %d\n", + t->index); /* avoid jumps when landing a finger */ tp_motion_history_reset(t); tp_begin_touch(tp, t, time); @@ -1073,7 +1082,8 @@ tp_unhover_pressure(struct tp_dispatch *tp, uint64_t time) } else { if (t->pressure < tp->pressure.low) { evdev_log_debug(tp->device, - "pressure: end touch\n"); + "pressure: end touch %d\n", + t->index); tp_end_touch(tp, t, time); } } @@ -1145,7 +1155,8 @@ tp_unhover_size(struct tp_dispatch *tp, uint64_t time) if ((t->major > high && t->minor > low) || (t->major > low && t->minor > high)) { evdev_log_debug(tp->device, - "touch-size: begin touch\n"); + "touch-size: begin touch %d\n", + t->index); /* avoid jumps when landing a finger */ tp_motion_history_reset(t); tp_begin_touch(tp, t, time); @@ -1153,7 +1164,8 @@ tp_unhover_size(struct tp_dispatch *tp, uint64_t time) } else { if (t->major < low || t->minor < low) { evdev_log_debug(tp->device, - "touch-size: end touch\n"); + "touch-size: end touch %d\n", + t->index); tp_end_touch(tp, t, time); } } @@ -1371,7 +1383,8 @@ tp_detect_thumb_while_moving(struct tp_dispatch *tp) /* Finger are too far apart or 2fg scrolling is disabled, mark * second finger as thumb */ evdev_log_debug(tp->device, - "touch is speed-based thumb\n"); + "touch %d is speed-based thumb\n", + second->index); second->thumb.state = THUMB_STATE_YES; } @@ -2302,10 +2315,12 @@ static struct evdev_dispatch_interface tp_interface = { static void tp_init_touch(struct tp_dispatch *tp, - struct tp_touch *t) + struct tp_touch *t, + unsigned int index) { t->tp = tp; t->has_ended = true; + t->index = index; } static inline void @@ -2389,7 +2404,7 @@ tp_init_slots(struct tp_dispatch *tp, tp->touches = zalloc(tp->ntouches * sizeof(struct tp_touch)); for (i = 0; i < tp->ntouches; i++) - tp_init_touch(tp, &tp->touches[i]); + tp_init_touch(tp, &tp->touches[i], i); tp_sync_slots(tp, device); diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 442f34a3..8f35ef0a 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -143,6 +143,7 @@ enum tp_thumb_state { struct tp_touch { struct tp_dispatch *tp; + unsigned int index; enum touch_state state; bool has_ended; /* TRACKING_ID == -1 */ bool dirty; diff --git a/test/litest.c b/test/litest.c index a31e874e..c102afa8 100644 --- a/test/litest.c +++ b/test/litest.c @@ -661,7 +661,7 @@ litest_log_handler(struct libinput *libinput, if (!is_tty) color = ""; - else if (strstr(format, "tap state:")) + else if (strstr(format, "tap:")) color = ANSI_BLUE; else if (strstr(format, "thumb state:")) color = ANSI_YELLOW; @@ -673,7 +673,7 @@ litest_log_handler(struct libinput *libinput, else if (strstr(format, "palm:") || strstr(format, "thumb:")) color = ANSI_CYAN; - else if (strstr(format, "edge state:")) + else if (strstr(format, "edge-scroll:")) color = ANSI_BRIGHT_GREEN; fprintf(stderr, "%slitest %s ", color, priority);