Android USB HID Device

radders picture radders · Feb 3, 2011 · Viewed 8k times · Source

Does anyone know how to configure an Android device (tablet) to appear as a USB HID device when connected to a PC? Is there any other way of getting data from the tablet to the PC (via USB) other than writing it to a file, and have the PC retrieve the (updated) file from the tablet which is acting as a 'mass storage device' for the PC? Can USB carry a TCP/IP end-end connection? Using a tablet as a high-end intelligent 'keyboard' or 'mouse' or similar device would be immensely powerful, and open up lots of possibilities. Controlling a model railway layout is the end I have in mind. Thanks

Answer

insitusec picture insitusec · Dec 6, 2012

It's possible to do this using the linux gadget framework http://www.linux-usb.org/gadget/ using a custom composite USB device. The gadget framework is part of the Android kernel source tree by inheritance from Linux.

Unfortunately, Android has its own customizations that restrict the ability to dynamically register new USB gadgets so you will need to patch the kernel source tree for your particular device and add your HID gadget (otherwise you could create a module and load it that way) to the supported Android list.

I have done this before and will update this answer to contain more detail if there is interest. Unfortunately I lost the code so I will have to start from scratch.