我试图区分操纵杆和方向键输入。我总是得到相同的事件源(16777232)。不管我是按下方向键还是转动操纵杆。
我正在使用 ipega 游戏控制器
我的问题是:
第一:
当我将左操纵杆向右转动时:
1. dispatchGenericMotionEvent(MotionEvent motionEvent)
被触发。
a= 16777232(SOURCE_JOYSTICK)
2.它会转发到dispatchKeyEvent(KeyEvent event)
第二:
当我将右摇杆向右转动时:
1.ispatchGenericMotionEvent(MotionEvent motionEvent)
被触发。和
a= 16777232(SOURCE_JOYSTICK)
2. 它确实转发到dispatchKeyEvent(KeyEvent event)
第三:
当我按下左/右/上/下 d-pad 按钮时:
1.ispatchGenericMotionEvent(MotionEvent motionEvent)
被触发。
a= 16777232(SOURCE_JOYSTICK)
2.它会转发到dispatchKeyEvent(KeyEvent event)
@Override
public boolean dispatchGenericMotionEvent(MotionEvent motionEvent)
{
int a=motionEvent.getSource();
return super.dispatchGenericMotionEvent(motionEvent);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int a=motionEvent.getSource();
return super.dispatchKeyEvent(event);
}