Skip to content

Commit fca96de

Browse files
MarekPietanordicjm
authored andcommitted
applications: nrf_desktop: Document HID eventq utility
Change introduces documentation for HID eventq utility. Jira: NCSDK-33578 Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Divya Pillai <[email protected]>
1 parent 8f29341 commit fca96de

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _nrf_desktop_hid_eventq:
2+
3+
HID event queue utility
4+
#######################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The HID event queue utility can be used by an application module to temporarily queue HID events related to keypresses (button press or release) to handle them later.
11+
12+
Configuration
13+
*************
14+
15+
Make sure that heap size (:kconfig:option:`CONFIG_HEAP_MEM_POOL_SIZE`) is large enough to handle the worst possible use case.
16+
Data structures used to internally queue HID events are dynamically allocated using the :c:func:`k_malloc` function.
17+
When no longer needed, the structures are freed using the :c:func:`k_free` function.
18+
19+
Use the :ref:`CONFIG_DESKTOP_HID_EVENTQ <config_desktop_app_options>` Kconfig option to enable the utility.
20+
You can use the utility only on HID peripherals (:ref:`CONFIG_DESKTOP_ROLE_HID_PERIPHERAL <config_desktop_app_options>`).
21+
22+
See Kconfig help for more details.
23+
24+
Using HID event queue
25+
*********************
26+
27+
An application module that handles keypresses internally can use this utility.
28+
29+
Initialization
30+
==============
31+
32+
Initialize a utility instance before use, using the :c:func:`hid_eventq_init` function.
33+
Specify the limit of queued HID events to limit heap usage.
34+
35+
Queuing keypresses
36+
==================
37+
38+
You can use the :c:func:`hid_eventq_keypress_enqueue` function to enqueue a keypress event.
39+
You can use the :c:func:`hid_eventq_keypress_dequeue` function to get a keypress event from the queue.
40+
The keypress events are queued in FIFO (first in first out) manner.
41+
An ID is used to identify the button related to the keypress.
42+
The ID could be, for example, an application-specific identifier of a hardware button or HID usage ID.
43+
44+
You can use the :c:func:`hid_eventq_is_full` and :c:func:`hid_eventq_is_empty` functions, respectively, to determine if the queue is full or empty.
45+
46+
Clearing the queue
47+
==================
48+
49+
You can use the :c:func:`hid_eventq_reset` function to reset the queue.
50+
Resetting the queue results in dropping all of the enqueued keypresses.
51+
52+
You can use the :c:func:`hid_eventq_cleanup` to remove stale keypresses (with timestamp lower than the provided minimal valid timestamp).
53+
54+
API documentation
55+
*****************
56+
57+
Application modules can use the following API of the HID event queue:
58+
59+
| Header file: :file:`applications/nrf_desktop/src/util/hid_eventq.h`
60+
| Source file: :file:`applications/nrf_desktop/src/util/hid_eventq.c`
61+
62+
.. doxygengroup:: hid_eventq

applications/nrf_desktop/utils.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ More information about each utility and its configuration details is available o
1616

1717
doc/config_channel.rst
1818
doc/dfu_lock.rst
19+
doc/hid_eventq.rst
1920
doc/hid_reportq.rst

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ nRF5340 Audio
227227
nRF Desktop
228228
-----------
229229

230+
* Added the :ref:`nrf_desktop_hid_eventq`.
231+
The utility can be used by an application module to temporarily queue HID events related to keypresses (button press or release) to handle them later.
232+
230233
* Updated:
231234

232235
* Application configurations for dongles on memory-limited SoCs (nRF52820) to reuse the system workqueue for GATT Discovery Manager (:kconfig:option:`CONFIG_BT_GATT_DM_WORKQ_SYS`).

0 commit comments

Comments
 (0)