X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/a2001ac1ccf4d4919c8243fbc69aff0b68973d3f..f9f1bcc25c17b031029200cd9648d76d4ee39dc4:/LUFA/Drivers/USB/Class/Host/HID.c?ds=inline diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c index a42f8afa3..f9c42b281 100644 --- a/LUFA/Drivers/USB/Class/Host/HID.c +++ b/LUFA/Drivers/USB/Class/Host/HID.c @@ -39,13 +39,15 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint16_t ConfigDescriptorSize, uint8_t* ConfigDescriptorData) { - uint8_t FoundEndpoints = 0; + uint8_t FoundEndpoints = 0; memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State)); if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) return HID_ENUMERROR_InvalidConfigDescriptor; + USB_Descriptor_Interface_t* CurrentHIDInterface; + do { if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, @@ -53,14 +55,23 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint { return HID_ENUMERROR_NoHIDInterfaceFound; } - } while (HIDInterfaceInfo->Config.MatchInterfaceProtocol && - DESCRIPTOR_PCAST(ConfigDescriptorData, - USB_Descriptor_Interface_t)->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol); - - while (FoundEndpoints != ((1 << HID_FOUND_DATAPIPE_IN) | (1 << HID_FOUND_DATAPIPE_OUT))) + + CurrentHIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + } while (HIDInterfaceInfo->Config.HIDInterfaceProtocol && + (CurrentHIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol)); + + HIDInterfaceInfo->State.InterfaceNumber = + #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) + CurrentHIDInterface->InterfaceNumber; + #else + CurrentHIDInterface->bInterfaceNumber; + #endif + HIDInterfaceInfo->State.SupportsBootSubClass = (CurrentHIDInterface->SubClass != 0); + + while (FoundEndpoints != (HID_FOUND_DATAPIPE_IN | HID_FOUND_DATAPIPE_OUT)) { if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_HID_Host_NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + DComp_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) { if (FoundEndpoints == (1 << HID_FOUND_DATAPIPE_IN)) break; @@ -74,15 +85,17 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint { Pipe_ConfigurePipe(HIDInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); + HIDInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize; - FoundEndpoints |= (1 << HID_FOUND_DATAPIPE_IN); + FoundEndpoints |= HID_FOUND_DATAPIPE_IN; } else { Pipe_ConfigurePipe(HIDInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT, EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); + HIDInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize; - FoundEndpoints |= (1 << HID_FOUND_DATAPIPE_OUT); + FoundEndpoints |= HID_FOUND_DATAPIPE_OUT; } } @@ -104,7 +117,7 @@ static uint8_t DComp_HID_Host_NextHIDInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } -static uint8_t DComp_HID_Host_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor) +static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* CurrentDescriptor) { if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) { @@ -144,4 +157,20 @@ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) return ReportReceived; } +uint8_t USB_HID_Host_SetProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool UseReportProtocol) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = REQ_SetProtocol, + .wValue = UseReportProtocol, + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + #endif