3

According to this website https://developer.android.com/training/game-controllers/multiple-controllers.html , Android seems to support multiple gamepads. Actually, it doesn't work when multiple input device event is occurred simultaneously. for example when player1 and player2 push the up button simultaneously, dipathKeyEvents are happened like below.

D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_UP,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP

And device:6's ACTION_UP is never happened.

They should be like this

D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D/dispatchKeyEvent(12736): device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP

Are there anyone who can manage multiple controller? Does NativeActivity resolve this problem?

My environment is

  • device: NVIDIA Shield TV
  • controller1: Shield controller
  • controller2: Playstation 3 controller connect via USB
  • OS: Android TV
devMiyax
  • 65
  • 1
  • 8

1 Answers1

0

There is a bug in Android that causes the onKeyDown/onKeyUp events from one controller to be sometimes misidentified as coming from the other one. This only happens with the D-pads, other buttons work fine. You can work around this bug by implementing onGenericMotionEvent and handling the D-pad events (AXIS_HAT_X, AXIS_HAT_Y) yourself. More info on the bug and the workaround: https://playjam.com/develop/guides/controller