Fix demos based on the device mode HID class driver, as well as the driver itself. Changed HID device class driver to require the user to give a buffer and size to hold the previously generated report, for comparison purposes, and altered the prototype of the CALLBACK_HID_Device_CreateHIDReport() function so that reports can be sent to the host even if there are no apparent changes (useful for relative movements in mice, etc.).
This commit is contained in:
parent
a789619fbe
commit
eb41086947
14 changed files with 135 additions and 74 deletions
|
@ -56,17 +56,6 @@
|
|||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
#if !defined(HID_MAX_REPORT_SIZE)
|
||||
/** Maximum size of an IN report which can be generated by the device and sent to the host, in bytes.
|
||||
*
|
||||
* \note If larger reports than the default specified here are to be generated by the device, this
|
||||
* value can be overridden by defining this token to the required value in the project makefile
|
||||
* and passing it to the compiler via the -D switch.
|
||||
*/
|
||||
#define HID_MAX_REPORT_SIZE 16
|
||||
#endif
|
||||
|
||||
/* Type Defines: */
|
||||
/** Class state structure. An instance of this structure should be made for each HID interface
|
||||
* within the user application, and passed to each of the HID class driver functions as the
|
||||
|
@ -80,6 +69,16 @@
|
|||
|
||||
uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */
|
||||
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */
|
||||
|
||||
void* PrevReportINBuffer; /** Pointer to a buffer where the previously created HID input report can be
|
||||
* stored by the driver, for comparison purposes to detect report changes that
|
||||
* must be sent immediately to the host. This should point to a buffer big enough
|
||||
* to hold the largest HID input report sent from the HID interface.
|
||||
*/
|
||||
uint8_t PrevReportINBufferSize; /** Size in bytes of the given input report buffer. This is used to create a
|
||||
* second buffer of the same size within the driver so that subsequent reports
|
||||
* can be compared.
|
||||
*/
|
||||
} Config; /**< Config data for the USB class interface within the device. All elements in this section
|
||||
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
|
||||
*/
|
||||
|
@ -89,8 +88,6 @@
|
|||
uint16_t IdleCount; /**< Report idle period, in mS, set by the host */
|
||||
uint16_t IdleMSRemaining; /**< Total number of mS remaining before the idle period elapsed - this should be
|
||||
* decremented by the user application if non-zero each millisecond */
|
||||
|
||||
uint8_t PreviousReportINData[HID_MAX_REPORT_SIZE]; /**< Previously generated report from the HID interface */
|
||||
} State; /**< State data for the USB class interface within the device. All elements in this section
|
||||
* are reset to their defaults when the interface is enumerated.
|
||||
*/
|
||||
|
@ -137,11 +134,14 @@
|
|||
* be set to the report ID of the generated HID input report. If multiple reports are not sent via the
|
||||
* given HID interface, this parameter should be ignored.
|
||||
* \param[out] ReportData Pointer to a buffer where the generated HID report should be stored.
|
||||
* \param[out] ReportSize Number of bytes in the generated input report, or zero if no report is to be sent
|
||||
*
|
||||
* \return Number of bytes in the generated input report, or zero if no report is to be sent
|
||||
* \return Boolean true to force the sending of the report even if it is identical to the previous report and still within
|
||||
* the idle period (useful for devices which report relative movement), false otherwise
|
||||
*/
|
||||
uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);
|
||||
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||
void* ReportData, uint16_t* ReportSize);
|
||||
|
||||
/** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to
|
||||
* either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback
|
||||
* the user is responsible for the processing of the received HID output report from the host.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue