Jesus Estrada
Jesus Estrada

Reputation: 1

Android Things: Raspberry Pi Gamepad usb

Someone knows how to implement the use of a usb gamepad for the raspberry pi in android things, I've tried all of UsbManager, InputDevice, but I could not make it work.

https://developer.android.com/training/game-controllers/controller-input https://developer.android.com/guide/topics/connectivity/usb/host

Upvotes: 0

Views: 483

Answers (2)

nondebug
nondebug

Reputation: 1021

Genuine SIXAXIS/Dualshock3 gamepads should work on most Linux-based OSes including Raspberry Pi and Android because they are supported through the hid-sony kernel module. Sometimes you need a newer kernel version to support newer devices, but DS3 support is old enough that you shouldn't need to update anything.

Is your gamepad a genuine Sony device? If it's a third party gamepad it probably won't work through hid-sony. It might still work as a generic HID gamepad.

You can check if Linux detects the device:

ls /dev/input/js*

"Joystick" devices on linux show up as /dev/input/js0, js1, js2, etc. If you don't see anything here it means the OS doesn't think it's a gamepad and it probably isn't going to work.

If Linux sees it but you can't access it through Android Things, I don't know what the issue is.

Upvotes: 0

shalafi
shalafi

Reputation: 3996

In principle Android Things should work the same as Android, so, most gamepads work just as HID devices and register the buttons as key presses, so you just need to override onKeyDown / onKeyUp.

In the case of a joystick with multiple positions you have a MotionEvent and you can override onGenericMotionEvent.

I know it is one of your links, but this what I have always done to add gamepad support on Android: https://developer.android.com/training/game-controllers/controller-input

Upvotes: 0

Related Questions