EVENT_HANDLER(USB_UnhandledControlPacket)\r
{\r
/* Handle HID Class specific requests */\r
- switch (bRequest)\r
+ switch (USB_ControlRequest.bRequest)\r
{\r
case REQ_GetReport:\r
- if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
{\r
USB_JoystickReport_Data_t JoystickReportData;\r
\r
/* Create the next HID report to send to the host */ \r
GetNextReport(&JoystickReportData);\r
-\r
- /* Ignore report type and ID number value */\r
- Endpoint_Discard_Word();\r
- \r
- /* Ignore unused Interface number value */\r
- Endpoint_Discard_Word();\r
-\r
- /* Read in the number of bytes in the report to send to the host */\r
- uint16_t wLength = Endpoint_Read_Word_LE();\r
\r
- /* If trying to send more bytes than exist to the host, clamp the value at the report size */\r
- if (wLength > sizeof(JoystickReportData))\r
- wLength = sizeof(JoystickReportData);\r
-\r
Endpoint_ClearSETUP();\r
\r
/* Write the report data to the control endpoint */\r
- Endpoint_Write_Control_Stream_LE(&JoystickReportData, wLength);\r
+ Endpoint_Write_Control_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));\r
\r
/* Finalize the stream transfer to send the last packet or clear the host abort */\r
Endpoint_ClearOUT();\r