2

Is it possible for a public sdk only app write a "driver" to an input device, like a joystick that uses some vague, possibly alien, protocol over USB using the new 3.1 USB Apis?

For example, would it be possible to implement a driver for the brand-new-just-out-the-door O-Triangle 3.15 Controller with 13 joysticks and 159 buttons and virtual head tracking and soda dispenser, or would this have to wait for android to be updated with a new low-level driver for the O-Triangle 3.15's controller

Amanda
  • 213
  • 2
  • 9

2 Answers2

0

It does look like you can do it with the classes in the android.hardware.usb package: you can implement a Service that detects insert/remove of the device and generates the appropriate InputEvents. Not sure if any application that wants to use that device would have to include the Service in its apk, or if you can do a separate package that feeds the necessary events to the OS input subsystem, though.

Femi
  • 64,273
  • 8
  • 118
  • 148
  • Yeah my question was aimed at a system-wide implementation, not for just a single app, and as far as I am aware only a keyboard app can generate input events, which is less than ideal because of the fact you want to be able to input normal text as well. – Amanda Jun 13 '11 at 00:47
  • Well, you can certainly tie your input method to USB hardware under the hood, no? – Femi Jun 13 '11 at 03:11
  • Yeah that part I can understand, what I can't figure out is if you could send these events to all applications listening for the events without replacing the user's selected text input method, which I feel is rather hackish and way less than ideal. – Amanda Jun 14 '11 at 18:34
  • OK. "You CAN implement a service..." but any clue on HOW? – Behnam Nov 24 '14 at 05:52
0

We have had success writing to USB devices without kernel drivers using this code: http://android.serverbox.ch/?p=370

We are able to write generic bulk packets to the USB endpoints. I would imagine that you could do the same for other types of USB devices (HID, etc). Note that the Samsung Galaxy Tab 10.1 seems to lack the components required to discover USB devices properly (as of the 3.1 touchwiz update). However it works for us on an Acer A500.

I don't know about making it system-wide, but I imagine it could be. I'd suggest looking at how the Wiimote apps do it. I know you can download apps that let you pair a Wiimote with the phone and then use it as a general purpose controller for games etc.

Also, I'd really like a controller with 13 Joysticks and a soda dispenser! ;)

Taylor Alexander
  • 844
  • 7
  • 12
  • It is my understanding that the Wii Controller apps pretend to be a keyboard to send the synthisized events, though I have no first hand experience to say one way or the other. – Amanda Dec 07 '11 at 00:36