diff options
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.c | 28 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.h | 5 |
2 files changed, 17 insertions, 16 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 88bb60993..bc796464d 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -50,21 +50,20 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter { Endpoint_ClearSETUP(); - uint16_t ReportINSize = 0; - uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); - uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; - uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize]; + uint16_t ReportSize = 0; + uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); + uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; + uint8_t ReportData[HIDInterfaceInfo->Config.PrevReportINBufferSize]; - memset(ReportINData, 0, sizeof(ReportINData)); + memset(ReportData, 0, sizeof(ReportData)); - CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, - HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize); + CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, ReportData, &ReportSize); if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) - memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize); + memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, HIDInterfaceInfo->Config.PrevReportINBufferSize); Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize); + Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportSize); Endpoint_ClearOUT(); } @@ -74,12 +73,13 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter { Endpoint_ClearSETUP(); - uint16_t ReportOUTSize = USB_ControlRequest.wLength; - uint8_t ReportOUTData[ReportOUTSize]; - uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); + uint16_t ReportSize = USB_ControlRequest.wLength; + uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); + uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; + uint8_t ReportData[ReportSize]; - Endpoint_Read_Control_Stream_LE(ReportOUTData, ReportOUTSize); - CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportOUTData, ReportOUTSize); + Endpoint_Read_Control_Stream_LE(ReportData, ReportSize); + CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize); Endpoint_ClearIN(); } diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index ac6ee4cb7..9e42843d4 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -174,12 +174,13 @@ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state * \param[in] ReportID Report ID of the received output report. If multiple reports are not received via the given HID * interface, this parameter should be ignored. + * \param[in] ReportType Type of received HID report, either \ref REPORT_ITEM_TYPE_Out or \ref REPORT_ITEM_TYPE_Feature * \param[in] ReportData Pointer to a buffer where the received HID report is stored. * \param[in] ReportSize Size in bytes of the received report from the host. */ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, - const void* ReportData, const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1) - ATTR_NON_NULL_PTR_ARG(3); + const uint8_t ReportType, const void* ReportData, const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(4); /* Inline Functions: */ /** Indicates that a millisecond of idle time has elapsed on the given HID interface, and the interface's idle count should be |