/*\r
LUFA Library\r
- Copyright (C) Dean Camera, 2009.\r
+ Copyright (C) Dean Camera, 2010.\r
\r
dean [at] fourwalledcubicle [dot] com\r
www.fourwalledcubicle.com\r
*/\r
\r
/*\r
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, and distribute this software\r
- and its documentation for any purpose and without fee is hereby\r
- granted, provided that the above copyright notice appear in all\r
- copies and that both that the copyright notice and this\r
- permission notice and warranty disclaimer appear in supporting\r
- documentation, and that the name of the author not be used in\r
- advertising or publicity pertaining to distribution of the\r
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
software without specific, written prior permission.\r
\r
The author disclaim all warranties with regard to this\r
{\r
Endpoint_ClearSETUP(); \r
\r
- uint16_t ReportINSize;\r
- uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
+ uint16_t ReportINSize = 0;\r
+ uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
+ uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;\r
\r
memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
\r
- CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID,\r
+ CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType,\r
HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);\r
\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);\r
Endpoint_ClearOUT();\r
}\r
{\r
Endpoint_ClearSETUP();\r
\r
- HIDInterfaceInfo->State.UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000);\r
+ HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);\r
\r
Endpoint_ClearStatusStage();\r
}\r
HIDInterfaceInfo->State.IdleCount = 500;\r
\r
if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT,\r
- ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize, ENDPOINT_BANK_SINGLE)))\r
+ ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize,\r
+ HIDInterfaceInfo->Config.ReportINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE)))\r
{\r
return false;\r
}\r
if (Endpoint_IsReadWriteAllowed())\r
{\r
uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];\r
- uint8_t ReportID = 0;\r
- uint16_t ReportINSize;\r
+ uint8_t ReportID = 0;\r
+ uint16_t ReportINSize = 0;\r
\r
memset(ReportINData, 0, sizeof(ReportINData));\r
\r
- bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData, &ReportINSize);\r
-\r
- bool StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);\r
+ bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, REPORT_ITEM_TYPE_In,\r
+ ReportINData, &ReportINSize);\r
+ bool StatesChanged = false;\r
bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));\r
\r
- memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);\r
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)\r
+ {\r
+ StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);\r
+ }\r
\r
if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))\r
{\r
HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;\r
\r
+ Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber);\r
+\r
if (ReportID)\r
Endpoint_Write_Byte(ReportID);\r
\r
}\r
}\r
\r
-void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo)\r
-{\r
- if (HIDInterfaceInfo->State.IdleMSRemaining)\r
- HIDInterfaceInfo->State.IdleMSRemaining--;\r
-}\r
-\r
#endif\r