diff --git a/doc/tapping.dox b/doc/tapping.dox index f603b7d5..7eb81e62 100644 --- a/doc/tapping.dox +++ b/doc/tapping.dox @@ -33,6 +33,10 @@ continue the dragging process, so that multiple touchpad-widths of distance can be covered easily. If two-fingers are supported by the hardware, a second finger can be used to drag while the first is held in-place. +An alternative method to end a drag process is to tap immediately after +lifting the finger. The full sequence is thus: tap, finger down, drag, +finger up, tap. + @section tap_constraints Constraints while tapping A couple of constraints apply to the contact to be converted into a press, the most common ones are: diff --git a/doc/touchpad-tap-state-machine.svg b/doc/touchpad-tap-state-machine.svg index b168b4f6..39b0b86b 100644 --- a/doc/touchpad-tap-state-machine.svg +++ b/doc/touchpad-tap-state-machine.svg @@ -14,93 +14,93 @@ - IDLE + IDLE - TOUCH + TOUCH - first + first - finger down + finger down - finger up + finger up - button 1 + button 1 - press + press - timeout + timeout - move > + move > - threshold + threshold - second + second - finger down + finger down - TOUCH_2 + TOUCH_2 - second + second - finger up + finger up - button 2 + button 2 - press + press - move > + move > - threshold + threshold - timeout + timeout @@ -109,16 +109,16 @@ - button 1 + button 1 - release + release - button 2 + button 2 - release + release @@ -127,42 +127,42 @@ - TAPPED + TAPPED - timeout + timeout - first + first - finger down + finger down - DRAGGING + DRAGGING - first + first - finger up + finger up - btn1 + btn1 - release + release @@ -173,81 +173,81 @@ - IDLE + IDLE - third + third - finger down + finger down - TOUCH_3 + TOUCH_3 - button 3 + button 3 - press + press - button 3 + button 3 - release + release - move > + move > - threshold + threshold - IDLE + IDLE - timeout + timeout - first + first - finger up + finger up - IDLE + IDLE - fourth + fourth - finger down + finger down @@ -256,64 +256,64 @@ - DRAGGING_OR_DOUBLETAP + DRAGGING_OR_DOUBLETAP - timeout + timeout - first + first - finger up + finger up - button 1 + button 1 - release + release - button 1 + button 1 - press + press - btn1 + btn1 - release + release - second + second - finger down + finger down - move > + move > - threshold + threshold @@ -322,14 +322,14 @@ - HOLD + HOLD - first + first - finger up + finger up @@ -338,9 +338,9 @@ - second + second - finger down + finger down @@ -351,23 +351,23 @@ - TOUCH_2_HOLD + TOUCH_2_HOLD - second + second - finger up + finger up - first + first - finger up + finger up @@ -378,9 +378,9 @@ - third + third - finger down + finger down @@ -391,21 +391,21 @@ - TOUCH_3_HOLD + TOUCH_3_HOLD - fourth + fourth - finger down + finger down - DEAD + DEAD @@ -416,19 +416,19 @@ - any finger up + any finger up - fourth + fourth - finger up + finger up - any finger up + any finger up @@ -437,12 +437,12 @@ - yes + yes - any finger up + any finger up @@ -455,14 +455,14 @@ - IDLE + IDLE - if finger + if finger - count == 0 + count == 0 @@ -473,14 +473,14 @@ - second + second - finger up + finger up - DRAGGING_2 + DRAGGING_2 @@ -489,9 +489,9 @@ - first + first - finger up + finger up @@ -502,9 +502,9 @@ - second + second - finger down + finger down @@ -515,29 +515,29 @@ - third + third - finger down + finger down - btn1 + btn1 - release + release - phys + phys - button + button - press + press @@ -554,23 +554,23 @@ - phys + phys - button + button - press + press - + - - button 1 - - release + + button 1 + + release - - + + @@ -582,12 +582,12 @@ - DRAGGING_WAIT + DRAGGING_WAIT - timeout + timeout @@ -598,21 +598,21 @@ - first + first - finger down + finger down - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_IDLE + TOUCH_IDLE @@ -625,7 +625,7 @@ - TOUCH_DEAD + TOUCH_DEAD @@ -640,12 +640,12 @@ - yes + yes - TOUCH_DEAD + TOUCH_DEAD @@ -656,14 +656,14 @@ - TOUCH_IDLE + TOUCH_IDLE - TOUCH_TOUCH + TOUCH_TOUCH @@ -672,44 +672,44 @@ - TOUCH_IDLE + TOUCH_IDLE - TOUCH_IDLE + TOUCH_IDLE - TOUCH_IDLE + TOUCH_IDLE - TOUCH_TOUCH + TOUCH_TOUCH - that finger + that finger - TOUCH_IDLE + TOUCH_IDLE - TOUCH_DEAD + TOUCH_DEAD @@ -720,9 +720,9 @@ - that finger + that finger - TOUCH_IDLE + TOUCH_IDLE @@ -731,31 +731,31 @@ - no + no - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_IDLE + TOUCH_IDLE - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_DEAD + TOUCH_DEAD @@ -764,175 +764,171 @@ - TOUCH_IDLE + TOUCH_IDLE - + - - TOUCH_TOUCH + + TOUCH_TOUCH - - - - - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_IDLE + TOUCH_IDLE - TOUCH_IDLE + TOUCH_IDLE - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_IDLE + TOUCH_IDLE - TOUCH_TOUCH + TOUCH_TOUCH - that finger + that finger - TOUCH_IDLE + TOUCH_IDLE - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - - + + - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - state == + state == - TOUCH_TOUCH + TOUCH_TOUCH - that finger state == + that finger state == - TOUCH_TOUCH + TOUCH_TOUCH - no + no - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - TOUCH_DEAD + TOUCH_DEAD - first + first - finger down + finger down - + - - MULTITAP + + MULTITAP - - - - + + + + - timeout + timeout - - + + - IDLE + IDLE @@ -943,14 +939,14 @@ - MULTITAP_DOWN + MULTITAP_DOWN - button 1 + button 1 - press + press @@ -959,39 +955,39 @@ - first + first - finger up + finger up - button 1 + button 1 - release + release - timeout + timeout - second + second - finger down + finger down - move > + move > - threshold + threshold @@ -1002,16 +998,16 @@ - button 1 + button 1 - release + release - button 1 + button 1 - press + press @@ -1022,16 +1018,16 @@ - button 1 + button 1 - release + release - button 1 + button 1 - press + press @@ -1042,16 +1038,16 @@ - button 1 + button 1 - release + release - button 1 + button 1 - press + press @@ -1059,36 +1055,87 @@ - - + + - TOUCH_TOUCH + TOUCH_TOUCH - TOUCH_IDLE + TOUCH_IDLE - phys + phys - button + button - press + press - - + + + + + + DRAGGING_OR_TAP + + + + + first + + finger up + + + + + + + timeout + + + + + + + + + move > + + threshold + + + + + + + + + + + + + + + TOUCH_IDLE + + + + + + + diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 61f94e51..fb8c9e43 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -74,6 +74,7 @@ tap_state_to_str(enum tp_tap_state state) CASE_RETURN_STRING(TAP_STATE_DRAGGING); CASE_RETURN_STRING(TAP_STATE_DRAGGING_WAIT); CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_DOUBLETAP); + CASE_RETURN_STRING(TAP_STATE_DRAGGING_OR_TAP); CASE_RETURN_STRING(TAP_STATE_DRAGGING_2); CASE_RETURN_STRING(TAP_STATE_MULTITAP); CASE_RETURN_STRING(TAP_STATE_MULTITAP_DOWN); @@ -409,8 +410,8 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp, switch (event) { case TAP_EVENT_TOUCH: - tp->tap.state = TAP_STATE_DRAGGING; - tp_tap_clear_timer(tp); + tp->tap.state = TAP_STATE_DRAGGING_OR_TAP; + tp_tap_set_timer(tp, time); break; case TAP_EVENT_RELEASE: case TAP_EVENT_MOTION: @@ -426,6 +427,32 @@ tp_tap_dragging_wait_handle_event(struct tp_dispatch *tp, } } +static void +tp_tap_dragging_tap_handle_event(struct tp_dispatch *tp, + struct tp_touch *t, + enum tap_event event, uint64_t time) +{ + + switch (event) { + case TAP_EVENT_TOUCH: + tp->tap.state = TAP_STATE_DRAGGING_2; + tp_tap_clear_timer(tp); + break; + case TAP_EVENT_RELEASE: + tp->tap.state = TAP_STATE_IDLE; + tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + break; + case TAP_EVENT_MOTION: + case TAP_EVENT_TIMEOUT: + tp->tap.state = TAP_STATE_DRAGGING; + break; + case TAP_EVENT_BUTTON: + tp->tap.state = TAP_STATE_DEAD; + tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED); + break; + } +} + static void tp_tap_dragging2_handle_event(struct tp_dispatch *tp, struct tp_touch *t, @@ -588,6 +615,9 @@ tp_tap_handle_event(struct tp_dispatch *tp, case TAP_STATE_DRAGGING_WAIT: tp_tap_dragging_wait_handle_event(tp, t, event, time); break; + case TAP_STATE_DRAGGING_OR_TAP: + tp_tap_dragging_tap_handle_event(tp, t, event, time); + break; case TAP_STATE_DRAGGING_2: tp_tap_dragging2_handle_event(tp, t, event, time); break; @@ -692,6 +722,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time) case TAP_STATE_TOUCH: case TAP_STATE_TAPPED: case TAP_STATE_DRAGGING_OR_DOUBLETAP: + case TAP_STATE_DRAGGING_OR_TAP: case TAP_STATE_TOUCH_2: case TAP_STATE_TOUCH_3: case TAP_STATE_MULTITAP_DOWN: @@ -870,6 +901,7 @@ tp_tap_dragging(struct tp_dispatch *tp) case TAP_STATE_DRAGGING: case TAP_STATE_DRAGGING_2: case TAP_STATE_DRAGGING_WAIT: + case TAP_STATE_DRAGGING_OR_TAP: return true; default: return false; diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 37113752..f602359f 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -94,6 +94,7 @@ enum tp_tap_state { TAP_STATE_TOUCH_3, TAP_STATE_TOUCH_3_HOLD, TAP_STATE_DRAGGING_OR_DOUBLETAP, + TAP_STATE_DRAGGING_OR_TAP, TAP_STATE_DRAGGING, TAP_STATE_DRAGGING_WAIT, TAP_STATE_DRAGGING_2,