Click detector module¶
The click detector module is used to send a click_event
when a known type of click is recorded for the button defined in the module configuration.
Click type¶
The module records the following click types:
CLICK_SHORT
- Button pressed and released after short time.CLICK_NONE
- Button pressed and held for a period of time that is too long forCLICK_SHORT
, but too short forCLICK_LONG
.CLICK_LONG
- Button pressed and held for a long period of time.CLICK_DOUBLE
- Two sequences of the button press and release in a short time interval.
The exact values of time intervals for click types are defined in the click_detector.c
file.
Module events¶
Source Module |
Input Event |
This Module |
Output Event |
Sink Module |
---|---|---|---|---|
|
|
|||
|
||||
|
||||
|
||||
|
||||
|
Note
See the Overview: Firmware architecture for more information about the event-based communication in the nRF Desktop application and about how to read this table.
Configuration¶
The click detector module detects click types based on button_event
.
Make sure you define the Buttons module hardware interface.
Set CONFIG_DESKTOP_CLICK_DETECTOR_ENABLE
and define the module configuration.
The configuration (array of click_detector_config
) is written in the click_detector_def.h`
file located in the board-specific directory in the application configuration directory.
For every click detector, make sure to define the following information:
click_detector_config.key_id
- ID of the selected key.click_detector_config.consume_button_event
- Whether thebutton_event
with the givenclick_detector_config.key_id
should be consumed by the module.
Implementation details¶
Tracing of key states is implemented using a periodically submitted work (k_delayed_work
).
The work updates the states of traced keys and sends click_event
.
The work is not submitted if there is no key for which the state should be updated.