Emulate a USB keyboard.


14 posts
by nickon314 » Tue Aug 07, 2012 8:08 pm
Is it possible to get a Raspberry Pi to emulate a USB keyboard?

I would like to plug in the raspberry pi in to my PC - and the PC recognise it as a new keyboard.

Then it can be used to send predefined automated keystrokes to the PC.


Is that possible?

Regards

Nick
Posts: 115
Joined: Tue Jul 03, 2012 12:11 pm
Location: West Yorkshire
by mahjongg » Tue Aug 07, 2012 9:58 pm
No, on the RAspberry PI model B the USB hardware is actually connected to a built in Hub, this fixes the USB format as master, there is no way a model B can be a "slave device". Thats said, the SoC of the Raspberry PI is actually capable as being used for both a master and a slave USB device, so theoretically when using a model-A it could be possible to program it to behave as a slave device. Obviously its against the USB specification for a slave device to have a type-A connector, but with some soldering you could connect a type-B or even an USB-on-the-go connector.

Currently it is NOT possible.
User avatar
Forum Moderator
Forum Moderator
Posts: 5857
Joined: Sun Mar 11, 2012 12:19 am
by redhawk » Tue Aug 07, 2012 10:11 pm
If you need to control your PC from the PI there is always the VNC server / client option.

As for keyboard combinations what exactly did you have in mind??

Richard S.
User avatar
Posts: 3519
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1
by mahjongg » Tue Aug 07, 2012 10:23 pm
`It may be possible to emulate a PS/2 keyboard (using bit banging on the GPIO pins), then using a "Blue box" PS/2 to USB adapter to connect this "PS/2 keyboard" to a PC.
User avatar
Forum Moderator
Forum Moderator
Posts: 5857
Joined: Sun Mar 11, 2012 12:19 am
by bredman » Tue Aug 07, 2012 10:42 pm
It is also possible to use the RPi sound port to drive infrared LEDs. This allows the RPi to pretend that it is an infrared wireless keyboard. Some people have reported success using the RPi to control a media server using this method. Try searching this forum for "infrared".
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by arbuz » Tue Aug 07, 2012 11:36 pm
redhawk wrote:If you need to control your PC from the PI there is always the VNC server / client option.

VNC is only usable when x server is loaded, I would recommend using SSH (you can use it to operate on x11 as well).
Posts: 12
Joined: Mon Jul 30, 2012 12:06 am
by nickon314 » Wed Aug 08, 2012 9:24 pm
bredman wrote:It is also possible to use the RPi sound port to drive infrared LEDs. This allows the RPi to pretend that it is an infrared wireless keyboard. Some people have reported success using the RPi to control a media server using this method. Try searching this forum for "infrared".


Yes, I have already played with the PWM pins to create an IR transmitter.
But, that was to directly control my Set Top Box.

It worked - but it's not very reliable as the timing of on/off isn't very accurate with Linux.

I also have an Arduino to do this sort of thing and I am sticking with that at the moment as it works everytime.


Regards

Nick
Posts: 115
Joined: Tue Jul 03, 2012 12:11 pm
Location: West Yorkshire
by guidol » Thu Aug 09, 2012 6:55 am
nickon314 wrote:Is it possible to get a Raspberry Pi to emulate a USB keyboard?
I would like to plug in the raspberry pi in to my PC - and the PC recognise it as a new keyboard.
Then it can be used to send predefined automated keystrokes to the PC.

You can only use a Ardunino Lenoardo as single device or conencted to you RPi to emulate
a USB-Keyboard (and Mouse):
http://arduino.cc/en/Reference/MouseKeyboard
User avatar
Posts: 70
Joined: Tue Jul 03, 2012 9:21 am
Location: Babenhausen, Germany
by YodaTheCoder » Thu Aug 09, 2012 8:07 am
nickon314 wrote:IThen it can be used to send predefined automated keystrokes to the PC.


If this is just going to be run on a timed basis I'd recommend AutoHotkey and Scheduled Tasks. If you are aiming for remote control then go with the already suggested SSH or VNC.
Posts: 14
Joined: Fri Jul 27, 2012 5:02 pm
by DexOS » Thu Aug 09, 2012 8:11 pm
nickon314 wrote:
bredman wrote:It is also possible to use the RPi sound port to drive infrared LEDs. This allows the RPi to pretend that it is an infrared wireless keyboard. Some people have reported success using the RPi to control a media server using this method. Try searching this forum for "infrared".


Yes, I have already played with the PWM pins to create an IR transmitter.
But, that was to directly control my Set Top Box.

It worked - but it's not very reliable as the timing of on/off isn't very accurate with Linux.

I also have an Arduino to do this sort of thing and I am sticking with that at the moment as it works everytime.


Regards

Nick

The problem is linux gets in the way of the timing, to be fair to the PI, go bare metal and it will do anything the arduino can do, plus more.
Batteries not included, Some assembly required.
User avatar
Posts: 865
Joined: Wed May 16, 2012 6:32 pm
by owen » Wed Jul 31, 2013 11:03 pm
http://www.linuxuser.co.uk/tutorials/em ... spberry-pi

Looks like you can emulate a keyboard over bluetooth, this is a guide for doing it to connect to an android device. But I like the idea of keyboard emulation for PCs so I can do KVM over IP. I wonder if a bluetooth USB device could be pre-paired with this and offer immidiate USB keyboard and mouse input. Then we're just left with dealing with video, and that should be doable on a pi.

For most of the other suggestions here, ask yourself, can they offer KVM access to a BIOS? The one real alternative mentioned was arduino, and while it can handle keyboard/mouse unfortunately it doesn't look like it can handle the video.
Posts: 1
Joined: Wed Jul 31, 2013 10:46 pm
by GebekovAS » Sun Aug 10, 2014 4:54 pm
Here's an interesting link on the topic https://www.youtube.com/watch?v=Ua_5Uekg4tQ
Posts: 4
Joined: Mon Dec 09, 2013 8:15 am
by Fr4gg0r » Mon Oct 13, 2014 4:18 pm
Anyone trying to get this working for the model A?
There are now patches available for certain android devices, https://github.com/pelya/android-keyboard-gadget .
Posts: 15
Joined: Tue Mar 26, 2013 1:15 am
by Darlanio » Sat Nov 15, 2014 11:54 am
I would also like to emulate a PS/2 keyboard with my Raspberry pi, preferrably thru a library using bitbanging on the GPIO port and C-program or bash-script that controls what to be sent.

I need both the schematics for the wiring (PS/2 connector - GPIO) aswell as the software for the bitbanging, preferrably open source and downloadable, for a Raspberry PI Model B+.

I would also apprechiate any information on how to emulate a mouse using PS/2 aswell (moving mouse up/down/left/right and mousebuttons).

I am NOT interested in any specific software on the computer to have this keyboard connected to.

Someone wrote that a Raspberry Pi Model A have the hardware to emulate a USB-keyboard but that it was not possible at present. Is it only the software missing, or something else? Information regarding Emulation of a hardware USB-keyboard is welcome. And, no, still not intersted in installing any software on the computer which this "keyboard" will be connected to.

Please reply with all and any information.
Posts: 1
Joined: Sat Nov 15, 2014 11:46 am