diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-05-04 11:51:36 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-05-04 11:51:36 +1000 |
commit | fc470291f1e66ff4a9195df92b3600a331cd488f (patch) | |
tree | cd03b3ced8e3f423bbe59b597431cda5ffc836ef /src | |
parent | 61452d80c67a9f3e15411030e564aab49b1b8d7a (diff) | |
parent | 2d032019b6a46ae0ce837137a4890fc2f6409c7c (diff) |
Merge branch 'wip/touchpad-tap-timestamps'
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev-mt-touchpad-tap.c | 74 | ||||
-rw-r--r-- | src/evdev-mt-touchpad.c | 25 | ||||
-rw-r--r-- | src/evdev-mt-touchpad.h | 3 | ||||
-rw-r--r-- | src/libinput-private.h | 2 | ||||
-rw-r--r-- | src/libinput.c | 86 | ||||
-rw-r--r-- | src/libinput.h | 42 |
6 files changed, 180 insertions, 52 deletions
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 29989c9..5a237fe 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -152,7 +152,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH; - tp->tap.first_press_time = time; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: @@ -182,15 +182,17 @@ tp_tap_touch_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH_2; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: tp_tap_notify(tp, - tp->tap.first_press_time, + tp->tap.saved_press_time, 1, LIBINPUT_BUTTON_STATE_PRESSED); if (tp->tap.drag_enabled) { tp->tap.state = TAP_STATE_TAPPED; + tp->tap.saved_release_time = time; tp_tap_set_timer(tp, time); } else { tp_tap_notify(tp, @@ -226,6 +228,7 @@ tp_tap_hold_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH_2; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: @@ -258,15 +261,22 @@ tp_tap_tapped_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_DRAGGING_OR_DOUBLETAP; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_TIMEOUT: tp->tap.state = TAP_STATE_IDLE; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); break; case TAP_EVENT_BUTTON: tp->tap.state = TAP_STATE_DEAD; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); break; case TAP_EVENT_THUMB: break; @@ -282,10 +292,12 @@ tp_tap_touch2_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH_3; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: tp->tap.state = TAP_STATE_TOUCH_2_RELEASE; + tp->tap.saved_release_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_MOTION: @@ -311,6 +323,7 @@ tp_tap_touch2_hold_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_TOUCH_3; + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: @@ -341,8 +354,14 @@ tp_tap_touch2_release_handle_event(struct tp_dispatch *tp, tp_tap_clear_timer(tp); break; case TAP_EVENT_RELEASE: - tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_PRESSED); - tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_press_time, + 2, + LIBINPUT_BUTTON_STATE_PRESSED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 2, + LIBINPUT_BUTTON_STATE_RELEASED); tp->tap.state = TAP_STATE_IDLE; break; case TAP_EVENT_MOTION: @@ -376,7 +395,10 @@ tp_tap_touch3_handle_event(struct tp_dispatch *tp, case TAP_EVENT_RELEASE: tp->tap.state = TAP_STATE_TOUCH_2_HOLD; if (t->tap.state == TAP_TOUCH_STATE_TOUCH) { - tp_tap_notify(tp, time, 3, LIBINPUT_BUTTON_STATE_PRESSED); + tp_tap_notify(tp, + tp->tap.saved_press_time, + 3, + LIBINPUT_BUTTON_STATE_PRESSED); tp_tap_notify(tp, time, 3, LIBINPUT_BUTTON_STATE_RELEASED); } break; @@ -424,7 +446,11 @@ tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_RELEASE: tp->tap.state = TAP_STATE_MULTITAP; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); + tp->tap.saved_release_time = time; break; case TAP_EVENT_MOTION: case TAP_EVENT_TIMEOUT: @@ -432,7 +458,10 @@ tp_tap_dragging_or_doubletap_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_BUTTON: tp->tap.state = TAP_STATE_DEAD; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); break; case TAP_EVENT_THUMB: break; @@ -568,7 +597,11 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_MULTITAP_DOWN; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_PRESSED); + tp_tap_notify(tp, + tp->tap.saved_press_time, + 1, + LIBINPUT_BUTTON_STATE_PRESSED); + tp->tap.saved_press_time = time; tp_tap_set_timer(tp, time); break; case TAP_EVENT_MOTION: @@ -577,8 +610,14 @@ tp_tap_multitap_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_TIMEOUT: tp->tap.state = TAP_STATE_IDLE; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_PRESSED); - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_press_time, + 1, + LIBINPUT_BUTTON_STATE_PRESSED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); break; case TAP_EVENT_BUTTON: tp->tap.state = TAP_STATE_IDLE; @@ -598,7 +637,11 @@ tp_tap_multitap_down_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_RELEASE: tp->tap.state = TAP_STATE_MULTITAP; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); + tp->tap.saved_release_time = time; break; case TAP_EVENT_TOUCH: tp->tap.state = TAP_STATE_DRAGGING_2; @@ -611,7 +654,10 @@ tp_tap_multitap_down_handle_event(struct tp_dispatch *tp, break; case TAP_EVENT_BUTTON: tp->tap.state = TAP_STATE_DEAD; - tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + tp_tap_notify(tp, + tp->tap.saved_release_time, + 1, + LIBINPUT_BUTTON_STATE_RELEASED); tp_tap_clear_timer(tp); break; case TAP_EVENT_THUMB: diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 38c3c92..8140c44 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1262,6 +1262,28 @@ tp_handle_state(struct tp_dispatch *tp, tp_clickpad_middlebutton_apply_config(tp->device); } +static inline void +tp_debug_touch_state(struct tp_dispatch *tp, + struct evdev_device *device) +{ + char buf[1024] = {0}; + struct tp_touch *t; + size_t i = 0; + + tp_for_each_touch(tp, t) { + if (i >= tp->nfingers_down) + break; + sprintf(&buf[strlen(buf)], + "slot %zd: %04d/%04d p%03d %s |", + i++, + t->point.x, + t->point.y, + t->pressure, + tp_touch_active(tp, t) ? "" : "inactive"); + } + evdev_log_debug(device, "touch state: %s\n", buf); +} + static void tp_interface_process(struct evdev_dispatch *dispatch, struct evdev_device *device, @@ -1285,6 +1307,9 @@ tp_interface_process(struct evdev_dispatch *dispatch, break; case EV_SYN: tp_handle_state(tp, time); +#if 0 + tp_debug_touch_state(tp, device); +#endif break; } } diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 8d5bbc4..304e92f 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -321,7 +321,8 @@ struct tp_dispatch { struct libinput_timer timer; enum tp_tap_state state; uint32_t buttons_pressed; - uint64_t first_press_time; + uint64_t saved_press_time, + saved_release_time; enum libinput_config_tap_button_map map; enum libinput_config_tap_button_map want_map; diff --git a/src/libinput-private.h b/src/libinput-private.h index a1d5000..1a564f9 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -136,6 +136,8 @@ struct libinput { int refcount; struct list device_group_list; + + uint64_t last_event_time; }; typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat); diff --git a/src/libinput.c b/src/libinput.c index 514a611..472b1c0 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -25,6 +25,7 @@ #include "config.h" #include <errno.h> +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -73,6 +74,43 @@ check_event_type(struct libinput *libinput, return rc; } +static inline const char * +event_type_to_str(enum libinput_event_type type) +{ + switch(type) { + CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED); + CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED); + CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY); + CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION); + CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE); + CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON); + CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS); + CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_DOWN); + CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_UP); + CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION); + CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL); + CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_BUTTON); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING); + CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_BEGIN); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_UPDATE); + CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_END); + CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE); + case LIBINPUT_EVENT_NONE: + abort(); + } + + return NULL; +} + struct libinput_source { libinput_source_dispatch_t dispatch; void *user_data; @@ -2026,6 +2064,17 @@ post_device_event(struct libinput_device *device, struct libinput_event *event) { struct libinput_event_listener *listener, *tmp; +#if 0 + struct libinput *libinput = device->seat->libinput; + + if (libinput->last_event_time > time) { + log_bug_libinput(device->seat->libinput, + "out-of-order timestamps for %s time %" PRIu64 "\n", + event_type_to_str(type), + time); + } + libinput->last_event_time = time; +#endif init_event_base(event, device, type); @@ -2660,43 +2709,6 @@ gesture_notify_pinch_end(struct libinput_device *device, finger_count, cancelled, &zero, &zero, scale, 0.0); } -static inline const char * -event_type_to_str(enum libinput_event_type type) -{ - switch(type) { - CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED); - CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED); - CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY); - CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION); - CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE); - CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON); - CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS); - CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_DOWN); - CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_UP); - CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION); - CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL); - CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_BUTTON); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING); - CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_BEGIN); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_UPDATE); - CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_END); - CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE); - case LIBINPUT_EVENT_NONE: - abort(); - } - - return NULL; -} - void switch_notify_toggle(struct libinput_device *device, uint64_t time, diff --git a/src/libinput.h b/src/libinput.h index 0540f23..6b63d47 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -972,6 +972,9 @@ libinput_event_device_notify_get_base_event(struct libinput_event_device_notify /** * @ingroup event_keyboard * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event */ uint32_t @@ -980,6 +983,9 @@ libinput_event_keyboard_get_time(struct libinput_event_keyboard *event); /** * @ingroup event_keyboard * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event in microseconds */ uint64_t @@ -1035,6 +1041,9 @@ libinput_event_keyboard_get_seat_key_count( /** * @ingroup event_pointer * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event */ uint32_t @@ -1043,6 +1052,9 @@ libinput_event_pointer_get_time(struct libinput_event_pointer *event); /** * @ingroup event_pointer * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event in microseconds */ uint64_t @@ -1400,6 +1412,9 @@ libinput_event_pointer_get_base_event(struct libinput_event_pointer *event); /** * @ingroup event_touch * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event */ uint32_t @@ -1408,6 +1423,9 @@ libinput_event_touch_get_time(struct libinput_event_touch *event); /** * @ingroup event_touch * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event in microseconds */ uint64_t @@ -1564,6 +1582,9 @@ libinput_event_touch_get_base_event(struct libinput_event_touch *event); /** * @ingroup event_gesture * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event */ uint32_t @@ -1572,6 +1593,9 @@ libinput_event_gesture_get_time(struct libinput_event_gesture *event); /** * @ingroup event_gesture * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @return The event time for this event in microseconds */ uint64_t @@ -2300,6 +2324,9 @@ libinput_event_tablet_tool_get_seat_button_count(struct libinput_event_tablet_to /** * @ingroup event_tablet * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput tablet tool event * @return The event time for this event */ @@ -2309,6 +2336,9 @@ libinput_event_tablet_tool_get_time(struct libinput_event_tablet_tool *event); /** * @ingroup event_tablet * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput tablet tool event * @return The event time for this event in microseconds */ @@ -2735,6 +2765,9 @@ libinput_event_tablet_pad_get_mode_group(struct libinput_event_tablet_pad *event /** * @ingroup event_tablet_pad * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput tablet pad event * @return The event time for this event */ @@ -2744,6 +2777,9 @@ libinput_event_tablet_pad_get_time(struct libinput_event_tablet_pad *event); /** * @ingroup event_tablet_pad * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput tablet pad event * @return The event time for this event in microseconds */ @@ -2799,6 +2835,9 @@ libinput_event_switch_get_base_event(struct libinput_event_switch *event); /** * @ingroup event_switch * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput switch event * @return The event time for this event */ @@ -2808,6 +2847,9 @@ libinput_event_switch_get_time(struct libinput_event_switch *event); /** * @ingroup event_switch * + * @note Timestamps may not always increase. See @ref event_timestamps for + * details. + * * @param event The libinput switch event * @return The event time for this event in microseconds */ |