英文:
Is it possible to use a wiimote as an android game controller?
问题
我长时间以来一直对将Wiimote用作Android控制器感兴趣。
我知道在多年前,Android API中创建l2cap socket的方法被移除之前,这是可能的。
在api 29(Android 10)中,添加了创建l2cap socket的方法,因此从理论上讲,现在应该可以将Wiimote用作控制器。
我像这样创建并尝试连接socket:
BluetoothSocket socket = mWiimote.createInsecureL2capChannel(0x13);
socket.connect();
这里的0x13
是Wiimote数据通道的PSM,如此处所述:
https://wiibrew.org/wiki/Wiimote#HID_Interface
我也尝试连接到控制通道,但无济于事。
我只得到:
java.io.IOException: read failed, socket might closed or timeout, read ret -1
其他人在尝试连接Wii平衡板时也遇到了相同的问题:
https://stackoverflow.com/questions/59996168/android-10-l2cap-connection-ioexception-timeout-wii-balance-board
他们已经成功配对了平衡板,但我尝试失败了,据我了解,这需要特权蓝牙权限,因为您必须根据按下的按钮设置键(主机或控制器的mac地址,反向)来使Wiimote可被发现。我不确定这个人是否在使用特权权限(并且将他们的应用程序放在/priv-app/
文件夹中),或者他们是否有其他解决方法。
英文:
I have been interested in using a Wiimote as a controller for Android for a long time.
I know this was possible many years ago before the methods for creating an l2cap socket were removed from the Android api.
In api 29 (Android 10) methods for creating an l2cap socket were added, so theoretically it should now be possible to to use a Wiimote as a controller.
I create and try to connect to the socket like this:
BluetoothSocket socket = mWiimote.createInsecureL2capChannel(0x13);
socket.connect();
Where 0x13
is the PSM of the Wiimote data pipe, as stated here:
https://wiibrew.org/wiki/Wiimote#HID_Interface
I have tried connecting to the control pipe aswell to no avail.
I just get:
java.io.IOException: read failed, socket might closed or timeout, read ret -1
Someone else has the same issue trying to connect a Wii Balance Board:
https://stackoverflow.com/questions/59996168/android-10-l2cap-connection-ioexception-timeout-wii-balance-board
They have managed to pair with the Balance Board but I have been unsuccessful, from what I understand this requires the privileged bluetooth permission as you have to set the key (mac address of the host or controller, backwards) depending the buttons pressed to make the Wiimote discoverable. I am unsure if this person is using the privileged permission (and has their app in the /priv-app/
folder), or they have
a workaround.
专注分享java语言的经验与见解,让所有开发者获益!
评论