Fixed incorrect signature reported in the CDC class bootloader for the ATMEGA32U2.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / HID.c
index f7292d7..0642ecd 100644 (file)
@@ -36,7 +36,8 @@
 #define  __INCLUDE_FROM_HID_DRIVER
 #include "HID.h"
 
-uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, uint16_t ConfigDescriptorSize,
+uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
+                                uint16_t ConfigDescriptorSize,
                                 void* ConfigDescriptorData)
 {
        uint8_t FoundEndpoints = 0;
@@ -51,7 +52,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
        do
        {
                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
-                                                                         DComp_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
+                                                                         DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
                {
                        return HID_ENUMERROR_NoHIDInterfaceFound;
                }
@@ -63,17 +64,17 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
        HIDInterfaceInfo->State.InterfaceNumber      = CurrentHIDInterface->InterfaceNumber;
        HIDInterfaceInfo->State.SupportsBootProtocol = (CurrentHIDInterface->SubClass != HID_NON_BOOT_PROTOCOL);
 
-       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
+       if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, DCOMP_HID_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
        {
                return HID_ENUMERROR_NoHIDDescriptorFound;
        }
 
-       HIDInterfaceInfo->State.HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_HID_Descriptor_t).HIDReportLength;
+       HIDInterfaceInfo->State.HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_HID_Descriptor_HID_t).HIDReportLength;
 
        while (FoundEndpoints != (HID_FOUND_DATAPIPE_IN | HID_FOUND_DATAPIPE_OUT))
        {
                if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
-                                             DComp_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
+                                             DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
                {
                        if (FoundEndpoints & HID_FOUND_DATAPIPE_IN)
                          break;
@@ -110,7 +111,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
        return HID_ENUMERROR_NoError;
 }
 
-static uint8_t DComp_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
 {
        if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
        {
@@ -124,7 +125,7 @@ static uint8_t DComp_HID_Host_NextHIDInterface(void* const CurrentDescriptor)
        return DESCRIPTOR_SEARCH_NotFound;
 }
 
-static uint8_t DComp_NextHID(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_NextHID(void* const CurrentDescriptor)
 {
        if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
          return DESCRIPTOR_SEARCH_Found;
@@ -134,7 +135,7 @@ static uint8_t DComp_NextHID(void* const CurrentDescriptor)
          return DESCRIPTOR_SEARCH_NotFound;      
 }
 
-static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
+static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)
 {
        if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
        {
@@ -153,7 +154,9 @@ static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescri
 }
 
 #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
-uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, const uint8_t ReportID, void* Buffer)
+uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
+                                   const uint8_t ReportID,
+                                   void* Buffer)
 {
        USB_ControlRequest = (USB_Request_Header_t)
        {
@@ -170,7 +173,8 @@ uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceI
 }                                                                                         
 #endif
                                                                                   
-uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, void* Buffer)
+uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,
+                               void* Buffer)
 {
        if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))
          return PIPE_READYWAIT_DeviceDisconnected;
@@ -215,13 +219,15 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
 #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
                                 const uint8_t ReportID,
 #endif
-                                void* Buffer, const uint16_t ReportSize)
+                                const uint8_t ReportType,
+                                void* Buffer,
+                                const uint16_t ReportSize)
 {
 #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
        if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))
          return false;
 
-       if (HIDInterfaceInfo->State.DeviceUsesOUTPipe)
+       if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == REPORT_ITEM_TYPE_Out))
        {
                uint8_t ErrorCode;
        
@@ -247,9 +253,9 @@ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
                        .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
                        .bRequest      = REQ_SetReport,
 #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)
-                       .wValue        = ((REPORT_ITEM_TYPE_Out + 1) << 8) | ReportID,
+                       .wValue        = ((ReportType + 1) << 8) | ReportID,
 #else
-                       .wValue        = ((REPORT_ITEM_TYPE_Out + 1) << 8),
+                       .wValue        = ((ReportType + 1) << 8),
 #endif
                        .wIndex        = HIDInterfaceInfo->State.InterfaceNumber,
                        .wLength       = ReportSize,