Because I have multiple report types (a FEATURE for fetching the LCD configuration, and an OUTPUT for blitting) I have to bypass HIDReporter and use low-level functions in a lot of places --- HIDReporter assumes exactly one report. That means it's very likely I'm just doing it wrong...
So, I create an output buffer in my component's begin().
Code: Select all
blitBuffer.buffer = blitBufferBytes;
blitBuffer.bufferSize = sizeof(blitBufferBytes);
blitBuffer.reportID = BLIT_REPORT_ID;
HID.addOutputBuffer(&blitBuffer);
Code: Select all
if (usb_hid_get_data(HID_REPORT_TYPE_OUTPUT,
BLIT_REPORT_ID,
(uint8_t*)&blitReport,
true))
{
USBSerial.print(blitReport.x1, HEX);
USBSerial.print(" ");
USBSerial.print(blitReport.y1, HEX);
USBSerial.print(" ");
USBSerial.print(blitReport.x2, HEX);
USBSerial.print(" ");
USBSerial.println(blitReport.y2, HEX);
}
Looking at the code, when a packet arrives, hidUSBDataSetup() is supposed to find an OUTPUT buffer, copy the data in, and mark it as UNREAD. Then, usb_hid_get_data is supposed to find an UNREAD buffer, copy the data out, and mark it as READ. The next incoming packet then goes into the buffer.
I can't find _any_ references to people actually using OUTPUT reports with USBComposite, so it might be possible that I'm the very first person to try this... I'm so special. Any advice?