diff options
| author | Ryan <fauxpark@gmail.com> | 2020-03-27 00:11:32 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-26 13:11:32 +0000 |
| commit | 4d76d85d7bef735a56f9e1e275c89f4beaf52a64 (patch) | |
| tree | 7aaace6286075a2130828d8900a217618fdc9ef8 /tmk_core/protocol/vusb | |
| parent | 981ea87b05b18756e79475b6aa576a4515008960 (diff) | |
| download | qmk_firmware-4d76d85d7bef735a56f9e1e275c89f4beaf52a64.tar.gz qmk_firmware-4d76d85d7bef735a56f9e1e275c89f4beaf52a64.zip | |
V-USB: Use manufacturer and product strings from config.h (#7797)
* V-USB: Use manufacturer and product strings from config.h
* Update board configs
Diffstat (limited to 'tmk_core/protocol/vusb')
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 58 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.h | 12 |
2 files changed, 70 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: |
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index 7e3f8c394..cee07207a 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h | |||
| @@ -20,6 +20,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | #include "host_driver.h" | 21 | #include "host_driver.h" |
| 22 | 22 | ||
| 23 | typedef struct usbDescriptorHeader { | ||
| 24 | uchar bLength; | ||
| 25 | uchar bDescriptorType; | ||
| 26 | } __attribute__((packed)) usbDescriptorHeader_t; | ||
| 27 | |||
| 28 | typedef struct usbStringDescriptor { | ||
| 29 | usbDescriptorHeader_t header; | ||
| 30 | int bString[]; | ||
| 31 | } __attribute__((packed)) usbStringDescriptor_t; | ||
| 32 | |||
| 33 | #define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1)) | ||
| 34 | |||
| 23 | host_driver_t *vusb_driver(void); | 35 | host_driver_t *vusb_driver(void); |
| 24 | void vusb_transfer_keyboard(void); | 36 | void vusb_transfer_keyboard(void); |
| 25 | 37 | ||
