Emulating a USB keyboard using ???

Hi guys, Do you know a way to emulate a USB keyboard using Raspberry Pi, BeagleBone Black, ODROID, or some other embedded board? That is, as far as PC is concerned, it's receiving keypresses from some keyboard. I know those boards have UART pins. But, even if I connect the pins to a serial-to-USB cable, the USB end of the cable will show up as serial (/dev/ttyUSBx) and not as keyboard. I have such a cable, and that's what I see. -- William

On Sat, Dec 05, 2015 at 11:10:40AM -0500, William Park wrote:
Hi guys,
Do you know a way to emulate a USB keyboard using Raspberry Pi, BeagleBone Black, ODROID, or some other embedded board? That is, as far as PC is concerned, it's receiving keypresses from some keyboard.
I know those boards have UART pins. But, even if I connect the pins to a serial-to-USB cable, the USB end of the cable will show up as serial (/dev/ttyUSBx) and not as keyboard. I have such a cable, and that's what I see.
If it supports linux's USB gadget interface then you should be in luck: https://www.kernel.org/doc/Documentation/usb/gadget_hid.txt Raspberry pie can NOT do it, since it has a permanent USB hub connected, and you can't have a hub connected to the port to use it in gadget mode (since gadget mode means being a USB client, not a host). The BBB on the hand can do it. I didn't check the others. -- Len Sorensen

On Dec 5, 2015 10:39, "Lennart Sorensen" <lsorense@csclub.uwaterloo.ca> wrote:
Raspberry pi can NOT do it, since it has a permanent USB hub connected
The Model A, Compute Module, and Raspberry Pi Zero *can* do it, but will need some kernel fiddling to enable gadget mode. Cheers Stewart

On Sat, Dec 05, 2015 at 01:47:26PM -0500, Stewart Russell wrote:
On Dec 5, 2015 10:39, "Lennart Sorensen" <lsorense@csclub.uwaterloo.ca> wrote:
Raspberry pi can NOT do it, since it has a permanent USB hub connected
The Model A, Compute Module, and Raspberry Pi Zero *can* do it, but will need some kernel fiddling to enable gadget mode.
True, I forgot about the A. -- Len Sorensen

On 5 December 2015 at 22:01, Lennart Sorensen <lsorense@csclub.uwaterloo.ca> wrote:
On Sat, Dec 05, 2015 at 01:47:26PM -0500, Stewart Russell wrote:
On Dec 5, 2015 10:39, "Lennart Sorensen" <lsorense@csclub.uwaterloo.ca> wrote:
Raspberry pi can NOT do it, since it has a permanent USB hub connected
The Model A, Compute Module, and Raspberry Pi Zero *can* do it, but will need some kernel fiddling to enable gadget mode.
True, I forgot about the A.
I talked to Jason Kridner at the last Penguicon (Science Fiction and Linux convention in Detroit) - Kridner is the main guy behind the BeagleBone. He expressed an interest in helping me out with something I've wanted for a long, long time: he said it would be easy to turn the BeagleBone Black into a keyboard converter, ie. you type Dvorak on a standard keyboard and the inline-USB BBB turns it into standard Qwerty. This is a little like using a bulldozer to move a pebble, but computing power is so cheap these days and the BBB is equipped for the job ... Sadly (for me, anyway) he didn't get around to writing the code and has (per his public posts) recently become a father, so I'm not expecting this to come to anything. But the point remains: generating keyboard output to USB shouldn't be too difficult from the BBB. If you have a BBB I think it would be worth considering, but if you're starting from zero an Arduino Nano or Teensy might be better (the Teensy is used in the Ergodox keyboard project). A quick search turned up these: http://www.rs-online.com/designspark/electronics/blog/leostick-dev-kit-revie... https://www.tindie.com/products/digistump/digispark-the-tiny-arduino-enabled... They looks like the ideal form factor for the kind of project you're discussing? Sorry this isn't coming from expertise in the area, but I've had a long-time peripheral interest so I hope this may help a little. -- Giles http://www.gilesorr.com/ gilesorr@gmail.com

On Sun, Dec 06, 2015 at 11:10:38AM -0500, Giles Orr wrote:
If you have a BBB I think it would be worth considering, but if you're starting from zero an Arduino Nano or Teensy might be better (the Teensy is used in the Ergodox keyboard project). A quick search turned up these:
Thanks Giles. I do have BBB, and that's where I will start my reading. I have seen Teensy, LaundPad (from TI), and others. Most examples go something like - if a button is pressed - then send data to USB client port What I'm trying to do is send keypress from another PC, eliminating any "manual" pressing. I was thinking to hook up serial-to-USB cable to UART pins on those boards, and move data between UART serial port and USB client port. This will work (I think). But, I need USB hub, one serial-to-USB cable for each PC, and worry about distance and the length of USB cables. BBB comes with ethernet, which is easier to work with. BBB also has UART pins, so I'll use those as last resort. -- William

| From: Stewart Russell <scruss@gmail.com> | The Model A, Compute Module, and Raspberry Pi Zero *can* do it, but will | need some kernel fiddling to enable gadget mode. The problem is that you don't get much other I/O on these. No other USB, no ethernet, no RS232-style serial port. So yes, they could emulate a keyboard but then it would be hard to provide input to the Pi. The various I/O pins could be harnessed but to me that would multiply the complexity of a project. (A project that would amuse me, but not enough to do it, would be to build a KM switch (i.e. a Keyboard / Video / Mouse switch without the video part). But that would take n gadget interfaces.)

On Sat, Dec 05, 2015 at 11:39:01AM -0500, Lennart Sorensen wrote:
On Sat, Dec 05, 2015 at 11:10:40AM -0500, William Park wrote:
Hi guys,
Do you know a way to emulate a USB keyboard using Raspberry Pi, BeagleBone Black, ODROID, or some other embedded board? That is, as far as PC is concerned, it's receiving keypresses from some keyboard.
I know those boards have UART pins. But, even if I connect the pins to a serial-to-USB cable, the USB end of the cable will show up as serial (/dev/ttyUSBx) and not as keyboard. I have such a cable, and that's what I see.
If it supports linux's USB gadget interface then you should be in luck:
Thanks for the link. It even has sample code for testing!
Raspberry pie can NOT do it, since it has a permanent USB hub connected, and you can't have a hub connected to the port to use it in gadget mode (since gadget mode means being a USB client, not a host).
The BBB on the hand can do it. I didn't check the others.
Both BeagleBone Black and ODROID-U3 have USB mini-B port, and do mention USB "client mode" in their online specs. So, I'm encouraged. -- William

There are some Arduino boards that can do it using this library. https://www.arduino.cc/en/Reference/MouseKeyboard I haven't used it. Jim On 2015-12-05 11:10 AM, William Park wrote:
Hi guys,
Do you know a way to emulate a USB keyboard using Raspberry Pi, BeagleBone Black, ODROID, or some other embedded board? That is, as far as PC is concerned, it's receiving keypresses from some keyboard.
I know those boards have UART pins. But, even if I connect the pins to a serial-to-USB cable, the USB end of the cable will show up as serial (/dev/ttyUSBx) and not as keyboard. I have such a cable, and that's what I see.

The Arduino Leonardo, Micro and Zero, the SparkFun Pro Micro and some other Arduino compatibles can easily emulate a USB keyboard or mouse. <https://www.arduino.cc/en/Reference/MouseKeyboard> -- Scott
participants (7)
-
D. Hugh Redelmeier
-
Giles Orr
-
Jim Ruxton
-
Lennart Sorensen
-
Scott Allen
-
Stewart Russell
-
William Park