PaulStoffregen / USBHost_t36

USB Host Library for Teensy 3.6 and 4.0
165 stars 85 forks source link

Keyboard foreward #73

Closed KurtE closed 2 years ago

KurtE commented 2 years ago

Hi @PaulStoffregen

Since I have read several requests for a keyboard forwarder functionality in USB Host, thought maybe I would try building a version.

This example sketch can be configured to simply print out the debug information, similar tot he mouse.ino example sketch. For a keyboard.

But if you build with a USB Type that includes keyboard, it will try to forward everything from the keyboard to the Teensy Host...

For normal like keys, it captures them using the capture RAW data code in USBHost code and sends them to the PC by calling keyboard.press with the scan code | 0xF000 (likewise for release). It also looks at the modifier data and if changed updates it for Keyboard. Also it checks to see if keyboard_leds changed and if so it tells the keyboard attached to update to the new values.

For Multimedia keys, it does similar, that if it finds that the data came from HID table C it sends on ored with 0xE400

I have tested it on my W10 64 bit machine with 3 different keyboards and all USB Types including Keyboards... But user mcrc is still having issues with his machine.