1
0

button-debouncing.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .. _button_debouncing:
  2. ==============================================================================
  3. Button debouncing
  4. ==============================================================================
  5. Physical buttons experience wear-and-tear with usage. On some devices this
  6. can result in an effect called "contact bouncing" or "chatter". This effect
  7. can cause the button to send multiple events within a short time frame, even
  8. though the user only pressed or clicked the button once. This effect can be
  9. counteracted by "debouncing" the buttons, usually by ignoring erroneous
  10. events.
  11. libinput provides two methods of debouncing buttons, referred to as the
  12. "bounce" and "spurious" methods:
  13. - In the "bounce" method, libinput monitors hardware bouncing on button
  14. state changes, i.e. when a user clicks or releases a button. For example,
  15. if a user presses a button but the hardware generates a
  16. press-release-press sequence in quick succession, libinput ignores the
  17. release and second press event. This method is always enabled.
  18. - in the "spurious" method, libinput detects spurious releases of a button
  19. while the button is physically held down by the user. These releases are
  20. immediately followed by a press event. libinput monitors for these events
  21. and ignores the release and press event. This method is disabled by
  22. default and enables once libinput detects the first faulty event sequence.
  23. The "bounce" method guarantees that all press events are delivered
  24. immediately and most release events are delivered immediately. The
  25. "spurious" method requires that release events are delayed, libinput thus
  26. does not enable this method unless a faulty event sequence is detected. A
  27. message is printed to the log when spurious debouncing was detected.
  28. libinput's debouncing is supposed to correct hardware damage or
  29. substandard hardware. Debouncing also exists as an accessibility feature
  30. but the requirements are different. In the accessibility feature, multiple
  31. physical key presses, usually caused by involuntary muscle movement, must be
  32. filtered to only one key press. This feature must be implemented higher in
  33. the stack, libinput is limited to hardware debouncing.
  34. Below is an illustration of the button debouncing modes to show the relation
  35. of the physical button state and the application state. Where applicable, an
  36. extra line is added to show the timeouts used by libinput that
  37. affect the button state handling. The waveform's high and low states
  38. correspond to the buttons 'pressed' and 'released' states, respectively.
  39. .. figure:: button-debouncing-wave-diagram.svg
  40. :align: center
  41. Diagram illustrating button debouncing
  42. Some devices send events in bursts, erroneously triggering the button
  43. debouncing detection. Please :ref:`file a bug <reporting_bugs>` if that
  44. occurs for your device.