jnbspace
Posts: 1
Joined: Wed Dec 05, 2018 10:33 pm

Getting the pi to pretend it is a keyboard

Wed Dec 05, 2018 10:44 pm

I have a project in mind. I want to get a raspberry pi to act as though it is a keyboard to another computer so that when I run a control program through a touch screen it will send keyboard commands to a USB port on another computer. This has to be done through the physical USB port on the controlled computer.

A bit of context might clarify what I want to do.

I run a mobile planetarium and that I can control through a custom remote control that the planetarium provider uses, an x box controller or a keyboard.
The custom remote control is cumbersome to use and unless you know the system inside out in the dark people do have navigation problems.
The X box controller is nice for adjusting position once you are somewhere but otherwise is quite limited
The keyboard has the same issue that you need to know the interface very well to hit the right keys.

The planetarium system runs software that I can not change and can not supplement. So I can install no drivers or clients on that computer.

What I want to do is to run a system on a raspberry pi with a touch screen. So that instead of having to remember key strokes I can just press a button on screen to say "toggle atmosphere" and it will send the appropriate signals to the USB port on the controlled computer. I'm sure this should be quite possible but I'm not sure where to start looking.

Thanks in advance

User avatar
rpdom
Posts: 12953
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Getting the pi to pretend it is a keyboard

Thu Dec 06, 2018 7:02 am

First thoughts are:

Pi Zero range can present as USB devices in gadget mode. There are drivers for HID devices like keyboards. It shouldn't be too hard to make a Zero look like a USB keyboard abd send the right button presses.

Pi Zero does not support the official Pi touch screen display.

It may be possible to connect a touch screen that runs from the GPIO, but these tend to be smallish.

Alternative is to use two Pi, connected via wifi. A Zero W to pretend to be a USB keyboard, and a 3B or 3B+ to drive the touch screen and send message to the Zero over Wifi.

PhatFil
Posts: 614
Joined: Thu Apr 13, 2017 3:55 pm

Re: Getting the pi to pretend it is a keyboard

Thu Dec 06, 2018 7:54 am

check out this esp8266 based rubber ducky for a wifi controlled usb keyboard emulator
https://github.com/spacehuhn/wifi_ducky a pi is a bit ott for this sort of job,

User avatar
Imperf3kt
Posts: 1487
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Getting the pi to pretend it is a keyboard

Thu Dec 06, 2018 8:09 am

rpdom wrote:
Thu Dec 06, 2018 7:02 am
First thoughts are:

Pi Zero range can present as USB devices in gadget mode. There are drivers for HID devices like keyboards. It shouldn't be too hard to make a Zero look like a USB keyboard abd send the right button presses.

Pi Zero does not support the official Pi touch screen display.

It may be possible to connect a touch screen that runs from the GPIO, but these tend to be smallish.

Alternative is to use two Pi, connected via wifi. A Zero W to pretend to be a USB keyboard, and a 3B or 3B+ to drive the touch screen and send message to the Zero over Wifi.
A better alternative may be to use a Pi3A+, as it does have the DSI connector.
Stop plugging your fan directly into the GPIO 5v
https://www.electronics-tutorials.ws/power/transient-suppression.html

User avatar
thagrol
Posts: 942
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Getting the pi to pretend it is a keyboard

Thu Dec 06, 2018 4:03 pm

Imperf3kt wrote:
Thu Dec 06, 2018 8:09 am
A better alternative may be to use a Pi3A+, as it does have the DSI connector.
Or, if you can get hold of them an original A or A+. These can be forced into gadget mode, not usre about the 3A+ but it should be the same.

Edit:
there's some code here https://github.com/thagrol/pwdgen that might get you started with HID keyboard gadgets
Note to self: don't feed the trolls
If you believe "L'enfer, c'est les autres" (Hell is other people) have you considered that it may be of your own making?

Return to “Other projects”