diff options
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.c')
-rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 79e8cf71b..30c970892 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
@@ -335,6 +335,10 @@ const PROGMEM uchar mouse_extra_hid_report[] = { | |||
335 | }; | 335 | }; |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | #ifndef SERIAL_NUMBER | ||
339 | # define SERIAL_NUMBER 0 | ||
340 | #endif | ||
341 | |||
338 | #ifndef USB_MAX_POWER_CONSUMPTION | 342 | #ifndef USB_MAX_POWER_CONSUMPTION |
339 | # define USB_MAX_POWER_CONSUMPTION 500 | 343 | # define USB_MAX_POWER_CONSUMPTION 500 |
340 | #endif | 344 | #endif |
@@ -344,6 +348,40 @@ const PROGMEM uchar mouse_extra_hid_report[] = { | |||
344 | # define USB_POLLING_INTERVAL_MS 1 | 348 | # define USB_POLLING_INTERVAL_MS 1 |
345 | #endif | 349 | #endif |
346 | 350 | ||
351 | // clang-format off | ||
352 | const PROGMEM usbStringDescriptor_t usbDescriptorStringZero = { | ||
353 | .header = { | ||
354 | .bLength = USB_STRING_LEN(1), | ||
355 | .bDescriptorType = USBDESCR_STRING | ||
356 | }, | ||
357 | .bString = {0x0409} // US English | ||
358 | }; | ||
359 | |||
360 | const PROGMEM usbStringDescriptor_t usbDescriptorStringManufacturer = { | ||
361 | .header = { | ||
362 | .bLength = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), | ||
363 | .bDescriptorType = USBDESCR_STRING | ||
364 | }, | ||
365 | .bString = LSTR(MANUFACTURER) | ||
366 | }; | ||
367 | |||
368 | const PROGMEM usbStringDescriptor_t usbDescriptorStringProduct = { | ||
369 | .header = { | ||
370 | .bLength = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), | ||
371 | .bDescriptorType = USBDESCR_STRING | ||
372 | }, | ||
373 | .bString = LSTR(PRODUCT) | ||
374 | }; | ||
375 | |||
376 | const PROGMEM usbStringDescriptor_t usbDescriptorStringSerial = { | ||
377 | .header = { | ||
378 | .bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), | ||
379 | .bDescriptorType = USBDESCR_STRING | ||
380 | }, | ||
381 | .bString = LSTR(SERIAL_NUMBER) | ||
382 | }; | ||
383 | // clang-format on | ||
384 | |||
347 | /* | 385 | /* |
348 | * Descriptor for compite device: Keyboard + Mouse | 386 | * Descriptor for compite device: Keyboard + Mouse |
349 | * | 387 | * |
@@ -457,6 +495,26 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
457 | len = sizeof(usbDescriptorConfiguration); | 495 | len = sizeof(usbDescriptorConfiguration); |
458 | break; | 496 | break; |
459 | #endif | 497 | #endif |
498 | case USBDESCR_STRING: | ||
499 | switch (rq->wValue.bytes[0]) { | ||
500 | case 0: | ||
501 | usbMsgPtr = (unsigned char *)&usbDescriptorStringZero; | ||
502 | len = usbDescriptorStringZero.header.bLength; | ||
503 | break; | ||
504 | case 1: // iManufacturer | ||
505 | usbMsgPtr = (unsigned char *)&usbDescriptorStringManufacturer; | ||
506 | len = usbDescriptorStringManufacturer.header.bLength; | ||
507 | break; | ||
508 | case 2: // iProduct | ||
509 | usbMsgPtr = (unsigned char *)&usbDescriptorStringProduct; | ||
510 | len = usbDescriptorStringProduct.header.bLength; | ||
511 | break; | ||
512 | case 3: // iSerialNumber | ||
513 | usbMsgPtr = (unsigned char *)&usbDescriptorStringSerial; | ||
514 | len = usbDescriptorStringSerial.header.bLength; | ||
515 | break; | ||
516 | } | ||
517 | break; | ||
460 | case USBDESCR_HID: | 518 | case USBDESCR_HID: |
461 | switch (rq->wValue.bytes[0]) { | 519 | switch (rq->wValue.bytes[0]) { |
462 | case 0: | 520 | case 0: |