Multiple Teensys as keyboards on one PC?

Status
Not open for further replies.

plasma2002

New member
Hiya!

I've had an issue in the past with Adafruit's Trinket, where if I had two or more of them configured as keyboard devices, the OS (Mac at the time) would only work with the first one that was plugged in. It would ignore any more that were plugged in. In other words, I could only use one Trinket configured as a keyboard at a time. I'm not sure if it does that on other operating systems, but it doesnt matter.

Would anybody happen to know if this limitation would also exist with the Teensy's keyboard emulation? I only have one on-hand, so there's no easy way for me to test this.
 
My best guess as to what would be causing that with the Trinket (I have not used them, myself) is that the USB device ID is hardcoded, and for some reason it was seeing both trinkets as a single device. Perhaps that would cause it to just ignore the second one?
But I just attached an identical *actual* keyboard (I have two MacAllys) to my computer, and they both seem to work fine. Half of this sentence was written on one, and this half of the sentence was written on the other.
This reply didn't turn out as helpful as I'd hoped it would. Sadly I don't have enough spare teensy's to try it out with either. I'll just say, the Teensy's USB/HID implementation is very, very robust. If you're willing to dig deep enough, you can do all sorts of crazy things with it.
 
I've the opinion that if it wouldn't already work and nobody beats him to the punch Paul will help you make it work happily enough :)

Just curiosity: Unless multi-seating at a suitable (assuming Linux) work-station, what you gonna do with all them keyboards attached simultaneously?
 
Yes, I can confirm this works.

I tested it just now, using a MacBook Pro running OS-X 10.7.5, with two Teensy 3.1s programmed with File > Examples > Teensy > USB_Keyboard > Buttons, and of course Tools > USB Type set to Keyboard + Mouse + Joystick while uploading that sketch to both of them.

With both connected to the MacBook, and the cursor in a terminal window, I tried touching a wire from GND to the nearby pins. Both are able to type "B1 press" and "B1 release", "B2 press" and "B2 release", etc. This test involved touching the pins on 1 board at a time.

As a final test, to make sure they can truly type at the same time, I put the two Teensys on a breadboard and wired the pin 0 signals together. Then I touched a wire between the pair of pin 0 signals and ground, so both Teensys would try to type at the same moment. The results are not perfect. Here's a screenshot:

Screen.png

Sometimes the 2 simultaneous keystrokes appear as 2 characters, but sometimes only 1 character.

Then I tried using two real USB keyboards. I was able to reproduce the problem where a character appears only once when pressed on both keyboards. It's takes quick finger action! You have to press and hold key on the first keyboard, then press and release the same key on the other keyboard while holding the first one down. It's tricky to do manually, because holding the key on the first keyboard pretty quickly causes auto-repeat. But it's definitely possible to get only a single character typed if one keyboard sends the key press and release entirely inside the time the other keyboard has the key pressed and not yet released.

Mac OS-X appears to be merging the keyboard input at the key-down & key-up level. This obviously isn't anything to do with Teensy, or Trinket, or any USB keyboard, but how Apple's HID driver is merging the data streams. It seems to merge all the key-down and key-up events into a single event stream, and then it turns that single stream into actual input characters.

With Teensy, or Trinket, or any real USB keyboard, if both try to send the exact same key at the same moment, and the timing happens to have one send the key-down event while the other has the key-down without having sent the corresponding key-up event, you'll get only 1 keystroke registered instead of two.

But other than that small timing caveat, 2 Teensy 3.1 definitely do work.

I have no idea why Trinket didn't work, but there are all sorts of USB compliance issues with software-emulated USB, so I'm not surprised is would have issues. In fact, it's pretty amazing that can work at all.
 
Last edited:
Hey Paul, it wouldn't surprise me if that behaviour is repeatable in all operating systems in any configuration which isn't well implemented multi-seat.
 
Status
Not open for further replies.
Back
Top