根据这个网站https://developer.android.com/training/game-controllers/multiple-controllers.html,Android似乎支持多个游戏手柄。实际上,当同时发生多个输入设备事件时,它不起作用。例如,当player1和player2同时按下向上按钮时,dipathKeyEvents发生如下。
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
并且设备:6' ACTION_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 D / dispatchKeyEvent(12736):device:6,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP D / dispatchKeyEvent(12736):device:1,action:ACTION_DOWN,keyCoe:KEYCODE_DPAD_UP
有没有人可以管理多个控制器? NativeActivity是否解决了这个问题?
我的环境是
答案 0 :(得分:0)
Android中存在一个错误,导致来自一个控制器的onKeyDown / onKeyUp事件有时被错误识别为来自另一个控制器。这只发生在D-pad上,其他按钮工作正常。您可以通过实现onGenericMotionEvent并自己处理D-pad事件(AXIS_HAT_X,AXIS_HAT_Y)来解决此错误。有关错误和解决方法的更多信息:https://playjam.com/develop/guides/controller