diff options
author | Ryan <fauxpark@gmail.com> | 2020-03-28 13:02:25 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 13:02:25 +1100 |
commit | 14079ce6984b359e080c85d9e9b8f7b8eb01437c (patch) | |
tree | 7da8f69e8611836197a926946204f04df0fc5140 /tmk_core/protocol/vusb/vusb.h | |
parent | 05d9a0ff036d91b7dc4e6198f4074161c1c7b633 (diff) |
V-USB: Use structs for USB descriptors (#8572)
* V-USB: Use structs for USB descriptors
* Update usbconfigs
* cformat pass
Diffstat (limited to 'tmk_core/protocol/vusb/vusb.h')
-rw-r--r-- | tmk_core/protocol/vusb/vusb.h | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index cee07207a3..debac67d24 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef VUSB_H -#define VUSB_H +#pragma once #include "host_driver.h" @@ -25,14 +24,83 @@ typedef struct usbDescriptorHeader { uchar bDescriptorType; } __attribute__((packed)) usbDescriptorHeader_t; +typedef struct usbDeviceDescriptor { + usbDescriptorHeader_t header; + unsigned bcdUSB; + uchar bDeviceClass; + uchar bDeviceSubClass; + uchar bDeviceProtocol; + uchar bMaxPacketSize0; + unsigned idVendor; + unsigned idProduct; + unsigned bcdDevice; + uchar iManufacturer; + uchar iProduct; + uchar iSerialNumber; + uchar bNumConfigurations; +} __attribute__((packed)) usbDeviceDescriptor_t; + +typedef struct usbConfigurationDescriptorHeader { + usbDescriptorHeader_t header; + unsigned wTotalLength; + uchar bNumInterfaces; + uchar bConfigurationValue; + uchar iConfiguration; + uchar bmAttributes; + uchar bMaxPower; +} __attribute__((packed)) usbConfigurationDescriptorHeader_t; + typedef struct usbStringDescriptor { usbDescriptorHeader_t header; int bString[]; } __attribute__((packed)) usbStringDescriptor_t; +typedef struct usbInterfaceDescriptor { + usbDescriptorHeader_t header; + uchar bInterfaceNumber; + uchar bAlternateSetting; + uchar bNumEndpoints; + uchar bInterfaceClass; + uchar bInterfaceSubClass; + uchar bInterfaceProtocol; + uchar iInterface; +} __attribute__((packed)) usbInterfaceDescriptor_t; + +typedef struct usbEndpointDescriptor { + usbDescriptorHeader_t header; + uchar bEndpointAddress; + uchar bmAttributes; + unsigned wMaxPacketSize; + uchar bInterval; +} __attribute__((packed)) usbEndpointDescriptor_t; + +typedef struct usbHIDDescriptor { + usbDescriptorHeader_t header; + unsigned bcdHID; + uchar bCountryCode; + uchar bNumDescriptors; + uchar bDescriptorType; + unsigned wDescriptorLength; +} __attribute__((packed)) usbHIDDescriptor_t; + +typedef struct usbConfigurationDescriptor { + usbConfigurationDescriptorHeader_t header; + usbInterfaceDescriptor_t keyboardInterface; + usbHIDDescriptor_t keyboardHID; +#ifdef USB_CFG_HAVE_INTRIN_ENDPOINT + usbEndpointDescriptor_t keyboardINEndpoint; +#endif + +#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE) + usbInterfaceDescriptor_t mouseExtraInterface; + usbHIDDescriptor_t mouseExtraHID; +# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3 + usbEndpointDescriptor_t mouseExtraINEndpoint; +# endif +#endif +} __attribute__((packed)) usbConfigurationDescriptor_t; + #define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1)) host_driver_t *vusb_driver(void); void vusb_transfer_keyboard(void); - -#endif |