teensy 3 - Support for any consumer key

Status
Not open for further replies.

gregersrygg

New member
The implementation in Teensy 3 (and previous) only supports 8 hard-coded consumer-keys, so it was not possible to send the key AC_HOME (0x223) or any of the other 660 consumer-keys. I need some of these consumer-keys to create a custom button-panel for my in-car Nexus 7. The home-button, back-button and many other Android functions can only be triggered by consumer-keys (reference http://source.android.com/devices/tech/input/keyboard-devices.html). Some of them are two bytes, so I found it was not sufficient to just modify the keyboard report descriptor.

I changed the keyboard report descriptor to use an array for the consumer-keys. Not sure if that's Correct™, but that's what I got working. Since some of the consumer page usage ids consists of 2 bytes, I also had to steal one byte from the 6 “normal” keyboard keys (now 5). It's also only possible to send one consumer key at the time. Not sure if there are enough available bytes in the packet to add more consumer-keys, or if it's better to add a new HID config for Consumer Keyboard?

Since set_media was only for media-related keys, I added a new method; set_consumer that can take a 16-bit int. Changed the media-key constants in keylayouts.h to the usage id, and set_media now just calls set_consumer.

Tested many different consumer keys on Android 4.2, and they work perfectly. Only tested the volume-keys on OS X 10.9.1, and they work as well. Tried to test on Windows in VirtualBox, but it wouldn't allow me to use the Teensy USB keyboard :(

This patch makes it easier to send any of the consumer-keys without changing the C-library-code for teensy. Sorry about the README.md file in the patch, it's for people stumbling into my GitHub clone.
https://github.com/gregersrygg/teensyduino-android-keyboard/pull/1.patch

Btw: Have you considered putting the Teensy source-code on Gitorious/GitHub or similar? I think that would make it easier for others to contribute to the project :)

Thanks,
Gregers
 
Agreed. Although a keyboard+consumer pairing would be commonly used in practice, that is a combination of two separate interfaces (in the same way as keyboard+mouse+joystick combines three, for example).
 
Status
Not open for further replies.
Back
Top