Is it possible to write a driver for the input system in android

允我心安 提交于 2019-12-21 20:59:49

问题


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


回答1:


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.




回答2:


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! ;)



来源:https://stackoverflow.com/questions/6325151/is-it-possible-to-write-a-driver-for-the-input-system-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!