aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/Class/Host/HID.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-11 09:12:29 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-11 09:12:29 +0000
commitc86491af8b24679984a3fc5effc7675779652e4c (patch)
tree7709d0549ff5bc2354403c4da82574d8461f3e79 /LUFA/Drivers/USB/Class/Host/HID.c
parenta2001ac1ccf4d4919c8243fbc69aff0b68973d3f (diff)
downloadlufa-c86491af8b24679984a3fc5effc7675779652e4c.tar.gz
lufa-c86491af8b24679984a3fc5effc7675779652e4c.tar.bz2
lufa-c86491af8b24679984a3fc5effc7675779652e4c.zip
Add new functions to the HID host class driver, refine HID interface protocol matching.
Remove stray state variable from the CDC host class driver.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Host/HID.c')
-rw-r--r--LUFA/Drivers/USB/Class/Host/HID.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/HID.c b/LUFA/Drivers/USB/Class/Host/HID.c
index a42f8afa3..dc6997736 100644
--- a/LUFA/Drivers/USB/Class/Host/HID.c
+++ b/LUFA/Drivers/USB/Class/Host/HID.c
@@ -46,6 +46,8 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint
if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
return HID_ENUMERROR_InvalidConfigDescriptor;
+ USB_Descriptor_Interface_t* CurrentHIDInterface;
+
do
{
if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
@@ -53,9 +55,18 @@ 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);
+
+ 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 != ((1 << HID_FOUND_DATAPIPE_IN) | (1 << HID_FOUND_DATAPIPE_OUT)))
{
@@ -144,4 +155,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