From fa73b3b307a2fc23840bb3823fb0f28b6d450164 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 4 Jan 2019 16:03:38 +0900 Subject: [PATCH] evdev: Do not perform spurious detection when spurious is already enabled When exiting RELEASE_DELAYED state, do not transition into states to detect the need for spurious mode (RELEASE_WAITING, MAYBE_SPURIOUS). RELEASE_DELAYED is only entered when spurious mode is enabled, there is no need to detect the need for spurious mode again. --- doc/button-debouncing-state-machine.svg | 3 ++- src/evdev-debounce.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/button-debouncing-state-machine.svg b/doc/button-debouncing-state-machine.svg index 02ffc460..0553012f 100644 --- a/doc/button-debouncing-state-machine.svg +++ b/doc/button-debouncing-state-machine.svg @@ -1,2 +1,3 @@ + -
IS_UP
IS_UP
button
press
[Not supported by viewer]
DOWN_WAITING
DOWN_WAITING
RELEASE_PENDING
RELEASE_PENDING
timeout
timeout
notify
button
release
[Not supported by viewer]
notify
button
press
[Not supported by viewer]
IS_DOWN
IS_DOWN
button
release
button<br>release
timeout
timeout
IS_UP
IS_UP
button
release
button<br>release
button
press
[Not supported by viewer]
notify
button
release
[Not supported by viewer]
RELEASE_WAITING
RELEASE_WAITING
button
press
[Not supported by viewer]
timeout
timeout
MAYBE_SPURIOUS
MAYBE_SPURIOUS
button
release
button<br>release
timeout
short
timeout<br>short
spurious
enabled?
spurious<br>enabled?
no
no
timeout
short
timeout<br>short
RELEASED
RELEASED
button
press
[Not supported by viewer]
PRESS_PENDING
PRESS_PENDING
button
release
button<br>release
timeout
timeout
notify
button
press
[Not supported by viewer]
RELEASE_DELAYED
RELEASE_DELAYED
yes
yes
timeout
short
timeout<br>short
button
press
[Not supported by viewer]
set
timer
[Not supported by viewer]
set
timer
[Not supported by viewer]
set short
timer
set short<br>timer
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
timeout
timeout
notify
button
press
[Not supported by viewer]
other
button
[Not supported by viewer]
other
button
[Not supported by viewer]
notify
button
release
[Not supported by viewer]

Entry states: IS_UP, IS_DOWN

Assumption: state is stored per-button, and OTHER BUTTON events are always processed before the actual button. Stored state per button is a single bit (up/down), a single state for the state machine across the device is sufficient.

Start the state machine with IS_UP or IS_DOWN based on the button's bit, any OTHER BUTTON event will reset it to that state anyway, so the state can be re-used for the new button.

[Not supported by viewer]
other
button
[Not supported by viewer]
enable
spurious
enable<br>spurious
IS_DOWN
IS_DOWN
timeout
timeout
DISABLED
DISABLED
button
press
[Not supported by viewer]
notify
button
press
[Not supported by viewer]
button
release
button<br>release
notify
button
release
[Not supported by viewer]
other
button
[Not supported by viewer]

Entry state: DISABLED

Only set on devices that have button debouncing disabled. This state is effectively a noop, it just forwards the events as they come in and returns back to the same state.
[Not supported by viewer]
\ No newline at end of file +
IS_UP
IS_UP
button
press
button<br>press
DOWN_WAITING
DOWN_WAITING
RELEASE_PENDING
RELEASE_PENDING
timeout
timeout
notify
button
release
[Not supported by viewer]
notify
button
press
[Not supported by viewer]
IS_DOWN
IS_DOWN
button
release
button<br>release
timeout
timeout
IS_UP
IS_UP
button
release
button<br>release
button
press
button<br>press
notify
button
release
[Not supported by viewer]
RELEASE_WAITING
RELEASE_WAITING
button
press
button<br>press
timeout
timeout
MAYBE_SPURIOUS
MAYBE_SPURIOUS
button
release
button<br>release
timeout
short
timeout<br>short
spurious
enabled?
spurious<br>enabled?
no
no
timeout
short
timeout<br>short
RELEASED
RELEASED
button
press
button<br>press
PRESS_PENDING
PRESS_PENDING
button
release
button<br>release
timeout
timeout
notify
button
press
[Not supported by viewer]
RELEASE_DELAYED
RELEASE_DELAYED
yes
yes
timeout
short
timeout<br>short
button
press
button<br>press
set
timer
set<br>timer
set
timer
set<br>timer
set short
timer
set short<br>timer
other
button
other<br>button
other
button
other<br>button
other
button
other<br>button
other
button
other<br>button
other
button
other<br>button
other
button
other<br>button
timeout
timeout
notify
button
press
[Not supported by viewer]
other
button
other<br>button
other
button
other<br>button
notify
button
release
[Not supported by viewer]

Entry states: IS_UP, IS_DOWN

Assumption: state is stored per-button, and OTHER BUTTON events are always processed before the actual button. Stored state per button is a single bit (up/down), a single state for the state machine across the device is sufficient.

Start the state machine with IS_UP or IS_DOWN based on the button's bit, any OTHER BUTTON event will reset it to that state anyway, so the state can be re-used for the new button.

[Not supported by viewer]
other
button
other<br>button
enable
spurious
enable<br>spurious
IS_DOWN
IS_DOWN
timeout
timeout
DISABLED
DISABLED
button
press
button<br>press
notify
button
press
[Not supported by viewer]
button
release
button<br>release
notify
button
release
[Not supported by viewer]
other
button
other<br>button

Entry state: DISABLED

Only set on devices that have button debouncing disabled. This state is effectively a noop, it just forwards the events as they come in and returns back to the same state.
[Not supported by viewer]
notify
button
release
[Not supported by viewer]
\ No newline at end of file diff --git a/src/evdev-debounce.c b/src/evdev-debounce.c index 1da4542a..744debae 100644 --- a/src/evdev-debounce.c +++ b/src/evdev-debounce.c @@ -287,7 +287,7 @@ debounce_release_delayed_handle_event(struct fallback_dispatch *fallback, enum d log_debounce_bug(fallback, event); break; case DEBOUNCE_EVENT_TIMEOUT_SHORT: - debounce_set_state(fallback, DEBOUNCE_STATE_RELEASE_WAITING); + debounce_set_state(fallback, DEBOUNCE_STATE_RELEASED); debounce_notify_button(fallback, LIBINPUT_BUTTON_STATE_RELEASED); break;