@@ -31,29 +31,28 @@ int HID_::getInterface(uint8_t* interfaceCount)
3131{
3232 *interfaceCount += 1 ; // uses 1
3333 HIDDescriptor hidInterface = {
34- D_INTERFACE (interface () , 1 , 3 , 0 , 0 ),
34+ D_INTERFACE (pluggedInterface , 1 , 3 , 0 , 0 ),
3535 D_HIDREPORT (descriptorSize),
36- D_ENDPOINT (USB_ENDPOINT_IN (endpoint () ), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01 )
36+ D_ENDPOINT (USB_ENDPOINT_IN (pluggedEndpoint ), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01 )
3737 };
3838 return USB_SendControl (0 , &hidInterface, sizeof (hidInterface));
3939}
4040
41- int HID_::getDescriptor (int8_t type )
41+ int HID_::getDescriptor (USBSetup& setup )
4242{
43- if (HID_REPORT_DESCRIPTOR_TYPE == type) {
44- int total = 0 ;
45- HIDDescriptorListNode* node;
46- for (node = rootNode; node; node = node->next ) {
47- int res = USB_SendControl (TRANSFER_PGM, node->data , node->length );
48- if (res == -1 )
49- return -1 ;
50- total += res;
51- }
52- return total;
43+ if (pluggedInterface != setup.wIndex ) {
44+ return 0 ;
5345 }
5446
55- // Ignored
56- return 0 ;
47+ int total = 0 ;
48+ HIDDescriptorListNode* node;
49+ for (node = rootNode; node; node = node->next ) {
50+ int res = USB_SendControl (TRANSFER_PGM, node->data , node->length );
51+ if (res == -1 )
52+ return -1 ;
53+ total += res;
54+ }
55+ return total;
5756}
5857
5958void HID_::AppendDescriptor (HIDDescriptorListNode *node)
@@ -72,13 +71,13 @@ void HID_::AppendDescriptor(HIDDescriptorListNode *node)
7271
7372void HID_::SendReport (uint8_t id, const void * data, int len)
7473{
75- USB_Send (endpoint () , &id, 1 );
76- USB_Send (endpoint () | TRANSFER_RELEASE, data, len);
74+ USB_Send (pluggedEndpoint , &id, 1 );
75+ USB_Send (pluggedEndpoint | TRANSFER_RELEASE, data, len);
7776}
7877
79- bool HID_::setup (USBSetup& setup, uint8_t interfaceNum )
78+ bool HID_::setup (USBSetup& setup)
8079{
81- if (interface () != interfaceNum ) {
80+ if (pluggedInterface != setup. wIndex ) {
8281 return false ;
8382 }
8483
@@ -107,6 +106,9 @@ bool HID_::setup(USBSetup& setup, uint8_t interfaceNum)
107106 idle = setup.wValueL ;
108107 return true ;
109108 }
109+ if (request == HID_SET_REPORT)
110+ {
111+ }
110112 }
111113
112114 return false ;
0 commit comments