Android: listing buttons on a gamepad

I have an Android device that can connect a gamepad (this is a completely standard XBox 360 controller, but I need to also support other options). The gamepad appears as an InputDevice with some analog axes and some buttons.

I need to be able to request Android to find out which buttons the gamepad supports. Does anyone know how to do this?

I know that the system has this information, because if I write an application from the command line that opens /dev/input/event...and requests buttons using EVIOCGBITioctl, I get a good list of supported buttons from the kernel. But I can not do this from the Android application, because I do not have permission to access input devices directly.

It looks like you can get the InputDevice KeyCharacterMap object and request it; but it looks like Android has connected the default QWERTY keyboard keyboard to the gamepad, instead of constructing one that actually matches what the gamepad supports. This will happily tell me that the gamepad has a Q key that does not exist, and that it does not have the BUTTON_X key that it makes, and for which I receive key events. In order not to help.

Is there any way to do this?

+5
source share
1 answer

I haven't figured out the way yet, but I found a terrible workaround.

KeyCharacterMap.deviceHasKey(keycode), Android, - . , (, KeyEvent.KEYCODE_BUTTON_something), , .

. XBox 360 Wiimote, , XBox 1 2, Wiimote X Y, . , , .

- , , ...

+1

All Articles