1 /*
2 * Copyright (C) 2021 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holders nor the names of
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * 4. Any redistribution, use, or modification is done solely for
17 * personal benefit and not for any commercial purpose or for
18 * monetary gain.
19 *
20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * Please inquire about commercial licensing options at
34 * [email protected]
35 *
36 */
37
38 #include "btstack_hid.h"
39
40
41 // from USB HID Specification 1.1, Appendix B.1
42 const uint8_t btstack_hid_descriptor_boot_mode[] = {
43 // Keyboard
44
45 0x05, 0x01, // Usage Page (Generic Desktop)
46 0x09, 0x06, // Usage (Keyboard)
47 0xa1, 0x01, // Collection (Application)
48
49 0x85, 0x01, // Report ID 1
50
51 // Modifier byte
52
53 0x75, 0x01, // Report Size (1)
54 0x95, 0x08, // Report Count (8)
55 0x05, 0x07, // Usage Page (Key codes)
56 0x19, 0xe0, // Usage Minimum (Keyboard LeftControl)
57 0x29, 0xe7, // Usage Maxium (Keyboard Right GUI)
58 0x15, 0x00, // Logical Minimum (0)
59 0x25, 0x01, // Logical Maximum (1)
60 0x81, 0x02, // Input (Data, Variable, Absolute)
61
62 // Reserved byte
63
64 0x75, 0x01, // Report Size (1)
65 0x95, 0x08, // Report Count (8)
66 0x81, 0x03, // Input (Constant, Variable, Absolute)
67
68 // LED report + padding
69
70 0x95, 0x05, // Report Count (5)
71 0x75, 0x01, // Report Size (1)
72 0x05, 0x08, // Usage Page (LEDs)
73 0x19, 0x01, // Usage Minimum (Num Lock)
74 0x29, 0x05, // Usage Maxium (Kana)
75 0x91, 0x02, // Output (Data, Variable, Absolute)
76
77 0x95, 0x01, // Report Count (1)
78 0x75, 0x03, // Report Size (3)
79 0x91, 0x03, // Output (Constant, Variable, Absolute)
80
81 // Keycodes
82
83 0x95, 0x06, // Report Count (6)
84 0x75, 0x08, // Report Size (8)
85 0x15, 0x00, // Logical Minimum (0)
86 0x25, 0xff, // Logical Maximum (1)
87 0x05, 0x07, // Usage Page (Key codes)
88 0x19, 0x00, // Usage Minimum (Reserved (no event indicated))
89 0x29, 0xff, // Usage Maxium (Reserved)
90 0x81, 0x00, // Input (Data, Array)
91
92 0xc0, // End collection
93
94 // Mouse
95 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
96 0x09, 0x02, // USAGE (Mouse)
97 0xa1, 0x01, // COLLECTION (Application)
98
99 0x85, 0x01, // Report ID 1
100
101 0x09, 0x01, // USAGE (Pointer)
102
103 0xa1, 0x00, // COLLECTION (Physical)
104
105 #if 1
106 0x05, 0x09, // USAGE_PAGE (Button)
107 0x19, 0x01, // USAGE_MINIMUM (Button 1)
108 0x29, 0x03, // USAGE_MAXIMUM (Button 3)
109 0x15, 0x00, // LOGICAL_MINIMUM (0)
110 0x25, 0x01, // LOGICAL_MAXIMUM (1)
111 0x95, 0x03, // REPORT_COUNT (3)
112 0x75, 0x01, // REPORT_SIZE (1)
113 0x81, 0x02, // INPUT (Data,Var,Abs)
114 0x95, 0x01, // REPORT_COUNT (1)
115 0x75, 0x05, // REPORT_SIZE (5)
116 0x81, 0x03, // INPUT (Cnst,Var,Abs)
117 #endif
118
119 #if 1
120 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
121 0x09, 0x30, // USAGE (X)
122 0x09, 0x31, // USAGE (Y)
123 0x15, 0x81, // LOGICAL_MINIMUM (-127)
124 0x25, 0x7f, // LOGICAL_MAXIMUM (127)
125 0x75, 0x08, // REPORT_SIZE (8)
126 0x95, 0x02, // REPORT_COUNT (2)
127 0x81, 0x06, // INPUT (Data,Var,Rel)
128 #endif
129
130 0xc0, // END_COLLECTION
131 0xc0 // END_COLLECTION
132 };
133
btstack_hid_get_boot_descriptor_data(void)134 const uint8_t * btstack_hid_get_boot_descriptor_data(void){
135 return &btstack_hid_descriptor_boot_mode[0];
136 }
137
btstack_hid_get_boot_descriptor_len(void)138 uint16_t btstack_hid_get_boot_descriptor_len(void){
139 return sizeof(btstack_hid_descriptor_boot_mode);
140 }
141
142