Android 和 Guitar Hero 控制器
我知道最新版本的 Android(Honeycomb 和 ICS)支持操纵杆和游戏手柄。 Guitar Hero(和 Garage Band)控制器本质上是 USB HID 设备,对吗?
所以我的问题是: 是否可以从 Android 设备上的 Guitar Hero(或 Rock Band)控制器接收数据(按钮点击)? Android 会将其理解为游戏手柄输入吗?
PS 我所需要的只是在游戏中检测塑料吉他音品上这五个按钮的输入。
I know that the latest versions of Android (Honeycomb and ICS) have support for joysticks and gamepads.
Guitar Hero (and Garage Band) controllers are essentially USB HID devices, right?
So my question:
Is that possible to receive data (button clicks) from the Guitar Hero (or Rock Band) controllers on Android device?
Would the Android understand it as a gamepad input?
P.S. all I need is to detect in my game the input from those five buttons on the plastic guitar fret.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个好的起点是查看 Frets On Fire 的 Linux 源代码,它支持一些 Guitar Hero 控制器。
Frets on Fire:SourceForge
SVN:https://fretsonfire.svn.sourceforge.net/svnroot/fretsonfire
看起来很难普遍支持来自不同平台的所有控制器。每个控制台都有自己的协议,但它看起来确实像 操纵杆到键盘模拟可以在带有 PS3 控制器的 PC 上实现。第二个链接上有一个 PS3 控制器的配置文件,可能会有所帮助,它用于 JoyToKey(不是开源的),但配置中的一些值可能会对您有所帮助。
A good starting point would be to review the linux source code for Frets On Fire, which supports some of the Guitar Hero controllers.
Frets on Fire: SourceForge
SVN: https://fretsonfire.svn.sourceforge.net/svnroot/fretsonfire
It looks like it would be difficult to universally support all controllers, from different platforms. Each console has it's own protocol, but it does look like JoyStick to keyboard emulation is possible on the PC with the PS3 controller. There is a config file for the PS3 controller on the second link that may be helpful, it's for JoyToKey (which isn't open source), but some of the values in the config may help you.
嘿,这真是一个很酷的主意。从这里开始:
http://developer.android.com/guide/topics/usb/ host.html
然后,查看此示例:
http://developer.android.com/resources/samples/USB/MissileLauncher/index.html
在该示例中,有一个名为
setDevice(UsbDevice device) 的方法 如果我要实现此功能
,我将从
MissileLauncher
项目的副本开始,并修改此setDevice
方法。我将记录我能找到的有关UsbDevice 设备
的所有内容,并尝试在setDevice
方法中尝试这些条件:虽然
MissileLauncher
使用此< code>type 和这个endpointCount
,garageband 控制器很可能会有不同的值,还
可以查看
run
方法来查看来回的示例沟通免责声明:我不知道这是否有效。我也看到博客说这是不可能做到的。
Hey this is a really cool idea. start here:
http://developer.android.com/guide/topics/usb/host.html
Then, check out this sample:
http://developer.android.com/resources/samples/USB/MissileLauncher/index.html
in that sample, there is a method named
setDevice(UsbDevice device)
If I were implementing this, I would start with a duplicate of the
MissileLauncher
project, and modify thissetDevice
method. I would log everything I could possible find about theUsbDevice device
and try experimenting with these conditionals in thesetDevice
method:While the
MissileLauncher
uses thistype
and thisendpointCount
, it is very likely the garageband controller will have different valuesALSO
check out the
run
method to see an example of back and forth communicationDISCLAIMER: I have no idea if this will work. I've also seen blogs stating this cannot be done.
我的猜测是它应该检测数据。这甚至可以在现有的 Android 设备上实现 - 但它对 Android Market 不友好。
要在非 4.0 设备上实现此目的,您必须为 USB 端口提供备用电源。通常这可以通过一个会漏电的廉价 USB 集线器来完成。该设备还必须已扎根。完成此操作后,您需要创建一个设备 shell 接口,以在 Dalvik VM 之外启动 C 语言等本机语言。使用 C 绑定到适当的套接字,您应该能够来回传输数据。您可能还需要编译内核模块以提供驱动程序支持。
正如我所说,这是针对 4.0 以下设备的完整破解。但这是可能的。
My guess is it should detect data. This is even possible on existing Android devices - but it is not Android Market friendly.
To accomplish this on non-4.0 devices you must provide an alternative power source to the usb port. Usually this can be done with a cheap usb hub that leaks power. The device also must be rooted. Once this is complete you need to create an interface to the device shell to launch a native language like C outside of your Dalvik VM. Use your C to bind to the appropriate socket and you should be able to bus data back and forth. You may also need to compile a kernel module to give driver support.
Like I said this is a complete hack for device below 4.0. But it is possible.