]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/arm_atsam/usb/usb_protocol_hid.h
Massdrop keyboard support (#3780)
[qmk_firmware.git] / tmk_core / protocol / arm_atsam / usb / usb_protocol_hid.h
1 /**
2  * \file
3  *
4  * \brief USB Human Interface Device (HID) protocol definitions.
5  *
6  * Copyright (c) 2009-2015 Atmel Corporation. All rights reserved.
7  *
8  * \asf_license_start
9  *
10  * \page License
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  *    this list of conditions and the following disclaimer.
17  *
18  * 2. Redistributions in binary form must reproduce the above copyright notice,
19  *    this list of conditions and the following disclaimer in the documentation
20  *    and/or other materials provided with the distribution.
21  *
22  * 3. The name of Atmel may not be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * 4. This software may only be redistributed and used in connection with an
26  *    Atmel microcontroller product.
27  *
28  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  *
40  * \asf_license_stop
41  *
42  */
43 /*
44  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
45  */
46
47 #ifndef _USB_PROTOCOL_HID_H_
48 #define _USB_PROTOCOL_HID_H_
49
50 /**
51  * \ingroup usb_protocol_group
52  * \defgroup usb_hid_protocol USB Human Interface Device (HID)
53  * protocol definitions
54  * \brief USB Human Interface Device (HID) protocol definitions
55  *
56  * @{
57  */
58
59 //! \name Possible Class value
60 //@{
61 #define  HID_CLASS                            0x03
62 //@}
63
64 //! \name Possible SubClass value
65 //@{
66 //! Interface subclass NO support BOOT protocol
67 #define  HID_SUB_CLASS_NOBOOT                 0x00
68 //! Interface subclass support BOOT protocol
69 #define  HID_SUB_CLASS_BOOT                   0x01
70 //@}
71
72 //! \name Possible protocol value
73 //@{
74 //! Protocol generic standard
75 #define  HID_PROTOCOL_GENERIC                 0x00
76 //! Protocol keyboard standard
77 #define  HID_PROTOCOL_KEYBOARD                0x01
78 //! Protocol mouse standard
79 #define  HID_PROTOCOL_MOUSE                   0x02
80 //@}
81
82
83 //! \brief Hid USB requests (bRequest)
84 enum usb_reqid_hid {
85     USB_REQ_HID_GET_REPORT = 0x01,
86     USB_REQ_HID_GET_IDLE = 0x02,
87     USB_REQ_HID_GET_PROTOCOL = 0x03,
88     USB_REQ_HID_SET_REPORT = 0x09,
89     USB_REQ_HID_SET_IDLE = 0x0A,
90     USB_REQ_HID_SET_PROTOCOL = 0x0B,
91 };
92
93 //! \brief HID USB descriptor types
94 enum usb_descriptor_type_hid {
95     USB_DT_HID = 0x21,
96     USB_DT_HID_REPORT = 0x22,
97     USB_DT_HID_PHYSICAL = 0x23,
98 };
99
100 //! \brief HID Type for report descriptor
101 enum usb_hid_item_report_type {
102     USB_HID_ITEM_REPORT_TYPE_MAIN = 0,
103     USB_HID_ITEM_REPORT_TYPE_GLOBAL = 1,
104     USB_HID_ITEM_REPORT_TYPE_LOCAL = 2,
105     USB_HID_ITEM_REPORT_TYPE_LONG = 3,
106 };
107
108 //! \brief HID report type
109 enum usb_hid_report_type {
110     USB_HID_REPORT_TYPE_INPUT = 1,
111     USB_HID_REPORT_TYPE_OUTPUT = 2,
112     USB_HID_REPORT_TYPE_FEATURE = 3,
113 };
114
115
116 //! \brief HID protocol
117 enum usb_hid_protocol {
118     USB_HID_PROCOTOL_BOOT = 0,
119     USB_HID_PROCOTOL_REPORT = 1,
120 };
121
122 COMPILER_PACK_SET(1)
123
124 //! \brief HID Descriptor
125 typedef struct {
126     uint8_t bLength;          //!< Size of this descriptor in bytes
127     uint8_t bDescriptorType;  //!< HID descriptor type
128     le16_t bcdHID;            //!< Binary Coded Decimal Spec. release
129     uint8_t bCountryCode;     //!< Hardware target country
130     uint8_t bNumDescriptors;  //!< Number of HID class descriptors to follow
131     uint8_t bRDescriptorType; //!< Report descriptor type
132     le16_t wDescriptorLength; //!< Total length of Report descriptor
133 } usb_hid_descriptor_t;
134
135 COMPILER_PACK_RESET()
136
137    //! \name HID Report type
138    //! Used by SETUP_HID_GET_REPORT & SETUP_HID_SET_REPORT
139    //! @{
140 #define  REPORT_TYPE_INPUT                    0x01
141 #define  REPORT_TYPE_OUTPUT                   0x02
142 #define  REPORT_TYPE_FEATURE                  0x03
143    //! @}
144
145    //! \name Constants of field DESCRIPTOR_HID
146    //! @{
147 //! Numeric expression identifying the HID Class
148 //! Specification release (here V1.11)
149 #define  USB_HID_BDC_V1_11                    0x0111
150 //! Numeric expression specifying the number of class descriptors
151 //! Note: Always at least one i.e. Report descriptor.
152 #define  USB_HID_NUM_DESC                     0x01
153
154       //! \name Country code
155       //! @{
156 #define  USB_HID_NO_COUNTRY_CODE            0   // Not Supported
157 #define  USB_HID_COUNTRY_ARABIC             1   // Arabic
158 #define  USB_HID_COUNTRY_BELGIAN            2   // Belgian
159 #define  USB_HID_COUNTRY_CANADIAN_BILINGUAL 3   // Canadian-Bilingual
160 #define  USB_HID_COUNTRY_CANADIAN_FRENCH    4   // Canadian-French
161 #define  USB_HID_COUNTRY_CZECH_REPUBLIC     5   // Czech Republic
162 #define  USB_HID_COUNTRY_DANISH             6   // Danish
163 #define  USB_HID_COUNTRY_FINNISH            7   // Finnish
164 #define  USB_HID_COUNTRY_FRENCH             8   // French
165 #define  USB_HID_COUNTRY_GERMAN             9   // German
166 #define  USB_HID_COUNTRY_GREEK              10  // Greek
167 #define  USB_HID_COUNTRY_HEBREW             11  // Hebrew
168 #define  USB_HID_COUNTRY_HUNGARY            12  // Hungary
169 #define  USB_HID_COUNTRY_INTERNATIONAL_ISO  13  // International (ISO)
170 #define  USB_HID_COUNTRY_ITALIAN            14  // Italian
171 #define  USB_HID_COUNTRY_JAPAN_KATAKANA     15  // Japan (Katakana)
172 #define  USB_HID_COUNTRY_KOREAN             16  // Korean
173 #define  USB_HID_COUNTRY_LATIN_AMERICAN     17  // Latin American
174 #define  USB_HID_COUNTRY_NETHERLANDS_DUTCH  18  // Netherlands/Dutch
175 #define  USB_HID_COUNTRY_NORWEGIAN          19  // Norwegian
176 #define  USB_HID_COUNTRY_PERSIAN_FARSI      20  // Persian (Farsi)
177 #define  USB_HID_COUNTRY_POLAND             21  // Poland
178 #define  USB_HID_COUNTRY_PORTUGUESE         22  // Portuguese
179 #define  USB_HID_COUNTRY_RUSSIA             23  // Russia
180 #define  USB_HID_COUNTRY_SLOVAKIA           24  // Slovakia
181 #define  USB_HID_COUNTRY_SPANISH            25  // Spanish
182 #define  USB_HID_COUNTRY_SWEDISH            26  // Swedish
183 #define  USB_HID_COUNTRY_SWISS_FRENCH       27  // Swiss/French
184 #define  USB_HID_COUNTRY_SWISS_GERMAN       28  // Swiss/German
185 #define  USB_HID_COUNTRY_SWITZERLAND        29  // Switzerland
186 #define  USB_HID_COUNTRY_TAIWAN             30  // Taiwan
187 #define  USB_HID_COUNTRY_TURKISH_Q          31  // Turkish-Q
188 #define  USB_HID_COUNTRY_UK                 32  // UK
189 #define  USB_HID_COUNTRY_US                 33  // US
190 #define  USB_HID_COUNTRY_YUGOSLAVIA         34  // Yugoslavia
191 #define  USB_HID_COUNTRY_TURKISH_F          35  // Turkish-F
192       //! @}
193    //! @}
194 //! @}
195
196
197 //! \name HID KEYS values
198 //! @{
199 #define  HID_A                0x04
200 #define  HID_B                0x05
201 #define  HID_C                0x06
202 #define  HID_D                0x07
203 #define  HID_E                0x08
204 #define  HID_F                0x09
205 #define  HID_G                0x0A
206 #define  HID_H                0x0B
207 #define  HID_I                0x0C
208 #define  HID_J                0x0D
209 #define  HID_K                0x0E
210 #define  HID_L                0x0F
211 #define  HID_M                0x10
212 #define  HID_N                0x11
213 #define  HID_O                0x12
214 #define  HID_P                0x13
215 #define  HID_Q                0x14
216 #define  HID_R                0x15
217 #define  HID_S                0x16
218 #define  HID_T                0x17
219 #define  HID_U                0x18
220 #define  HID_V                0x19
221 #define  HID_W                0x1A
222 #define  HID_X                0x1B
223 #define  HID_Y                0x1C
224 #define  HID_Z                0x1D
225 #define  HID_1                30
226 #define  HID_2                31
227 #define  HID_3                32
228 #define  HID_4                33
229 #define  HID_5                34
230 #define  HID_6                35
231 #define  HID_7                36
232 #define  HID_8                37
233 #define  HID_9                38
234 #define  HID_0                39
235 #define  HID_ENTER            40
236 #define  HID_ESCAPE           41
237 #define  HID_BACKSPACE        42
238 #define  HID_TAB              43
239 #define  HID_SPACEBAR         44
240 #define  HID_UNDERSCORE       45
241 #define  HID_PLUS             46
242 #define  HID_OPEN_BRACKET     47 // {
243 #define  HID_CLOSE_BRACKET    48 // }
244 #define  HID_BACKSLASH        49
245 #define  HID_ASH              50 // # ~
246 #define  HID_COLON            51 // ; :
247 #define  HID_QUOTE            52 // ' "
248 #define  HID_TILDE            53
249 #define  HID_COMMA            54
250 #define  HID_DOT              55
251 #define  HID_SLASH            56
252 #define  HID_CAPS_LOCK        57
253 #define  HID_F1               58
254 #define  HID_F2               59
255 #define  HID_F3               60
256 #define  HID_F4               61
257 #define  HID_F5               62
258 #define  HID_F6               63
259 #define  HID_F7               64
260 #define  HID_F8               65
261 #define  HID_F9               66
262 #define  HID_F10              67
263 #define  HID_F11              68
264 #define  HID_F12              69
265 #define  HID_PRINTSCREEN      70
266 #define  HID_SCROLL_LOCK      71
267 #define  HID_PAUSE            72
268 #define  HID_INSERT           73
269 #define  HID_HOME             74
270 #define  HID_PAGEUP           75
271 #define  HID_DELETE           76
272 #define  HID_END              77
273 #define  HID_PAGEDOWN         78
274 #define  HID_RIGHT            79
275 #define  HID_LEFT             80
276 #define  HID_DOWN             81
277 #define  HID_UP               82
278 #define  HID_KEYPAD_NUM_LOCK  83
279 #define  HID_KEYPAD_DIVIDE    84
280 #define  HID_KEYPAD_AT        85
281 #define  HID_KEYPAD_MULTIPLY  85
282 #define  HID_KEYPAD_MINUS     86
283 #define  HID_KEYPAD_PLUS      87
284 #define  HID_KEYPAD_ENTER     88
285 #define  HID_KEYPAD_1         89
286 #define  HID_KEYPAD_2         90
287 #define  HID_KEYPAD_3         91
288 #define  HID_KEYPAD_4         92
289 #define  HID_KEYPAD_5         93
290 #define  HID_KEYPAD_6         94
291 #define  HID_KEYPAD_7         95
292 #define  HID_KEYPAD_8         96
293 #define  HID_KEYPAD_9         97
294 #define  HID_KEYPAD_0         98
295
296    //! \name HID modifier values
297    //! @{
298 #define  HID_MODIFIER_NONE          0x00
299 #define  HID_MODIFIER_LEFT_CTRL     0x01
300 #define  HID_MODIFIER_LEFT_SHIFT    0x02
301 #define  HID_MODIFIER_LEFT_ALT      0x04
302 #define  HID_MODIFIER_LEFT_UI       0x08
303 #define  HID_MODIFIER_RIGHT_CTRL    0x10
304 #define  HID_MODIFIER_RIGHT_SHIFT   0x20
305 #define  HID_MODIFIER_RIGHT_ALT     0x40
306 #define  HID_MODIFIER_RIGHT_UI      0x80
307    //! @}
308 //! @}
309
310 //! \name HID KEYS values
311 //! @{
312 #define  HID_LED_NUM_LOCK           (1<<0)
313 #define  HID_LED_CAPS_LOCK          (1<<1)
314 #define  HID_LED_SCROLL_LOCK        (1<<2)
315 #define  HID_LED_COMPOSE            (1<<3)
316 #define  HID_LED_KANA               (1<<4)
317 //! @}
318
319 #endif // _USB_PROTOCOL_HID_H_