diff options
| author | yiancar <yiangosyiangou@cytanet.com.cy> | 2020-05-14 01:24:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-14 10:24:18 +1000 |
| commit | 632285c9820f1c8231eeb0c7dc3ace3002ba0e26 (patch) | |
| tree | 6d8ec14450013ee061456315e2673b4e962f603b | |
| parent | 805f5cb72bb04c10327b40ed0c41e3848ad9ca75 (diff) | |
| download | qmk_firmware-632285c9820f1c8231eeb0c7dc3ace3002ba0e26.tar.gz qmk_firmware-632285c9820f1c8231eeb0c7dc3ace3002ba0e26.zip | |
V-USB Interface reorder (#9090)
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.c | 140 | ||||
| -rw-r--r-- | tmk_core/protocol/vusb/vusb.h | 12 |
2 files changed, 79 insertions, 73 deletions
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index e8aed6f5d..a9f37c61b 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c | |||
| @@ -43,12 +43,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | */ | 43 | */ |
| 44 | enum usb_interfaces { | 44 | enum usb_interfaces { |
| 45 | KEYBOARD_INTERFACE = NEXT_INTERFACE, | 45 | KEYBOARD_INTERFACE = NEXT_INTERFACE, |
| 46 | #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) | 46 | // It is important that the Raw HID interface is at a constant |
| 47 | MOUSE_EXTRA_INTERFACE = NEXT_INTERFACE, | 47 | // interface number, to support Linux/OSX platforms and chrome.hid |
| 48 | #endif | 48 | // If Raw HID is enabled, let it be always 1. |
| 49 | #ifdef RAW_ENABLE | 49 | #ifdef RAW_ENABLE |
| 50 | RAW_INTERFACE = NEXT_INTERFACE, | 50 | RAW_INTERFACE = NEXT_INTERFACE, |
| 51 | #endif | 51 | #endif |
| 52 | #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) | ||
| 53 | MOUSE_EXTRA_INTERFACE = NEXT_INTERFACE, | ||
| 54 | #endif | ||
| 52 | #ifdef CONSOLE_ENABLE | 55 | #ifdef CONSOLE_ENABLE |
| 53 | CONSOLE_INTERFACE = NEXT_INTERFACE, | 56 | CONSOLE_INTERFACE = NEXT_INTERFACE, |
| 54 | #endif | 57 | #endif |
| @@ -404,6 +407,29 @@ const PROGMEM uchar keyboard_hid_report[] = { | |||
| 404 | 0xC0 // End Collection | 407 | 0xC0 // End Collection |
| 405 | }; | 408 | }; |
| 406 | 409 | ||
| 410 | #ifdef RAW_ENABLE | ||
| 411 | const PROGMEM uchar raw_hid_report[] = { | ||
| 412 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) | ||
| 413 | 0x09, 0x61, // Usage (Vendor Defined) | ||
| 414 | 0xA1, 0x01, // Collection (Application) | ||
| 415 | // Data to host | ||
| 416 | 0x09, 0x62, // Usage (Vendor Defined) | ||
| 417 | 0x15, 0x00, // Logical Minimum (0) | ||
| 418 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | ||
| 419 | 0x95, RAW_BUFFER_SIZE, // Report Count | ||
| 420 | 0x75, 0x08, // Report Size (8) | ||
| 421 | 0x81, 0x02, // Input (Data, Variable, Absolute) | ||
| 422 | // Data from host | ||
| 423 | 0x09, 0x63, // Usage (Vendor Defined) | ||
| 424 | 0x15, 0x00, // Logical Minimum (0) | ||
| 425 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | ||
| 426 | 0x95, RAW_BUFFER_SIZE, // Report Count | ||
| 427 | 0x75, 0x08, // Report Size (8) | ||
| 428 | 0x91, 0x02, // Output (Data, Variable, Absolute) | ||
| 429 | 0xC0 // End Collection | ||
| 430 | }; | ||
| 431 | #endif | ||
| 432 | |||
| 407 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | 433 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
| 408 | const PROGMEM uchar mouse_extra_hid_report[] = { | 434 | const PROGMEM uchar mouse_extra_hid_report[] = { |
| 409 | # ifdef MOUSE_ENABLE | 435 | # ifdef MOUSE_ENABLE |
| @@ -488,29 +514,6 @@ const PROGMEM uchar mouse_extra_hid_report[] = { | |||
| 488 | }; | 514 | }; |
| 489 | #endif | 515 | #endif |
| 490 | 516 | ||
| 491 | #ifdef RAW_ENABLE | ||
| 492 | const PROGMEM uchar raw_hid_report[] = { | ||
| 493 | 0x06, 0x60, 0xFF, // Usage Page (Vendor Defined) | ||
| 494 | 0x09, 0x61, // Usage (Vendor Defined) | ||
| 495 | 0xA1, 0x01, // Collection (Application) | ||
| 496 | // Data to host | ||
| 497 | 0x09, 0x62, // Usage (Vendor Defined) | ||
| 498 | 0x15, 0x00, // Logical Minimum (0) | ||
| 499 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | ||
| 500 | 0x95, RAW_BUFFER_SIZE, // Report Count | ||
| 501 | 0x75, 0x08, // Report Size (8) | ||
| 502 | 0x81, 0x02, // Input (Data, Variable, Absolute) | ||
| 503 | // Data from host | ||
| 504 | 0x09, 0x63, // Usage (Vendor Defined) | ||
| 505 | 0x15, 0x00, // Logical Minimum (0) | ||
| 506 | 0x26, 0xFF, 0x00, // Logical Maximum (255) | ||
| 507 | 0x95, RAW_BUFFER_SIZE, // Report Count | ||
| 508 | 0x75, 0x08, // Report Size (8) | ||
| 509 | 0x91, 0x02, // Output (Data, Variable, Absolute) | ||
| 510 | 0xC0 // End Collection | ||
| 511 | }; | ||
| 512 | #endif | ||
| 513 | |||
| 514 | #if defined(CONSOLE_ENABLE) | 517 | #if defined(CONSOLE_ENABLE) |
| 515 | const PROGMEM uchar console_hid_report[] = { | 518 | const PROGMEM uchar console_hid_report[] = { |
| 516 | 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible) | 519 | 0x06, 0x31, 0xFF, // Usage Page (Vendor Defined - PJRC Teensy compatible) |
| @@ -657,88 +660,91 @@ const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = { | |||
| 657 | .bInterval = USB_POLLING_INTERVAL_MS | 660 | .bInterval = USB_POLLING_INTERVAL_MS |
| 658 | }, | 661 | }, |
| 659 | 662 | ||
| 660 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | 663 | # if defined(RAW_ENABLE) |
| 661 | /* | 664 | /* |
| 662 | * Mouse/Extrakeys | 665 | * RAW HID |
| 663 | */ | 666 | */ |
| 664 | .mouseExtraInterface = { | 667 | .rawInterface = { |
| 665 | .header = { | 668 | .header = { |
| 666 | .bLength = sizeof(usbInterfaceDescriptor_t), | 669 | .bLength = sizeof(usbInterfaceDescriptor_t), |
| 667 | .bDescriptorType = USBDESCR_INTERFACE | 670 | .bDescriptorType = USBDESCR_INTERFACE |
| 668 | }, | 671 | }, |
| 669 | .bInterfaceNumber = MOUSE_EXTRA_INTERFACE, | 672 | .bInterfaceNumber = RAW_INTERFACE, |
| 670 | .bAlternateSetting = 0x00, | 673 | .bAlternateSetting = 0x00, |
| 671 | .bNumEndpoints = 1, | 674 | .bNumEndpoints = 2, |
| 672 | .bInterfaceClass = 0x03, | 675 | .bInterfaceClass = 0x03, |
| 673 | .bInterfaceSubClass = 0x00, | 676 | .bInterfaceSubClass = 0x00, |
| 674 | .bInterfaceProtocol = 0x00, | 677 | .bInterfaceProtocol = 0x00, |
| 675 | .iInterface = 0x00 | 678 | .iInterface = 0x00 |
| 676 | }, | 679 | }, |
| 677 | .mouseExtraHID = { | 680 | .rawHID = { |
| 678 | .header = { | 681 | .header = { |
| 679 | .bLength = sizeof(usbHIDDescriptor_t), | 682 | .bLength = sizeof(usbHIDDescriptor_t), |
| 680 | .bDescriptorType = USBDESCR_HID | 683 | .bDescriptorType = USBDESCR_HID |
| 681 | }, | 684 | }, |
| 682 | .bcdHID = 0x0101, | 685 | .bcdHID = 0x0101, |
| 683 | .bCountryCode = 0x00, | 686 | .bCountryCode = 0x00, |
| 684 | .bNumDescriptors = 1, | 687 | .bNumDescriptors = 2, |
| 685 | .bDescriptorType = USBDESCR_HID_REPORT, | 688 | .bDescriptorType = USBDESCR_HID_REPORT, |
| 686 | .wDescriptorLength = sizeof(mouse_extra_hid_report) | 689 | .wDescriptorLength = sizeof(raw_hid_report) |
| 687 | }, | 690 | }, |
| 688 | .mouseExtraINEndpoint = { | 691 | .rawINEndpoint = { |
| 689 | .header = { | 692 | .header = { |
| 690 | .bLength = sizeof(usbEndpointDescriptor_t), | 693 | .bLength = sizeof(usbEndpointDescriptor_t), |
| 691 | .bDescriptorType = USBDESCR_ENDPOINT | 694 | .bDescriptorType = USBDESCR_ENDPOINT |
| 692 | }, | 695 | }, |
| 693 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER), | 696 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER), |
| 694 | .bmAttributes = 0x03, | 697 | .bmAttributes = 0x03, |
| 695 | .wMaxPacketSize = 8, | 698 | .wMaxPacketSize = RAW_EPSIZE, |
| 699 | .bInterval = USB_POLLING_INTERVAL_MS | ||
| 700 | }, | ||
| 701 | .rawOUTEndpoint = { | ||
| 702 | .header = { | ||
| 703 | .bLength = sizeof(usbEndpointDescriptor_t), | ||
| 704 | .bDescriptorType = USBDESCR_ENDPOINT | ||
| 705 | }, | ||
| 706 | .bEndpointAddress = (USBRQ_DIR_HOST_TO_DEVICE | USB_CFG_EP3_NUMBER), | ||
| 707 | .bmAttributes = 0x03, | ||
| 708 | .wMaxPacketSize = RAW_EPSIZE, | ||
| 696 | .bInterval = USB_POLLING_INTERVAL_MS | 709 | .bInterval = USB_POLLING_INTERVAL_MS |
| 697 | }, | 710 | }, |
| 698 | # endif | 711 | # endif |
| 699 | # if defined(RAW_ENABLE) | 712 | # if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) |
| 700 | .rawInterface = { | 713 | /* |
| 714 | * Mouse/Extrakeys | ||
| 715 | */ | ||
| 716 | .mouseExtraInterface = { | ||
| 701 | .header = { | 717 | .header = { |
| 702 | .bLength = sizeof(usbInterfaceDescriptor_t), | 718 | .bLength = sizeof(usbInterfaceDescriptor_t), |
| 703 | .bDescriptorType = USBDESCR_INTERFACE | 719 | .bDescriptorType = USBDESCR_INTERFACE |
| 704 | }, | 720 | }, |
| 705 | .bInterfaceNumber = RAW_INTERFACE, | 721 | .bInterfaceNumber = MOUSE_EXTRA_INTERFACE, |
| 706 | .bAlternateSetting = 0x00, | 722 | .bAlternateSetting = 0x00, |
| 707 | .bNumEndpoints = 2, | 723 | .bNumEndpoints = 1, |
| 708 | .bInterfaceClass = 0x03, | 724 | .bInterfaceClass = 0x03, |
| 709 | .bInterfaceSubClass = 0x00, | 725 | .bInterfaceSubClass = 0x00, |
| 710 | .bInterfaceProtocol = 0x00, | 726 | .bInterfaceProtocol = 0x00, |
| 711 | .iInterface = 0x00 | 727 | .iInterface = 0x00 |
| 712 | }, | 728 | }, |
| 713 | .rawHID = { | 729 | .mouseExtraHID = { |
| 714 | .header = { | 730 | .header = { |
| 715 | .bLength = sizeof(usbHIDDescriptor_t), | 731 | .bLength = sizeof(usbHIDDescriptor_t), |
| 716 | .bDescriptorType = USBDESCR_HID | 732 | .bDescriptorType = USBDESCR_HID |
| 717 | }, | 733 | }, |
| 718 | .bcdHID = 0x0101, | 734 | .bcdHID = 0x0101, |
| 719 | .bCountryCode = 0x00, | 735 | .bCountryCode = 0x00, |
| 720 | .bNumDescriptors = 2, | 736 | .bNumDescriptors = 1, |
| 721 | .bDescriptorType = USBDESCR_HID_REPORT, | 737 | .bDescriptorType = USBDESCR_HID_REPORT, |
| 722 | .wDescriptorLength = sizeof(raw_hid_report) | 738 | .wDescriptorLength = sizeof(mouse_extra_hid_report) |
| 723 | }, | 739 | }, |
| 724 | .rawINEndpoint = { | 740 | .mouseExtraINEndpoint = { |
| 725 | .header = { | 741 | .header = { |
| 726 | .bLength = sizeof(usbEndpointDescriptor_t), | 742 | .bLength = sizeof(usbEndpointDescriptor_t), |
| 727 | .bDescriptorType = USBDESCR_ENDPOINT | 743 | .bDescriptorType = USBDESCR_ENDPOINT |
| 728 | }, | 744 | }, |
| 729 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER), | 745 | .bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER), |
| 730 | .bmAttributes = 0x03, | 746 | .bmAttributes = 0x03, |
| 731 | .wMaxPacketSize = RAW_EPSIZE, | 747 | .wMaxPacketSize = 8, |
| 732 | .bInterval = USB_POLLING_INTERVAL_MS | ||
| 733 | }, | ||
| 734 | .rawOUTEndpoint = { | ||
| 735 | .header = { | ||
| 736 | .bLength = sizeof(usbEndpointDescriptor_t), | ||
| 737 | .bDescriptorType = USBDESCR_ENDPOINT | ||
| 738 | }, | ||
| 739 | .bEndpointAddress = (USBRQ_DIR_HOST_TO_DEVICE | USB_CFG_EP3_NUMBER), | ||
| 740 | .bmAttributes = 0x03, | ||
| 741 | .wMaxPacketSize = RAW_EPSIZE, | ||
| 742 | .bInterval = USB_POLLING_INTERVAL_MS | 748 | .bInterval = USB_POLLING_INTERVAL_MS |
| 743 | }, | 749 | }, |
| 744 | # endif | 750 | # endif |
| @@ -841,18 +847,18 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 841 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.keyboardHID; | 847 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.keyboardHID; |
| 842 | len = sizeof(usbHIDDescriptor_t); | 848 | len = sizeof(usbHIDDescriptor_t); |
| 843 | break; | 849 | break; |
| 844 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 845 | case MOUSE_EXTRA_INTERFACE: | ||
| 846 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.mouseExtraHID; | ||
| 847 | len = sizeof(usbHIDDescriptor_t); | ||
| 848 | break; | ||
| 849 | #endif | ||
| 850 | #if defined(RAW_ENABLE) | 850 | #if defined(RAW_ENABLE) |
| 851 | case RAW_INTERFACE: | 851 | case RAW_INTERFACE: |
| 852 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.rawHID; | 852 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.rawHID; |
| 853 | len = sizeof(usbHIDDescriptor_t); | 853 | len = sizeof(usbHIDDescriptor_t); |
| 854 | break; | 854 | break; |
| 855 | #endif | 855 | #endif |
| 856 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 857 | case MOUSE_EXTRA_INTERFACE: | ||
| 858 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.mouseExtraHID; | ||
| 859 | len = sizeof(usbHIDDescriptor_t); | ||
| 860 | break; | ||
| 861 | #endif | ||
| 856 | #if defined(CONSOLE_ENABLE) | 862 | #if defined(CONSOLE_ENABLE) |
| 857 | case CONSOLE_INTERFACE: | 863 | case CONSOLE_INTERFACE: |
| 858 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.consoleHID; | 864 | usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.consoleHID; |
| @@ -868,18 +874,18 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) { | |||
| 868 | usbMsgPtr = (unsigned char *)keyboard_hid_report; | 874 | usbMsgPtr = (unsigned char *)keyboard_hid_report; |
| 869 | len = sizeof(keyboard_hid_report); | 875 | len = sizeof(keyboard_hid_report); |
| 870 | break; | 876 | break; |
| 871 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 872 | case MOUSE_EXTRA_INTERFACE: | ||
| 873 | usbMsgPtr = (unsigned char *)mouse_extra_hid_report; | ||
| 874 | len = sizeof(mouse_extra_hid_report); | ||
| 875 | break; | ||
| 876 | #endif | ||
| 877 | #if defined(RAW_ENABLE) | 877 | #if defined(RAW_ENABLE) |
| 878 | case RAW_INTERFACE: | 878 | case RAW_INTERFACE: |
| 879 | usbMsgPtr = (unsigned char *)raw_hid_report; | 879 | usbMsgPtr = (unsigned char *)raw_hid_report; |
| 880 | len = sizeof(raw_hid_report); | 880 | len = sizeof(raw_hid_report); |
| 881 | break; | 881 | break; |
| 882 | #endif | 882 | #endif |
| 883 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 884 | case MOUSE_EXTRA_INTERFACE: | ||
| 885 | usbMsgPtr = (unsigned char *)mouse_extra_hid_report; | ||
| 886 | len = sizeof(mouse_extra_hid_report); | ||
| 887 | break; | ||
| 888 | #endif | ||
| 883 | #if defined(CONSOLE_ENABLE) | 889 | #if defined(CONSOLE_ENABLE) |
| 884 | case CONSOLE_INTERFACE: | 890 | case CONSOLE_INTERFACE: |
| 885 | usbMsgPtr = (unsigned char *)console_hid_report; | 891 | usbMsgPtr = (unsigned char *)console_hid_report; |
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index 96471433c..828960fc3 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h | |||
| @@ -89,12 +89,6 @@ typedef struct usbConfigurationDescriptor { | |||
| 89 | usbHIDDescriptor_t keyboardHID; | 89 | usbHIDDescriptor_t keyboardHID; |
| 90 | usbEndpointDescriptor_t keyboardINEndpoint; | 90 | usbEndpointDescriptor_t keyboardINEndpoint; |
| 91 | 91 | ||
| 92 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 93 | usbInterfaceDescriptor_t mouseExtraInterface; | ||
| 94 | usbHIDDescriptor_t mouseExtraHID; | ||
| 95 | usbEndpointDescriptor_t mouseExtraINEndpoint; | ||
| 96 | #endif | ||
| 97 | |||
| 98 | #if defined(RAW_ENABLE) | 92 | #if defined(RAW_ENABLE) |
| 99 | usbInterfaceDescriptor_t rawInterface; | 93 | usbInterfaceDescriptor_t rawInterface; |
| 100 | usbHIDDescriptor_t rawHID; | 94 | usbHIDDescriptor_t rawHID; |
| @@ -102,6 +96,12 @@ typedef struct usbConfigurationDescriptor { | |||
| 102 | usbEndpointDescriptor_t rawOUTEndpoint; | 96 | usbEndpointDescriptor_t rawOUTEndpoint; |
| 103 | #endif | 97 | #endif |
| 104 | 98 | ||
| 99 | #if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) | ||
| 100 | usbInterfaceDescriptor_t mouseExtraInterface; | ||
| 101 | usbHIDDescriptor_t mouseExtraHID; | ||
| 102 | usbEndpointDescriptor_t mouseExtraINEndpoint; | ||
| 103 | #endif | ||
| 104 | |||
| 105 | #if defined(CONSOLE_ENABLE) | 105 | #if defined(CONSOLE_ENABLE) |
| 106 | usbInterfaceDescriptor_t consoleInterface; | 106 | usbInterfaceDescriptor_t consoleInterface; |
| 107 | usbHIDDescriptor_t consoleHID; | 107 | usbHIDDescriptor_t consoleHID; |
