#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //Joystick on EP1 for IN bulk/interrupt transfers #define USB_EP1_TX_SIZE 20 #define USB_EP_JOYSTICK 1 #define USB_EP2_TX_ENABLE USB_ENABLE_INTERRUPT //Bt_1 on EP2 for IN bulk/interrupt transfers #define USB_EP2_TX_SIZE 20 #define USB_EP_BTN_1 2 #define USB_EP3_TX_ENABLE USB_ENABLE_INTERRUPT //Bt_2 on EP4 for IN bulk/interrupt transfers #define USB_EP3_TX_SIZE 4 #define USB_EP_BTN_2 3 #define USB_EP4_RX_ENABLE USB_ENABLE_INTERRUPT //Vendor define on EP3 for OUT bulk/interrupt transfers #define USB_EP4_RX_SIZE 53 #define USB_EP_COMMAND 4 const char USB_CONFIG_DESC[] = { //IN ORDER TO COMPLY WITH WINDOWS HOSTS, THE ORDER OF THIS ARRAY MUST BE: // config(s) // interface(s) // class(es) // endpoint(s) //config_descriptor for config index 1 USB_DESC_CONFIG_LEN, //length of descriptor size ==0 USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02) ==1 USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config ==2,3 USB_NUM_HID_INTERFACES, //number of interfaces this device supports ==4 0x01, //identifier for this configuration. (IF we had more than one configurations) ==5 0x02, //index of string descriptor for this configuration ==6 0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1 ==7 0xFA, //maximum bus power required (maximum milliamperes/2) (0x32 = 100mA) ==8 7D=250mA FA=500mA //interface descriptor 1 (JOY) USB_DESC_INTERFACE_LEN, //length of descriptor ==9 USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) ==10 0x00, //number defining this interface (IF we had more than one interface) ==11 0x00, //alternate setting ==12 1, //number of endpoints for this interface ==13 0x03, //class code, 03 = HID ==14 0x00, //subclass code //boot ==15 0x00, //protocol code ==16 0x03, //index of string descriptor for interface ==17 //class descriptor 1 (JOY) USB_DESC_CLASS_LEN, //length of descriptor ==18 USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==19 0x10,0x01, //hid class release number (1.0) (try 1.10) ==20,21 0x00, //localized country code (0 = none) ==22 0x01, //number of hid class descrptors that follow (1) ==23 0x22, //report descriptor type (0x22 == HID) ==24 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor ==25,26 //endpoint descriptor 1 (JOY) USB_DESC_ENDPOINT_LEN, //length of descriptor ==27 USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==28 0x81, //endpoint number and direction (0x81 = EP1 IN) ==29 USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==30 USB_EP1_TX_SIZE,0x00, //maximum packet size supported ==31,32 50, //polling interval, in ms. (cant be smaller than 10 for slow speed devices)==33 //interface descriptor 2 (BT 1) USB_DESC_INTERFACE_LEN, //length of descriptor ==34 USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) ==35 0x01, //number defining this interface (IF we had more than one interface) ==36 0x00, //alternate setting ==37 1, //number of endpoints for this interface ==38 0x03, //class code, 03 = HID ==39 0x00, //subclass code //boot ==40 0x00, //protocol code ==41 0x04, //index of string descriptor for interface ==42 //class descriptor 2 (BT 1) USB_DESC_CLASS_LEN, //length of descriptor ==43 USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==44 0x10,0x01, //hid class release number (1.0) (try 1.10) ==45,46 0x00, //localized country code (0 = none) ==47 0x01, //number of hid class descriptors that follow (1) ==48 0x22, //report descriptor type (0x22 == HID) ==49 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][1], 0x00, //length of report descriptor ==50,51 //endpoint descriptor 2 IN (BT 1) USB_DESC_ENDPOINT_LEN, //length of descriptor ==52 USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==53 0x82, //endpoint number and direction (0x81 = EP1 IN) ==54 USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==55 USB_EP2_TX_SIZE,0x00, //maximum packet size supported ==56,57 50, //polling interval, in ms. (cant be smaller than 10 for slow speed devices)==58 //interface descriptor 3 (BT 2) USB_DESC_INTERFACE_LEN, //length of descriptor ==59 USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) ==60 0x02, //number defining this interface (IF we had more than one interface) ==61 0x00, //alternate setting ==62 1, //number of endpoints for this interface ==63 0x03, //class code, 03 = HID ==64 0x00, //subclass code //boot ==65 0x00, //protocol code ==66 0x06, //index of string descriptor for interface ==67 //class descriptor 3 (BT 2) USB_DESC_CLASS_LEN, //length of descriptor ==68 USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==69 0x10,0x01, //hid class release number (1.0) (try 1.10) ==70,71 0x00, //localized country code (0 = none) ==72 0x01, //number of hid class descriptors that follow (1) ==73 0x22, //report descriptor type (0x22 == HID) ==74 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][2], 0x00, //length of report descriptor ==75,76 //endpoint descriptor 3 IN (BT 2) USB_DESC_ENDPOINT_LEN, //length of descriptor ==77 USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==78 0x83, //endpoint number and direction (0x81 = EP1 IN) ==79 USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==80 USB_EP3_TX_SIZE,0x00, //maximum packet size supported ==81,82 50, //polling interval, in ms. (cant be smaller than 10 for slow speed devices)==83 //interface descriptor 4 (Vendor define) USB_DESC_INTERFACE_LEN, //length of descriptor ==84 USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) ==85 0x03, //number defining this interface (IF we had more than one interface) ==86 0x00, //alternate setting ==87 1, //number of endpoints for this interface ==88 0x03, //class code, 03 = HID ==89 0x00, //subclass code //boot ==90 0x00, //protocol code ==91 0x05, //index of string descriptor for interface ==92 //class descriptor 4 (vendor define) USB_DESC_CLASS_LEN, //length of descriptor ==93 USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==94 0x10,0x01, //hid class release number (1.0) (try 1.10) ==95,96 0x00, //localized country code (0 = none) ==97 0x01, //number of hid class descriptors that follow (1) ==98 0x22, //report descriptor type (0x22 == HID) ==99 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][3], 0x00, //length of report descriptor ==100,101 //endpoint descriptor 4 OUT (vendor define) USB_DESC_ENDPOINT_LEN, //length of descriptor ==102 USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==103 0x04, //endpoint number and direction (0x81 = EP1 IN) ==104 USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==105 USB_EP4_RX_SIZE,0x00, //maximum packet size supported ==106,107 100 //polling interval, in ms. (cant be smaller than 10 for slow speed devices)==108 };