rim
Posts: 6
Joined: Sat Mar 03, 2012 3:22 pm

Re: Connecting to a computer as a USB HID device

Sat Mar 03, 2012 3:55 pm

Hi there,

I need to connect a Pi to a computer via USB in order to emulate a keyboard and mouse.  I need to do this on the PCs without special drivers because this is in an environment where I cannot load extra software on the machines and where there are multiple OS's involved.  I also need to retain the ability to use the Pi network port for networking; the Pi will get it's control data from a server and this server is on an isolated network from the host PC connected to the Pi.

It would be nice to do this with the micro USB port, but I understand that on the Pi this port can only be used for power.

I was thinking of using a USB type B socket and jumpers to the micro USB port for power, and to the USB type A port for data.  Then I would just need to use software on the Pi to convert the USB ports from host to device/slave/client mode...

Any thoughts, ideas, directions or suggestions out there?

Thanks,

Ian

mole125
Posts: 228
Joined: Tue Jan 10, 2012 2:01 pm

Re: Connecting to a computer as a USB HID device

Sat Mar 03, 2012 6:15 pm

From previous discussions (search the forums for other threads I've posted on) it is going to be very hard to impossible to switch the Pi to client mode.

For what you are wanting to do the the easiest solution is probably either:

1. Get add an additional usb port connected to a microcontroller like a Pic and then interface from the RPi to the pic.

2. Use PS/2 either directly into the computer or via a PS/2 to USB adapter and then connect the appropriate pins to the GPIO ports (not sure on voltage levels so may be safest to use an optocoupler or similar to protect the RPi). Generate PS/2 control signals as if you are the keyboard.

The following technical note contains details to help towards both of the above approaches.

http://ww1.microchip.com/downl.....91056C.pdf

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Connecting to a computer as a USB HID device

Sat Mar 03, 2012 7:15 pm

It definitely will not be possible on the Model B as the LAN9512 chip will be in the way.  I won't say it's impossible on the model A, but someone will have to do a lot of work to work out a driver that would make it possible.
Dear forum: Play nice ;-)

rim
Posts: 6
Joined: Sat Mar 03, 2012 3:22 pm

Re: Connecting to a computer as a USB HID device

Mon Mar 05, 2012 4:21 am

That's what I feared...  It's too bad that the micro USB port couldn't be used in this way.  When I first saw the Pi, knowing that it had an educational audience I automatically thought that connecting it in device mode would of been an option.

Thanks

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Connecting to a computer as a USB HID device

Mon Mar 05, 2012 5:13 am

yeah the micro usb port only has the power pins connected.  It doesn't provide any sort of data.  Basically they're using the micro-usb form factor due to it being accepted as the standard for upcoming devices so people should be able to find (or already have) an appropriate charger on the cheap!
Dear forum: Play nice ;-)

plugwash
Forum Moderator
Forum Moderator
Posts: 3545
Joined: Wed Dec 28, 2011 11:45 pm

Re: Connecting to a computer as a USB HID device

Mon Mar 05, 2012 4:34 pm

As abishur says the Pi will not be able to do what you want directly. You could add a microcontroller to receive data from the Pi and emulate a keyboard/mouse but once you add the cost of the microcontroller and the custom board to connect it to the Pis GPIO I doubt it will be worth it. I think this is a case where the Pi is simply not the right tool for the job.

The beaglebone should be able to do what you want with the caveat that in addition to the USB device funtionality in the arm there is also a FTDI chip connected to the device port via a USB hub so if you don't want the host machine to see the FTDI chip you would have to either remove the FTDI chip or cut the USB traces going to it.

TechColab
Posts: 27
Joined: Tue Mar 06, 2012 10:27 am

Re: Connecting to a computer as a USB HID device

Tue Mar 06, 2012 10:47 am

I've had a good look at the Teensy USB Development Board ..

http://www.pjrc.com/teensy/index.html

.. as used in a project to controll a PS3 ..

http://gimx.fr/forum/viewtopic.....&t=22

.. the code for which all sems to be free and/or open.

The simplest version is only USD16 and may be easier than re-inventing the wheel.

Although direct implemetation of PS/2 keyboars & mouse would be cheaper if the protocols are known, or ideally already in a library.

I too want to do this as I think it should be possible to build a RPi based version of this ..

http://www.epiphan.com/product.....s/vga2usb/

.. but with the capture spec. of this ..

http://www.epiphan.com/product.....ga2usb-lr/

.. for under £100 by using one of these ..

http://uk.rs-online.com/web/p/.....c/6977482/

Return to “Other projects”