aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/vusb/vusb.c
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2020-02-12 17:19:39 +1100
committerGitHub <noreply@github.com>2020-02-12 17:19:39 +1100
commiteaf32621aa0c067b2cab203e5e8e58c7c07a4ff4 (patch)
tree11220345d3692208129d317097af6d18c07afb78 /tmk_core/protocol/vusb/vusb.c
parentf318d6fffcda102b9063effb5403598d4bbf1213 (diff)
downloadqmk_firmware-eaf32621aa0c067b2cab203e5e8e58c7c07a4ff4.tar.gz
qmk_firmware-eaf32621aa0c067b2cab203e5e8e58c7c07a4ff4.zip
Align VUSB HID descriptors with LUFA/ChibiOS (#7675)
* Align VUSB HID descriptors with LUFA/ChibiOS * Wrap send_system and send_consumer in ifdefs too * Offset system usages to match LUFA/ChibiOS
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.c')
-rw-r--r--tmk_core/protocol/vusb/vusb.c247
1 files changed, 127 insertions, 120 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index 110b3069b..7c1f4ca7f 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -112,6 +112,7 @@ static void send_mouse(report_mouse_t *report) {
112 } 112 }
113} 113}
114 114
115#ifdef EXTRAKEY_ENABLE
115static void send_extra(uint8_t report_id, uint16_t data) { 116static void send_extra(uint8_t report_id, uint16_t data) {
116 static uint8_t last_id = 0; 117 static uint8_t last_id = 0;
117 static uint16_t last_data = 0; 118 static uint16_t last_data = 0;
@@ -124,10 +125,19 @@ static void send_extra(uint8_t report_id, uint16_t data) {
124 usbSetInterrupt3((void *)&report, sizeof(report)); 125 usbSetInterrupt3((void *)&report, sizeof(report));
125 } 126 }
126} 127}
128#endif
127 129
128static void send_system(uint16_t data) { send_extra(REPORT_ID_SYSTEM, data); } 130static void send_system(uint16_t data) {
131#ifdef EXTRAKEY_ENABLE
132 send_extra(REPORT_ID_SYSTEM, data - SYSTEM_POWER_DOWN + 1);
133#endif
134}
129 135
130static void send_consumer(uint16_t data) { send_extra(REPORT_ID_CONSUMER, data); } 136static void send_consumer(uint16_t data) {
137#ifdef EXTRAKEY_ENABLE
138 send_extra(REPORT_ID_CONSUMER, data);
139#endif
140}
131 141
132/*------------------------------------------------------------------* 142/*------------------------------------------------------------------*
133 * Request from host * 143 * Request from host *
@@ -200,128 +210,125 @@ uchar usbFunctionWrite(uchar *data, uchar len) {
200 * Descriptors * 210 * Descriptors *
201 *------------------------------------------------------------------*/ 211 *------------------------------------------------------------------*/
202 212
203/*
204 * Report Descriptor for keyboard
205 *
206 * from an example in HID spec appendix
207 */
208const PROGMEM uchar keyboard_hid_report[] = { 213const PROGMEM uchar keyboard_hid_report[] = {
209 0x05, 0x01, // Usage Page (Generic Desktop), 214 0x05, 0x01, // Usage Page (Generic Desktop)
210 0x09, 0x06, // Usage (Keyboard), 215 0x09, 0x06, // Usage (Keyboard)
211 0xA1, 0x01, // Collection (Application), 216 0xA1, 0x01, // Collection (Application)
212 0x75, 0x01, // Report Size (1), 217 // Modifiers (8 bits)
213 0x95, 0x08, // Report Count (8), 218 0x05, 0x07, // Usage Page (Keyboard/Keypad)
214 0x05, 0x07, // Usage Page (Key Codes), 219 0x19, 0xE0, // Usage Minimum (Keyboard Left Control)
215 0x19, 0xE0, // Usage Minimum (224), 220 0x29, 0xE7, // Usage Maximum (Keyboard Right GUI)
216 0x29, 0xE7, // Usage Maximum (231), 221 0x15, 0x00, // Logical Minimum (0)
217 0x15, 0x00, // Logical Minimum (0), 222 0x25, 0x01, // Logical Maximum (1)
218 0x25, 0x01, // Logical Maximum (1), 223 0x95, 0x08, // Report Count (8)
219 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte 224 0x75, 0x01, // Report Size (1)
220 0x95, 0x01, // Report Count (1), 225 0x81, 0x02, // Input (Data, Variable, Absolute)
221 0x75, 0x08, // Report Size (8), 226 // Reserved (1 byte)
222 0x81, 0x03, // Input (Constant), ;Reserved byte 227 0x95, 0x01, // Report Count (1)
223 0x95, 0x05, // Report Count (5), 228 0x75, 0x08, // Report Size (8)
224 0x75, 0x01, // Report Size (1), 229 0x81, 0x03, // Input (Constant)
225 0x05, 0x08, // Usage Page (LEDs), 230 // Keycodes (6 bytes)
226 0x19, 0x01, // Usage Minimum (1), 231 0x05, 0x07, // Usage Page (Keyboard/Keypad)
227 0x29, 0x05, // Usage Maximum (5), 232 0x19, 0x00, // Usage Minimum (0)
228 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report 233 0x29, 0xFF, // Usage Maximum (255)
229 0x95, 0x01, // Report Count (1), 234 0x15, 0x00, // Logical Minimum (0)
230 0x75, 0x03, // Report Size (3), 235 0x26, 0xFF, 0x00, // Logical Maximum (255)
231 0x91, 0x03, // Output (Constant), ;LED report padding 236 0x95, 0x06, // Report Count (6)
232 0x95, 0x06, // Report Count (6), 237 0x75, 0x08, // Report Size (8)
233 0x75, 0x08, // Report Size (8), 238 0x81, 0x00, // Input (Data, Array, Absolute)
234 0x15, 0x00, // Logical Minimum (0), 239
235 0x26, 0xFF, 0x00, // Logical Maximum(255), 240 // Status LEDs (5 bits)
236 0x05, 0x07, // Usage Page (Key Codes), 241 0x05, 0x08, // Usage Page (LED)
237 0x19, 0x00, // Usage Minimum (0), 242 0x19, 0x01, // Usage Minimum (Num Lock)
238 0x29, 0xFF, // Usage Maximum (255), 243 0x29, 0x05, // Usage Maximum (Kana)
239 0x81, 0x00, // Input (Data, Array), 244 0x95, 0x05, // Report Count (5)
240 0xc0 // End Collection 245 0x75, 0x01, // Report Size (1)
246 0x91, 0x02, // Output (Data, Variable, Absolute)
247 // LED padding (3 bits)
248 0x95, 0x01, // Report Count (1)
249 0x75, 0x03, // Report Size (3)
250 0x91, 0x03, // Output (Constant)
251 0xC0 // End Collection
241}; 252};
242 253
243/*
244 * Report Descriptor for mouse
245 *
246 * Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension
247 * http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521
248 * http://www.keil.com/forum/15671/
249 * http://www.microsoft.com/whdc/device/input/wheel.mspx
250 */
251const PROGMEM uchar mouse_hid_report[] = { 254const PROGMEM uchar mouse_hid_report[] = {
252 /* mouse */ 255 // Mouse report descriptor
253 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 256 0x05, 0x01, // Usage Page (Generic Desktop)
254 0x09, 0x02, // USAGE (Mouse) 257 0x09, 0x02, // Usage (Mouse)
255 0xa1, 0x01, // COLLECTION (Application) 258 0xA1, 0x01, // Collection (Application)
256 0x85, REPORT_ID_MOUSE, // REPORT_ID (1) 259 0x85, REPORT_ID_MOUSE, // Report ID
257 0x09, 0x01, // USAGE (Pointer) 260 0x09, 0x01, // Usage (Pointer)
258 0xa1, 0x00, // COLLECTION (Physical) 261 0xA1, 0x00, // Collection (Physical)
259 // ---------------------------- Buttons 262 // Buttons (5 bits)
260 0x05, 0x09, // USAGE_PAGE (Button) 263 0x05, 0x09, // Usage Page (Button)
261 0x19, 0x01, // USAGE_MINIMUM (Button 1) 264 0x19, 0x01, // Usage Minimum (Button 1)
262 0x29, 0x05, // USAGE_MAXIMUM (Button 5) 265 0x29, 0x05, // Usage Maximum (Button 5)
263 0x15, 0x00, // LOGICAL_MINIMUM (0) 266 0x15, 0x00, // Logical Minimum (0)
264 0x25, 0x01, // LOGICAL_MAXIMUM (1) 267 0x25, 0x01, // Logical Maximum (1)
265 0x75, 0x01, // REPORT_SIZE (1) 268 0x95, 0x05, // Report Count (5)
266 0x95, 0x05, // REPORT_COUNT (5) 269 0x75, 0x01, // Report Size (1)
267 0x81, 0x02, // INPUT (Data,Var,Abs) 270 0x81, 0x02, // Input (Data, Variable, Absolute)
268 0x75, 0x03, // REPORT_SIZE (3) 271 // Button padding (3 bits)
269 0x95, 0x01, // REPORT_COUNT (1) 272 0x95, 0x01, // Report Count (1)
270 0x81, 0x03, // INPUT (Cnst,Var,Abs) 273 0x75, 0x03, // Report Size (3)
271 // ---------------------------- X,Y position 274 0x81, 0x03, // Input (Constant)
272 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 275
273 0x09, 0x30, // USAGE (X) 276 // X/Y position (2 bytes)
274 0x09, 0x31, // USAGE (Y) 277 0x05, 0x01, // Usage Page (Generic Desktop)
275 0x15, 0x81, // LOGICAL_MINIMUM (-127) 278 0x09, 0x30, // Usage (X)
276 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 279 0x09, 0x31, // Usage (Y)
277 0x75, 0x08, // REPORT_SIZE (8) 280 0x15, 0x81, // Logical Minimum (-127)
278 0x95, 0x02, // REPORT_COUNT (2) 281 0x25, 0x7F, // Logical Maximum (127)
279 0x81, 0x06, // INPUT (Data,Var,Rel) 282 0x95, 0x02, // Report Count (2)
280 // ---------------------------- Vertical wheel 283 0x75, 0x08, // Report Size (8)
281 0x09, 0x38, // USAGE (Wheel) 284 0x81, 0x06, // Input (Data, Variable, Relative)
282 0x15, 0x81, // LOGICAL_MINIMUM (-127) 285
283 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 286 // Vertical wheel (1 byte)
284 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical 287 0x09, 0x38, // Usage (Wheel)
285 0x45, 0x00, // PHYSICAL_MAXIMUM (0) 288 0x15, 0x81, // Logical Minimum (-127)
286 0x75, 0x08, // REPORT_SIZE (8) 289 0x25, 0x7F, // Logical Maximum (127)
287 0x95, 0x01, // REPORT_COUNT (1) 290 0x95, 0x01, // Report Count (1)
288 0x81, 0x06, // INPUT (Data,Var,Rel) 291 0x75, 0x08, // Report Size (8)
289 // ---------------------------- Horizontal wheel 292 0x81, 0x06, // Input (Data, Variable, Relative)
290 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) 293 // Horizontal wheel (1 byte)
291 0x0a, 0x38, 0x02, // USAGE (AC Pan) 294 0x05, 0x0C, // Usage Page (Consumer)
292 0x15, 0x81, // LOGICAL_MINIMUM (-127) 295 0x0A, 0x38, 0x02, // Usage (AC Pan)
293 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 296 0x15, 0x81, // Logical Minimum (-127)
294 0x75, 0x08, // REPORT_SIZE (8) 297 0x25, 0x7F, // Logical Maximum (127)
295 0x95, 0x01, // REPORT_COUNT (1) 298 0x95, 0x01, // Report Count (1)
296 0x81, 0x06, // INPUT (Data,Var,Rel) 299 0x75, 0x08, // Report Size (8)
297 0xc0, // END_COLLECTION 300 0x81, 0x06, // Input (Data, Variable, Relative)
298 0xc0, // END_COLLECTION 301 0xC0, // End Collection
299 /* system control */ 302 0xC0, // End Collection
300 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 303
301 0x09, 0x80, // USAGE (System Control) 304#ifdef EXTRAKEY_ENABLE
302 0xa1, 0x01, // COLLECTION (Application) 305 // Extrakeys report descriptor
303 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) 306 0x05, 0x01, // Usage Page (Generic Desktop)
304 0x15, 0x01, // LOGICAL_MINIMUM (0x1) 307 0x09, 0x80, // Usage (System Control)
305 0x26, 0xb7, 0x00, // LOGICAL_MAXIMUM (0xb7) 308 0xA1, 0x01, // Collection (Application)
306 0x19, 0x01, // USAGE_MINIMUM (0x1) 309 0x85, REPORT_ID_SYSTEM, // Report ID
307 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) 310 0x1A, 0x81, 0x00, // Usage Minimum (System Power Down)
308 0x75, 0x10, // REPORT_SIZE (16) 311 0x2A, 0x83, 0x00, // Usage Maximum (System Wake Up)
309 0x95, 0x01, // REPORT_COUNT (1) 312 0x16, 0x01, 0x00, // Logical Minimum
310 0x81, 0x00, // INPUT (Data,Array,Abs) 313 0x26, 0x03, 0x00, // Logical Maximum
311 0xc0, // END_COLLECTION 314 0x95, 0x01, // Report Count (1)
312 /* consumer */ 315 0x75, 0x10, // Report Size (16)
313 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) 316 0x81, 0x00, // Input (Data, Array, Absolute)
314 0x09, 0x01, // USAGE (Consumer Control) 317 0xC0, // End Collection
315 0xa1, 0x01, // COLLECTION (Application) 318
316 0x85, REPORT_ID_CONSUMER, // REPORT_ID (3) 319 0x05, 0x0C, // Usage Page (Consumer)
317 0x15, 0x01, // LOGICAL_MINIMUM (0x1) 320 0x09, 0x01, // Usage (Consumer Control)
318 0x26, 0x9c, 0x02, // LOGICAL_MAXIMUM (0x29c) 321 0xA1, 0x01, // Collection (Application)
319 0x19, 0x01, // USAGE_MINIMUM (0x1) 322 0x85, REPORT_ID_CONSUMER, // Report ID
320 0x2a, 0x9c, 0x02, // USAGE_MAXIMUM (0x29c) 323 0x1A, 0x01, 0x00, // Usage Minimum (Consumer Control)
321 0x75, 0x10, // REPORT_SIZE (16) 324 0x2A, 0x9C, 0x02, // Usage Maximum (AC Distribute Vertically)
322 0x95, 0x01, // REPORT_COUNT (1) 325 0x16, 0x01, 0x00, // Logical Minimum
323 0x81, 0x00, // INPUT (Data,Array,Abs) 326 0x26, 0x9C, 0x02, // Logical Maximum
324 0xc0, // END_COLLECTION 327 0x95, 0x01, // Report Count (1)
328 0x75, 0x10, // Report Size (16)
329 0x81, 0x00, // Input (Data, Array, Absolute)
330 0xC0 // End Collection
331#endif
325}; 332};
326 333
327#ifndef USB_MAX_POWER_CONSUMPTION 334#ifndef USB_MAX_POWER_CONSUMPTION