\r
#include "GenericHID.h"\r
\r
+/** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another.\r
\r
.ReportINEndpointNumber = GENERIC_IN_EPNUM,\r
.ReportINEndpointSize = GENERIC_EPSIZE,\r
+ \r
+ .PrevReportINBuffer = PrevHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),\r
},\r
};\r
\r
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
* \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
// Create generic HID report here\r
\r
- return 0;\r
+ *ReportSize = 0;\r
+ return true;\r
}\r
\r
/** HID class driver callback function for the processing of HID reports from the host.\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r
\r
#include "Joystick.h"\r
\r
+/** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another.\r
\r
.ReportINEndpointNumber = JOYSTICK_EPNUM,\r
.ReportINEndpointSize = JOYSTICK_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevJoystickHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevJoystickHIDReportBuffer),\r
},\r
};\r
\r
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
* \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;\r
\r
if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
JoystickReport->Button |= (1 << 0);\r
\r
- return sizeof(USB_JoystickReport_Data_t);\r
+ *ReportSize = sizeof(USB_JoystickReport_Data_t);\r
+ return false;\r
}\r
\r
/** HID class driver callback function for the processing of HID reports from the host.\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateNextHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessReceivedHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, const uint8_t ReportID, \r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r
\r
#include "Keyboard.h"\r
\r
+/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another.\r
\r
.ReportINEndpointNumber = KEYBOARD_EPNUM,\r
.ReportINEndpointSize = KEYBOARD_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevKeyboardHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),\r
},\r
};\r
\r
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
* \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
\r
\r
if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
KeyboardReport->KeyCode[0] = 0x09; // F\r
- \r
- return sizeof(USB_KeyboardReport_Data_t);\r
+ \r
+ *ReportSize = sizeof(USB_KeyboardReport_Data_t);\r
+ return false;\r
}\r
\r
/** HID class driver callback function for the processing of HID reports from the host.\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r
\r
#include "KeyboardMouse.h"\r
\r
+/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];\r
+\r
+/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another. This is for the keyboard HID\r
\r
.ReportINEndpointNumber = KEYBOARD_IN_EPNUM,\r
.ReportINEndpointSize = HID_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevKeyboardHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),\r
},\r
};\r
\r
\r
.ReportINEndpointNumber = MOUSE_IN_EPNUM,\r
.ReportINEndpointSize = HID_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevMouseHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),\r
}, \r
};\r
\r
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
* \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
\r
if (JoyStatus_LCL & JOY_PRESS)\r
KeyboardReport->KeyCode[0] = 0x08; // E\r
- \r
- return sizeof(USB_KeyboardReport_Data_t);\r
+ \r
+ *ReportSize = sizeof(USB_KeyboardReport_Data_t);\r
+ return false;\r
}\r
else\r
{\r
if (JoyStatus_LCL & JOY_PRESS)\r
MouseReport->Button = (1 << 0);\r
\r
- return sizeof(USB_MouseReport_Data_t); \r
+ *ReportSize = sizeof(USB_MouseReport_Data_t);\r
+ return true; \r
}\r
}\r
\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r
\r
#include "Mouse.h"\r
\r
+/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another.\r
\r
.ReportINEndpointNumber = MOUSE_EPNUM,\r
.ReportINEndpointSize = MOUSE_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevMouseHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),\r
},\r
};\r
\r
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
* \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes written in the report (or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;\r
\r
if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
MouseReport->Button |= (1 << 1);\r
\r
- return sizeof(USB_MouseReport_Data_t);\r
+ *ReportSize = sizeof(USB_MouseReport_Data_t);\r
+ return true;\r
}\r
\r
/** HID class driver callback function for the processing of HID reports from the host.\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r
{\r
Endpoint_ClearSETUP(); \r
\r
- uint8_t ReportINData[HID_MAX_REPORT_SIZE];\r
uint16_t ReportINSize;\r
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
\r
- memset(ReportINData, 0, sizeof(ReportINData));\r
+ memset(HIDInterfaceInfo->Config.PrevReportINBuffer, 0, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
\r
- ReportINSize = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);\r
+ CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID,\r
+ HIDInterfaceInfo->Config.PrevReportINBuffer, &ReportINSize);\r
\r
- Endpoint_Write_Control_Stream_LE(ReportINData, ReportINSize);\r
+ Endpoint_Write_Control_Stream_LE(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize);\r
Endpoint_ClearOUT();\r
}\r
\r
\r
if (Endpoint_IsReadWriteAllowed())\r
{\r
- uint8_t ReportINData[HID_MAX_REPORT_SIZE];\r
+ uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];\r
uint8_t ReportID = 0;\r
uint16_t ReportINSize;\r
\r
memset(ReportINData, 0, sizeof(ReportINData));\r
\r
- ReportINSize = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);\r
+ bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData, &ReportINSize);\r
\r
- bool StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->State.PreviousReportINData, ReportINSize) != 0);\r
+ bool StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);\r
bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));\r
\r
- memcpy(HIDInterfaceInfo->State.PreviousReportINData, ReportINData, ReportINSize);\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);\r
\r
- if (ReportINSize && (StatesChanged || IdlePeriodElapsed))\r
+ if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))\r
{\r
HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;\r
\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- #if !defined(HID_MAX_REPORT_SIZE)\r
- /** Maximum size of an IN report which can be generated by the device and sent to the host, in bytes.\r
- *\r
- * \note If larger reports than the default specified here are to be generated by the device, this\r
- * value can be overridden by defining this token to the required value in the project makefile\r
- * and passing it to the compiler via the -D switch.\r
- */\r
- #define HID_MAX_REPORT_SIZE 16\r
- #endif\r
- \r
/* Type Defines: */\r
/** Class state structure. An instance of this structure should be made for each HID interface\r
* within the user application, and passed to each of the HID class driver functions as the\r
\r
uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */\r
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */ \r
+ \r
+ void* PrevReportINBuffer; /** Pointer to a buffer where the previously created HID input report can be\r
+ * stored by the driver, for comparison purposes to detect report changes that\r
+ * must be sent immediately to the host. This should point to a buffer big enough\r
+ * to hold the largest HID input report sent from the HID interface.\r
+ */\r
+ uint8_t PrevReportINBufferSize; /** Size in bytes of the given input report buffer. This is used to create a\r
+ * second buffer of the same size within the driver so that subsequent reports\r
+ * can be compared.\r
+ */\r
} Config; /**< Config data for the USB class interface within the device. All elements in this section\r
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
*/ \r
uint16_t IdleCount; /**< Report idle period, in mS, set by the host */\r
uint16_t IdleMSRemaining; /**< Total number of mS remaining before the idle period elapsed - this should be\r
* decremented by the user application if non-zero each millisecond */ \r
-\r
- uint8_t PreviousReportINData[HID_MAX_REPORT_SIZE]; /**< Previously generated report from the HID interface */\r
} State; /**< State data for the USB class interface within the device. All elements in this section\r
* are reset to their defaults when the interface is enumerated.\r
*/\r
* be set to the report ID of the generated HID input report. If multiple reports are not sent via the\r
* given HID interface, this parameter should be ignored.\r
* \param[out] ReportData Pointer to a buffer where the generated HID report should be stored.\r
+ * \param[out] ReportSize Number of bytes in the generated input report, or zero if no report is to be sent\r
*\r
- * \return Number of bytes in the generated input report, or zero if no report is to be sent\r
+ * \return Boolean true to force the sending of the report even if it is identical to the previous report and still within\r
+ * the idle period (useful for devices which report relative movement), false otherwise\r
*/\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
-\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ \r
/** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to\r
* either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback\r
* the user is responsible for the processing of the received HID output report from the host.\r
/** Pointer to the current track buffer being sent to the host. */\r
BitBuffer_t* CurrentTrackBuffer = &TrackDataBuffers[TOTAL_TRACKS];\r
\r
+/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */\r
+uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];\r
+\r
/** LUFA HID Class driver interface configuration and state information. This structure is\r
* passed to all HID Class driver functions, so that multiple instances of the same class\r
* within a device can be differentiated from one another.\r
\r
.ReportINEndpointNumber = KEYBOARD_EPNUM,\r
.ReportINEndpointSize = KEYBOARD_EPSIZE,\r
+\r
+ .PrevReportINBuffer = PrevKeyboardHIDReportBuffer,\r
+ .PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),\r
},\r
};\r
\r
HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);\r
}\r
\r
-/** HID Class driver callback function for the creation of a HID report for the host.\r
+/** HID class driver callback function for the creation of HID reports to the host.\r
*\r
- * \param[in] HIDInterfaceInfo Pointer to the HID interface structure for the HID interface being referenced\r
- * \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
- * \param[out] ReportData Pointer to the preallocated report buffer where the created report should be stored\r
+ * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced\r
+ * \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID\r
+ * \param[out] ReportData Pointer to a buffer where the created report should be stored\r
+ * \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent\r
*\r
- * \return Number of bytes in the created report\r
+ * \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent\r
*/\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID, void* ReportData)\r
+bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize)\r
{\r
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
\r
KeyboardReport->KeyCode = BitBuffer_GetNextBit(CurrentTrackBuffer) ? KEY_1 : KEY_0;\r
}\r
\r
- return sizeof(USB_KeyboardReport_Data_t);\r
+ *ReportSize = sizeof(USB_KeyboardReport_Data_t);\r
+ return false;\r
}\r
\r
/** HID Class driver callback function for the processing of a received HID report from the host.\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
- void* ReportData);\r
- void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,\r
- const void* ReportData, const uint16_t ReportSize);\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,\r
+ void* ReportData, uint16_t* ReportSize);\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, \r
+ const void* ReportData, const uint16_t ReportSize);\r
\r
#endif\r