Skip to content

Commit b549770

Browse files
MarekPietarlubos
authored andcommitted
applications: nrf_desktop: Move Fn key ID related macros
The Fn key ID related macros are specific to nRF Desktop and should be introduced by application specific header. Jira: NCSDK-13155 Signed-off-by: Marek Pieta <[email protected]>
1 parent 3db6da7 commit b549770

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2022 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef _FN_KEY_ID_H_
8+
#define _FN_KEY_ID_H_
9+
10+
#include <sys/util.h>
11+
#include <caf/key_id.h>
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
#define _FN_POS (_COL_POS + _COL_SIZE)
18+
#define _FN_BIT BIT(_FN_POS)
19+
20+
#define FN_KEY_ID(_col, _row) (KEY_ID(_col, _row) | _FN_BIT)
21+
#define IS_FN_KEY(_keyid) ((_FN_BIT & _keyid) != 0)
22+
23+
#ifdef __cplusplus
24+
}
25+
#endif
26+
27+
#endif /* _FN_KEY_ID_H_ */

applications/nrf_desktop/configuration/nrf52kbd_nrf52832/hid_keymap_def.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7-
#include "hid_keymap.h"
87
#include <caf/key_id.h>
98

9+
#include "hid_keymap.h"
10+
#include "fn_key_id.h"
11+
1012
/* This configuration file is included only once from hid_state module and holds
1113
* information about mapping between buttons and generated reports.
1214
*/

applications/nrf_desktop/doc/hid_state.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ For example, the file contents should look like the following:
4848

4949
.. code-block:: c
5050
51-
#include "hid_keymap.h"
5251
#include <caf/key_id.h>
5352
53+
#include "hid_keymap.h"
54+
#inclue "fn_key_id.h"
55+
5456
static const struct hid_keymap hid_keymap[] = {
5557
{ KEY_ID(0x00, 0x01), 0x0014, REPORT_ID_KEYBOARD_KEYS }, /* Q */
5658
{ KEY_ID(0x00, 0x02), 0x001A, REPORT_ID_KEYBOARD_KEYS }, /* W */

applications/nrf_desktop/src/modules/fn_keys.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <caf/key_id.h>
1717

18+
#include "fn_key_id.h"
1819
#include "fn_keys_def.h"
1920

2021
#include <logging/log.h>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ nRF Desktop
9393
* Updated:
9494

9595
* Documentation and diagrams for the Bluetooth LE bond internal module.
96+
* Moved Fn key related macros to an application specific header file (:file:`configuration/common/fn_key_id.h`).
9697

9798
Samples
9899
=======

include/caf/key_id.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ extern "C" {
1818
#define _ROW_SIZE 7ul
1919
#define _COL_POS (_ROW_POS + _ROW_SIZE)
2020
#define _COL_SIZE 7ul
21-
#define _FN_POS (_COL_POS + _COL_SIZE)
2221

23-
#define _FN_BIT BIT(_FN_POS)
2422
#define _COL_BITS(_col) ((_col & BIT_MASK(_COL_SIZE)) << _COL_POS)
2523
#define _ROW_BITS(_row) ((_row & BIT_MASK(_ROW_SIZE)) << _ROW_POS)
2624

@@ -30,11 +28,6 @@ extern "C" {
3028
#define KEY_COL(_keyid) ((_keyid >> _COL_POS) & BIT_MASK(_COL_SIZE))
3129
#define KEY_ROW(_keyid) ((_keyid >> _ROW_POS) & BIT_MASK(_ROW_SIZE))
3230

33-
#if defined(CONFIG_DESKTOP_FN_KEYS_ENABLE)
34-
#define FN_KEY_ID(_col, _row) (KEY_ID(_col, _row) | _FN_BIT)
35-
#define IS_FN_KEY(_keyid) ((_FN_BIT & _keyid) != 0)
36-
#endif
37-
3831
#ifdef __cplusplus
3932
}
4033
#endif

0 commit comments

Comments
 (0)