- /* Handle HID Class specific requests */\r
- switch (USB_ControlRequest.bRequest)\r
- {\r
- case REQ_GetReport:\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
- {\r
- USB_MouseReport_Data_t MouseReportData;\r
-\r
- Endpoint_ClearSETUP();\r
-\r
- /* Create the next mouse report for transmission to the host */\r
- CreateMouseReport(&MouseReportData);\r
- \r
- /* Write the report data to the control endpoint */\r
- Endpoint_Write_Control_Stream_LE(&MouseReportData, sizeof(MouseReportData));\r
- \r
- /* Clear the report data afterwards */\r
- memset(&MouseReportData, 0, sizeof(MouseReportData));\r
-\r
- /* Finalize the stream transfer to send the last packet or clear the host abort */\r
- Endpoint_ClearOUT();\r
- }\r
- \r
- break;\r
- case REQ_GetProtocol:\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
- {\r
- Endpoint_ClearSETUP();\r
- \r
- /* Write the current protocol flag to the host */\r
- Endpoint_Write_Byte(UsingReportProtocol);\r
- \r
- /* Send the flag to the host */\r
- Endpoint_ClearIN();\r
-\r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsOUTReceived()));\r
- Endpoint_ClearOUT();\r
- }\r
- \r
- break;\r
- case REQ_SetProtocol:\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
- {\r
- Endpoint_ClearSETUP();\r
- \r
- /* Set or clear the flag depending on what the host indicates that the current Protocol should be */\r
- UsingReportProtocol = (USB_ControlRequest.wValue != 0);\r
- \r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearIN();\r
- }\r
- \r
- break;\r
- case REQ_SetIdle:\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
- {\r
- Endpoint_ClearSETUP();\r
- \r
- /* Get idle period in MSB */\r
- IdleCount = (USB_ControlRequest.wValue >> 8);\r
- \r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsINReady()));\r
- Endpoint_ClearIN();\r
- }\r
- \r
- break;\r
- case REQ_GetIdle:\r
- if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
- { \r
- Endpoint_ClearSETUP();\r
- \r
- /* Write the current idle duration to the host */\r
- Endpoint_Write_Byte(IdleCount);\r
- \r
- /* Send the flag to the host */\r
- Endpoint_ClearIN();\r
-\r
- /* Acknowledge status stage */\r
- while (!(Endpoint_IsOUTReceived()));\r
- Endpoint_ClearOUT();\r
- }\r
-\r
- break;\r
- }\r