Button simulator module

Use the button simulator module to generate the sequence of simulated key presses. The time between subsequent key presses is defined as a module configuration option. Generating keys can be started and stopped by pressing the predefined button.

Module events

Source Module

Input Event

This Module

Output Event

Sink Module

Buttons module

button_event

buttons_sim

Button simulator module

Function key module

Source modules for module_state_event

module_state_event

Power manager module

power_down_event

Bluetooth LE advertising module

wake_up_event

Buttons module

HID forward module

Motion module

Power manager module

Wheel module

button_event

Function key module

Motion module

Button simulator module

Click detector module

Passkey module

HID state 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

To configure the button simulator module:

  1. Enable and configure the CAF: Buttons module. button_event is used to trigger the simulated button sequence.

  2. Enable the buttons_sim module by setting the CONFIG_DESKTOP_BUTTONS_SIM_ENABLE Kconfig option.

  3. Define the output key ID sequence in the buttons_sim_def.h file located in the board-specific directory in the configuration directory. The mapping from the defined key ID to the HID report ID and usage ID is defined in hid_keymap_def.h (this might be different for different boards).

  4. Define the interval between subsequent simulated button presses (CONFIG_DESKTOP_BUTTONS_SIM_INTERVAL). One second is used by default.

If you want the sequence to automatically restart after it ends, set CONFIG_DESKTOP_BUTTONS_SIM_LOOP_FOREVER. By default, the sequence is generated only once.

Implementation details

The button simulator module generates button sequence using k_work_delayable, which resubmits itself. The work handler submits the press and the release of a single button from the sequence.

Receiving button_event with the key ID set to CONFIG_DESKTOP_BUTTONS_SIM_TRIGGER_KEY_ID either stops generating the sequence (in case it is already being generated) or starts generating it.