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 for CLICK_SHORT, but too short for CLICK_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

Buttons module

button_event

click_detector

Button simulator module

Function key module

Source modules for module_state_event

module_state_event

Power manager module

power_down_event

Buttons module

wake_up_event

HID forward module

Motion module

Power manager module

Wheel module

click_event

Bluetooth LE bond module

module_state_event

Sink modules for module_state_event

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 the button_event with the given click_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.