Posts: 11
Joined: Mon Mar 14, 2016 2:20 am

Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Fri May 25, 2018 8:34 am


I would like to achieve following.
Rpi or (Rpi Zero) acting as USB device, I have read some articles about the zero being able to emulate as USB device, but it only has 1 USB port.

Can the Rpi do the same?


User avatar
Posts: 34562
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Fri May 25, 2018 8:49 am

Not possible. The USB ports on a RPi are all host ports. To be a HID device you need a USB slave.

Use ssh with port forwarding.
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a hippy & doctor free zone.

Posts: 11
Joined: Mon Mar 14, 2016 2:20 am

Re: Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Fri May 25, 2018 8:56 am

DougieLawson wrote:
Fri May 25, 2018 8:49 am
Not possible. The USB ports on a RPi are all host ports. To be a HID device you need a USB slave.

Use ssh with port forwarding.
I guessed some how.

The zero allows slave port. But can I use the GPIO Usb to connectors to my "Physical Keyboard" ? I will use the USB data port as USB Slave. Or is there any PCB out there that can do such thing easier? Thanks

Posts: 4372
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Fri May 25, 2018 10:52 am

You should be able to use two Pi Zeroes; one as a USB Host handling the physical keyboard, the other as a USB Device acting as a virtual keyboard for whatever it plugs into. The data could be passed between the two using UART serial easily enough and other GPIO mechanisms could work.

Turning that point-to-point serial link into a multi-drop or token-ting style configuration should allow multiple Hosts and Devices. All sorts of USB switching, routing and patching should be possible.

Posts: 939
Joined: Mon Oct 30, 2017 4:55 pm

Re: Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Fri May 25, 2018 11:27 am

DougieLawson wrote:
Fri May 25, 2018 8:49 am
Not possible. The USB ports on a RPi are all host ports. To be a HID device you need a USB slave.

Use ssh with port forwarding.
What does ssh have to do with anything???

"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

Posts: 2
Joined: Sun Aug 13, 2017 2:42 pm

Re: Can I "passthrough" a keyboard (act as keyboard) on an Rpi

Thu Jul 05, 2018 1:20 pm

I'm also interested in such a thing, here's my scenario;

I am building a 3x3 Video Wall using 9 4K Android TVs, Android TVs are great and yea you can load pretty much any Android app onto them, however if not specifically designed as an Android TV app, many apps assume there is a touch screen. A mouse can substitute for a touch screen, somewhat, though a mouse will not interact with an Android TV onscreen keyboard, that you have to use the remote that came with the TV for. Also there is no onscreen 'back', 'home' or 'overview' buttons, well actually there is no 'overview' function at all really in the Android TV leanback launcher, though they kind of hacked in this functionality into Nougat, but mine are Marshmallow, so anyway, for me, not there.

While the eventual plan is to have a box, probably a Windows box, just because it's the easiest path to output to a 12K, 130" 'screen', that has 9 4K video outs and can define the whole thing as a single 12K 'display', and may also use the other HDMI on these with a video wall controller connected to an nVidia shield to make a common 4K Android TV interface as well, with the TVs running at 720p each which would then upscale through the TVs themselves, though video wall controllers that can take 4K input, are not even remotely in any affordable range, the affordable boxes are only 1080p input making the output effectively 360p, which is not really worth it for me to consider, especially considering 'remotely affordable' is still $1000 US. Units that can do 4K input start at about $4000, for half that I can build a Windows box with an i7, a bunch of RAM, and a pair of frame locked 6 port Matrox Video wall display cards that do 4K output to every display, and before you say it, no there isn't a better solution from nVidia or ATi, past 6 displays everything gets really expensive really fast from nVidia, and ATi doesn't really have a frame locked common surface solution past 6 displays. But anyway, I still want to be able to use each of these displays independently and accessing the embedded Android TV interface already there is sufficient for that, it's actually a better streaming platform than I'll get from Windows, especially as a remote driven interface and the remote functions of Android TV can be Android app driven, though not mind you Android (non-TV) apps.

...Oh and the TVs were stupidly cheap, so perspective there.

Point is HID mice work just fine, USB or Bluetooth doesn't matter, and so do HID keyboards and it saves you from having to do the weird two handed mouse/remote dance to navigate and 'type'. You'd think with thousands of apps available this would exist, and it has, but..

Potential Solution 1:

There's Synergy, which based on a few Youtube videos looks like just the ticket, more than one video showing someone doing exactly what I'd like to do, move my mouse off screen some direction and it moves to the Video Wall grid and that becomes the focus of the Keyboard/Mouse over Ethernet. There's demos, sponsored by Synergy even, of a Windows box, a Mac a Linux box and an Android tablet all happily sharing a keyboard and mouse in an almost magical dance, like it's just RDP or VNC windows, seems awesome. However the Synergy Android App isn't a Synergy app at all it's a 3rd party developers app, and it's really some Alpha level app on Github, not on the google Play Store, not supported by Synergy at all, it doesn't seem to get the concept of Android TV, it's basically a white on white text setup, totally blind, and then crashes as soon as you try to connect, boo! Not really sure what the developer is doing there, because generally speaking, aside from the whole touch screen assumption, regular Android apps usually work on an Android TV as long as they don't require specific phone things like a SIM card or GPS or things like that. A lot of them come up in portrait mode, while annoying, they generally work, even complex DRM streaming apps. But anyway, fail 1.

Potential Solution 2:

ShareKM, basically does the same sort of thing as above, Windows and Android only which is OK, though the sole developer has been MIA since Android Lollipop was released which is apparently when his app stopped working, and no code repository, fail 2.

Potential Solution 3:

A multi point Bluetooth HID emulator USB dongle marketed as the I/O Gear KeyShair and also as a product called MultiBlue. This product was apparently featured on 'Mr. Robot', must have missed that part, as some evil hacking tool and went from being a $5 device that could kind of did what I want, well 1/3rd of the way there anyway as it would do 3 sets of Bluetooth keyboard and mice, to an effectively banned device, that if you can find one will cost you hundreds now, with a limit of 1 per customer, a price even Elliot would balk at, fail 3.

Potential Solution 4:

A not very mature app called DeskDock, though this Android app only works over USB direct connections, no network bridging, no Bluetooth, it seems to use the same kind of connection an Android Debugger (ADB) session would use, which would lead me to believe that I'd have doubts that you could just pop a hub behind the video wall and have it work, I don't think some remote USB hub would know what to do with a connection like that. I'd consider a Digi AnywhereUSB box or 2 if I thought that would work but I highly doubt it would. Also direct USB starts getting into cable length limits, if that's what you're stuck with, from my perspective anyway and that's not to say it'd play nice with Android TV at all, and being an app runs the same risk as solution 1 & 2 which both seem to have been broken by Android releases. The only reason I even mention it is that the developer was a fanatic fan of ShareKM until it puked, anyway logistically, probably fail 4.

So all these segues gets me back to this thread, simply because, unlike other threads on the USB HID Gadget subject, this one seems to elude to some interactive interaction, as opposed to most that seem to just want to send canned keyboard strings somewhere. All the above solutions rely on some very specific hosted magic, even the dongle solution had an embedded app contained on a flash portion of the dongle to function, and really this should just be a device independent thing. Hook up a HID keyboard and mouse into some black box that acts as the host, that communicates to however many gadget dongles via Wifi or wired or whatever networking. Having a web interface to define a screen grid would be awesome, though hotkey switching would work just as well and not sure you could define a grid without knowing the screen layout which I can't see how you would know that actually. But anyway just seems like the keyboard/mouse host could be anything, any Pi, any Linux box, any SBC really. I think you'd just need to reserve whatever keyboard and mouse got attached for that purpose so that they didn't get absorbed into X, or console, could probably associate them with a dummy 'seat', I have Pis running independent X session seats for TFT and HDMI display output where the TFTs touch screen and a chocolate bar keyboard and pad are associated with the little 3.5" TFT and anything else that gets plugged in associates with the HDMI and 1 Raspberry Pi acts like 2 Raspberry Pis, so I can see how that could be done on that side of things.

The hard 'parts' are readily available in almost any way you want to approach this, there is multiple off the shelf dongle adapter boards for Pi Zeros, solder on or pogo pin varieties, and many more posts, blogs and videos on how to DIY it. With Pi Zero Ws you could create a WiFi network of them, or there is I/O header based Ethernet adapters, limited to 10Mb, but still, that'll do it wired if you need to with regular old Pi Zeros which I'd probably more apt to do just because they'd be behind literally a wall of video, and shielding, and the Pi Ws WiFi performance and range is not very impressive or particularly stable under the best of conditions, this is something that you really just want to work, in the end I don't know that you really care that it's a Pi on the Gadget end of things, that side should just need a network definition, a listener, a definition of it's designated host, if that even really, and well I think that's it, other than that it just gets a HID command stream from the "server", the host that has the physical keyboard and mouse and repeats that to whatever host it's connected to.

Why don't I just write this? Um, because I'm at best a code hack. I know Linux/Unix config and admin very well, but not really a programmer and certainly not a device programmer which is a whole thing unto itself. If this was possible in a shell script I'd certainly give it a go, but I don't think there is really anyway to do hotkey intercepts that way.

Oh and sorry to the OP for the long post, just trying to put a real world application on your concept. I have one, obviously.

Return to “Interfacing (DSI, CSI, I2C, etc.)”