Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: teensy 3 - Support for any consumer key

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Location
    Oslo, Norway
    Posts
    3

    Lightbulb teensy 3 - Support for any consumer key

    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/te...d-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/teens...d/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

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,106
    Interesting, its good to see some support for the 0x0C USB Consumer Page. Besides the Android documentation, you should look at chapter 15 of the HID Usage Tables,
    http://www.usb.org/developers/devcla.../Hut1_12v2.pdf
    linked from here
    http://www.usb.org/developers/hidpage/

    The Teensy core code is on GitHub:
    https://github.com/PaulStoffregen/cores

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Location
    Oslo, Norway
    Posts
    3
    Quote Originally Posted by Nantonos View Post
    Besides the Android documentation, you should look at chapter 15 of the HID Usage Tables,
    http://www.usb.org/developers/devcla.../Hut1_12v2.pdf
    Yes, have spent many hours reading both 1.11 and 1.12 version of the HID spec

    Quote Originally Posted by Nantonos View Post
    The Teensy core code is on GitHub:
    https://github.com/PaulStoffregen/cores
    Oh, nice! Couldn't find it when searching on GitHub... Will move the pull-request there.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    This really needs to be added as a separate interface (and a unique endpoint) with its own report descriptor.

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,106
    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).

  6. #6
    Administrator Paul's Avatar
    Join Date
    Oct 2012
    Posts
    332
    If anyone's still watching this old thread, new & improved media key support is available.

    https://forum.pjrc.com/threads/34074...ows-compatible

    I'm closing this old thread. Please comment on the new thread.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •