0
我通過dispatchGenericMotionEvent(android.view. MotionEvent)
方法從我的藍牙手柄控制器接收軸位置。 我的方法:獲取當前的android遊戲手柄軸位置
@Override
public boolean dispatchGenericMotionEvent(final MotionEvent event) {
if(mPadListener==null ||
(event.getSource()&InputDeviceCompat.SOURCE_JOYSTICK)!=InputDeviceCompat.SOURCE_JOYSTICK){
return super.dispatchGenericMotionEvent(event);
}
int historySize = event.getHistorySize();
for (int i = 0; i < historySize; i++) {
// Process the event at historical position i
Log.d("JOYSTICKMOVE",event.getHistoricalAxisValue(MotionEvent.AXIS_Y,i)+" "+event.getHistoricalAxisValue(MotionEvent.AXIS_Z,i));
}
// Process current position
Log.d("JOYSTICKMOVE",event.getAxisValue(MotionEvent.AXIS_Y)+" "+event.getAxisValue(MotionEvent.AXIS_Z));
return true;
}
的問題是,當我釋放所有搖桿軸,我不會在我的日誌越來越最後軸值(0,0)。例如在(0.23,0.11)中停止,並且只有在下一個移動事件之後纔會在logcat中顯示相應的值。更重要的是 - 即使我按下正常按鈕,情況也是一樣的(按鈕事件被其他方法完全捕獲dispatchKeyEvent(android.view.KeyEvent)
)
發生了什麼事?