forked from mfulz_github/qmk_firmware
Fixed the ClassDriver GenericHID demo so that it echoes back reports as indicated in the demo overview.
This commit is contained in:
parent
eb41086947
commit
ac593611c9
|
@ -39,6 +39,14 @@
|
||||||
/** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */
|
/** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */
|
||||||
uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE];
|
uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE];
|
||||||
|
|
||||||
|
/** Structure to contain reports from the host, so that they can be echoed back upon request */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t ReportID;
|
||||||
|
uint16_t ReportSize;
|
||||||
|
uint8_t ReportData[GENERIC_REPORT_SIZE];
|
||||||
|
} HIDReportEcho;
|
||||||
|
|
||||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||||
* within a device can be differentiated from one another.
|
* within a device can be differentiated from one another.
|
||||||
|
@ -139,9 +147,12 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
||||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||||
void* ReportData, uint16_t* ReportSize)
|
void* ReportData, uint16_t* ReportSize)
|
||||||
{
|
{
|
||||||
// Create generic HID report here
|
if (HIDReportEcho.ReportID)
|
||||||
|
*ReportID = HIDReportEcho.ReportID;
|
||||||
|
|
||||||
*ReportSize = 0;
|
memcpy(ReportData, HIDReportEcho.ReportData, HIDReportEcho.ReportSize);
|
||||||
|
|
||||||
|
*ReportSize = HIDReportEcho.ReportSize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,5 +166,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
||||||
const void* ReportData, const uint16_t ReportSize)
|
const void* ReportData, const uint16_t ReportSize)
|
||||||
{
|
{
|
||||||
// Process received generic HID report here
|
HIDReportEcho.ReportID = ReportID;
|
||||||
|
HIDReportEcho.ReportSize = ReportSize;
|
||||||
|
memcpy(HIDReportEcho.ReportData, ReportData, ReportSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
*
|
*
|
||||||
* Generic HID device demonstration application. This gives a simple reference application
|
* Generic HID device demonstration application. This gives a simple reference application
|
||||||
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
||||||
* OSes (i.e. no special drivers required). It accepts and sends up to 255 byte reports to
|
* OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports
|
||||||
* and from a USB Host, and by default transmits the last sent report back to the host.
|
* to and from a USB Host, and transmits the last sent report back to the host.
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
||||||
* When controlled by a custom HID class application, reports can be sent and received by
|
* When controlled by a custom HID class application, reports can be sent and received by
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
*
|
*
|
||||||
* Generic HID device demonstration application. This gives a simple reference application
|
* Generic HID device demonstration application. This gives a simple reference application
|
||||||
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
||||||
* OSes (i.e. no special drivers required). It accepts and sends up to 255 byte reports to
|
* OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports
|
||||||
* and from a USB Host, and by default transmits the last sent report back to the host.
|
* to and from a USB Host, and transmits the last sent report back to the host.
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
||||||
* When controlled by a custom HID class application, reports can be sent and received by
|
* When controlled by a custom HID class application, reports can be sent and received by
|
||||||
|
|
Loading…
Reference in New Issue