Skip to content

Commit 1376cb4

Browse files
MarekPietakapi-no
authored andcommitted
applications: nrf_desktop: Update subscription priority in Fn keys
Change updates button_event subscription priority in the Fn keys module to let the module process the event before other application modules. Jira: NCSDK-34374 Signed-off-by: Marek Pieta <[email protected]>
1 parent d2d7781 commit 1376cb4

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

applications/nrf_desktop/doc/fn_keys.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Module events
2222
Configuration
2323
*************
2424

25-
The module uses ``button_event`` sent by :ref:`caf_buttons`.
26-
Make sure mentioned hardware interface is defined.
25+
The module uses :c:struct:`button_event` sent by :ref:`caf_buttons`.
26+
Make sure mentioned CAF module is enabled.
2727

2828
The module is enabled with :ref:`CONFIG_DESKTOP_FN_KEYS_ENABLE <config_desktop_app_options>` option.
2929

@@ -38,6 +38,9 @@ You must configure the following options:
3838
In the file :file:`fn_keys_def.h`, define all the dual-purpose keys.
3939
The ``fn_keys`` array must be sorted by key ID (the module uses binary search).
4040

41+
By default, the module subscribes for :c:struct:`button_event` as the first subscriber (:c:macro:`APP_EVENT_SUBSCRIBE_FIRST`).
42+
You can disable the :ref:`CONFIG_DESKTOP_FN_KEYS_BUTTON_EVENT_SUBSCRIBE_FIRST <config_desktop_app_options>` Kconfig option to use early subscription (:c:macro:`APP_EVENT_SUBSCRIBE_EARLY`).
43+
4144
Implementation details
4245
**********************
4346

applications/nrf_desktop/src/modules/Kconfig.fn_keys

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ config DESKTOP_FN_KEYS_MAX_ACTIVE
3838
help
3939
Maximum number of function keys pressed at the same time.
4040

41+
config DESKTOP_FN_KEYS_BUTTON_EVENT_SUBSCRIBE_FIRST
42+
bool "Subscribe for button_event as the first subscriber"
43+
default y
44+
help
45+
Subscribe for button_event as the first subscriber to handle the event
46+
before early subscribers. If the option is disabled, the module uses
47+
early subscription.
48+
49+
Make sure to keep the option enabled if other early button_event
50+
subscribers use function keys.
51+
4152
module = DESKTOP_FN_KEYS
4253
module-str = Fn keys
4354
source "subsys/logging/Kconfig.template.log_config"

applications/nrf_desktop/src/modules/fn_keys.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,9 @@ static bool app_event_handler(const struct app_event_header *aeh)
214214
}
215215

216216
APP_EVENT_LISTENER(MODULE, app_event_handler);
217+
#if CONFIG_DESKTOP_FN_KEYS_BUTTON_EVENT_SUBSCRIBE_FIRST
218+
APP_EVENT_SUBSCRIBE_FIRST(MODULE, button_event);
219+
#else
217220
APP_EVENT_SUBSCRIBE_EARLY(MODULE, button_event);
221+
#endif
218222
APP_EVENT_SUBSCRIBE(MODULE, module_state_event);

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ nRF Desktop
312312
* Improved HID subscription handling in the HID transports (:ref:`nrf_desktop_hids` and :ref:`nrf_desktop_usb_state`).
313313
Both HID transports now unsubscribe from HID input reports related to the previously used HID protocol mode before subscribing to HID input reports related to the new HID protocol mode.
314314
This change ensures that subscriptions to both HID boot and HID report protocol mode are not enabled at the same time.
315+
* The :ref:`nrf_desktop_fn_keys` to subscribe for :c:struct:`button_event` as the first subscriber (:c:macro:`APP_EVENT_SUBSCRIBE_FIRST`) by default.
316+
You can disable the :ref:`CONFIG_DESKTOP_FN_KEYS_BUTTON_EVENT_SUBSCRIBE_FIRST <config_desktop_app_options>` Kconfig option to use early subscription (:c:macro:`APP_EVENT_SUBSCRIBE_EARLY`).
315317

316318
nRF Machine Learning (Edge Impulse)
317319
-----------------------------------

0 commit comments

Comments
 (0)