Selector module

The selector module is used to send selector_event that informs about the current selector state. The module has one implementation, which uses hardware selectors (selector_hw.c).

Module events

Source Module

Input Event

This Module

Output Event

Sink Module

Source modules for module_state_event



Power manager module


Bluetooth LE advertising module


Buttons module

HID forward module

Motion module

Power manager module

Wheel module


Sink modules for module_state_event


Bluetooth LE bond module


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.


The module implemented in selector_hw.c uses the Zephyr GPIO driver to check the state of hardware selectors. For this reason, you should set CONFIG_GPIO option.

Set CONFIG_DESKTOP_SELECTOR_HW_ENABLE option to enable the module. The configuration for this module is an array of selector_config pointers. The array is written in the selector_hw_def.h file located in the board-specific directory in the application configuration directory.

For every hardware selector, define the following parameters:

  • - ID of the hardware selector.

  • selector_config.pins - Pointer to the array of gpio_pin.

  • selector_config.pins_size - Size of the array of gpio_pin.


Each source of selector_event must have a unique ID to properly distinguish events from different sources.

Implementation details

The selector_event that the module sends to inform about the current hardware selector state is sent on the following occasions:

  • System start or wakeup (for every defined selector).

  • Selector state change when the application is running (only for the selector that changed state).

When the application goes to sleep, selectors are not informing about the state change (interrupts are disabled).

If a selector is placed between states, it is in unknown state and selector_event is not sent.

Recording of selector state changes is implemented using GPIO callbacks (gpio_callback) and work (k_work_delayable). Each state change triggers an interrupt (GPIO interrupt for pin level high). Callback of an interrupt submits work, which sends selector_event.