keyboardio / KeyboardioHID

A HID library for Arduino
MIT License
34 stars 17 forks source link

HID_::SendReport_: Use a single send on SAMD #60

Closed algernon closed 4 years ago

algernon commented 4 years ago

On SAMD, we need to send the whole report in one go, otherwise the report does not arrive to the host. To do this, we merge the report id and the report itself into a single buffer, and send that instead of sending the report id and the data separately.

This is not a nice fix, but the best I could come up with. We could use the same code on AVR too, but that'd increase our RAM use by ~60 bytes, and RAM is scarce on AVR, so it's better to stick with the other implementation there.

Note that we can't use USB_PackMessages() either, because that only seems to work for control messages, and the report isn't one.

This fixes keyboardio/Kaleidoscope#754.

obra commented 4 years ago

Can you add some documentation inline explaining what you're doing and why?

algernon commented 4 years ago

Done, added some in-line explanation and force pushed.