nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
hid_report_keyboard.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef _HID_REPORT_KEYBOARD_H_
8#define _HID_REPORT_KEYBOARD_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/* Keyboard report uses 8 bytes for input and 1 byte for output.
15 * Input bytes:
16 * 8 bits - pressed modifier buttons bitmask
17 * 8 bits - reserved
18 * 6 x 8 bits - 6 slots for pressed key ids
19 *
20 * Output bytes:
21 * 8 bits - active LED indicators bitmask
22 */
23#define REPORT_SIZE_KEYBOARD_KEYS 8 /* bytes */
24#define REPORT_SIZE_KEYBOARD_LEDS 1 /* bytes */
25
26/* nRF Desktop's keyboard keys report uses the same format as boot keyboard reports. */
27#define REPORT_SIZE_KEYBOARD_BOOT REPORT_SIZE_KEYBOARD_KEYS
28
29/* Report mask marks which bytes should are absolute and should be stored. */
30#define REPORT_MASK_KEYBOARD_KEYS {} /* Store the whole report */
31
32
33#define KEYBOARD_REPORT_LAST_KEY 0x65 /* Keyboard Application */
34#define KEYBOARD_REPORT_FIRST_MODIFIER 0xE0 /* Keyboard Left Ctrl */
35#define KEYBOARD_REPORT_LAST_MODIFIER 0xE7 /* Keyboard Right GUI */
36#define KEYBOARD_REPORT_KEY_COUNT_MAX 6
37
38
39#define REPORT_MAP_KEYBOARD(report_id_keys, report_id_leds) \
40 \
41 /* Report: Keyboard Keys (input) */ \
42 0x85, report_id_keys, \
43 \
44 /* Keyboard - Modifiers */ \
45 0x05, USAGE_PAGE_KEYBOARD, \
46 0x19, KEYBOARD_REPORT_FIRST_MODIFIER, /* Usage Minimum */ \
47 0x29, KEYBOARD_REPORT_LAST_MODIFIER, /* Usage Maximum */ \
48 0x15, 0x00, /* Logical Minimum (0) */ \
49 0x25, 0x01, /* Logical Maximum (1) */ \
50 0x75, 0x01, /* Report Size (1) */ \
51 0x95, 0x08, /* Report Count (8) */ \
52 0x81, 0x02, /* Input (Data, Variable, Absolute) */ \
53 \
54 /* Keyboard - Reserved */ \
55 0x75, 0x08, /* Report Size (8) */ \
56 0x95, 0x01, /* Report Count (1) */ \
57 0x81, 0x01, /* Input (Constant) */ \
58 \
59 /* Keyboard - Keys */ \
60 0x05, USAGE_PAGE_KEYBOARD, \
61 0x19, 0x00, /* Usage Minimum (0) */ \
62 0x29, KEYBOARD_REPORT_LAST_KEY, /* Usage Maximum */ \
63 0x15, 0x00, /* Logical Minimum (0) */ \
64 0x25, KEYBOARD_REPORT_LAST_KEY, /* Logical Maximum */ \
65 0x75, 0x08, /* Report Size (8) */ \
66 0x95, KEYBOARD_REPORT_KEY_COUNT_MAX, /* Report Count */ \
67 0x81, 0x00, /* Input (Data, Array) */ \
68 \
69 /* Report: Keyboard LEDS (output) */ \
70 0x85, report_id_leds, \
71 \
72 /* Keyboard - LEDs */ \
73 0x05, USAGE_PAGE_LEDS, \
74 0x19, 0x01, /* Usage Minimum (1) */ \
75 0x29, 0x05, /* Usage Maximum (5) */ \
76 0x15, 0x00, /* Logical Minimum (0) */ \
77 0x25, 0x01, /* Logical Maximum (1) */ \
78 0x95, 0x05, /* Report Count (5) */ \
79 0x75, 0x01, /* Report Size (1) */ \
80 0x91, 0x02, /* Output (Data, Variable, Absolute) */ \
81 \
82 /* Keyboard - LEDs padding */ \
83 0x95, 0x01, /* Report Count (1) */ \
84 0x75, 0x03, /* Report Size (3) (padding) */ \
85 0x91, 0x01 /* Output (Constant, Array, Absolute) */
86
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif /* _HID_REPORT_KEYBOARD_H_ */