I'm making a Keyboard-to-Controller adapter using the FT908. Pretty simple design: You plug a keyboard into one end, and the other end plugs into a Nintendo Switch. From there, you can use your keyboard as a controller.
Right now I'm trying to handle the USB keyboard inputs and this harder than I expected.
Right now I'm using a Corsair K65. It has 3 endpoints and I need to listen to them all simultaneously:
- A "BOOT" endpoint (where it sends data matching the typical 6-KRO USB report for BIOS)
- A "Media Controls" endpoint (things like volume up/down)
- A "NKRO" endpoint (uses a bitmap so you can press ALL THE KEYS!)
I also made a video of me going through the keyboard and asking questions:
https://photos.app.goo.gl/7j98istA1GyRfbjE6The two questions I have:
I originally used the "USBH Example HID" code as a starting point, but realized that the "USBH_HID_get_report" is a blocking call to only 1 endpoint (which is a no-go - I need to listen to all 3 endpoints and receive from any as an interrupt.) I found out about "USBH_transfer_async" which seems like what I need. I combined it with looping over "USBH_Process" but it isn't yielding me any data in the buffer I'm sending in. I can't find any code examples using "USBH_transfer_async" - how should I be doing this? Figured this and it's working perfectly (although the documentation says NOT to re-call the "USBH_transfer_async" from within the callback, one of the examples does just that so so far it's been working pretty good)- When I do start receiving data, do I need to write unique code to decode all three of those different endpoints? The boot protocol, the volume All I want is the "keys" sent to me. If I do have to write unique code for each EP, this seems like an impossible task then right? There are hundreds of thousands of keyboards and I assume all of them send different kinds of reports. How could I possibly write code to interpret all of them?? Just looked at my Razer Tartarus and it also has an insanely unique way of reporting keys. HELP!!!
I've attached the USB HID data of my keyboard (interfaces, endpoints, etc.) Hope this helps someone answer my question 🙏