问题
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: 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.
来源:https://stackoverflow.com/questions/61029057/is-it-possible-to-use-a-wiimote-as-an-android-game-controller