HID 标准输入手柄的缺点
- 会操作 手机上的home建、返回键、会操作选择;需要对onKeyDown 事件进行重写,最好重写onGenericMotionEvent,会操作摇杆,和上下左右,压力值按键
@Override
public boolean onGenericMotionEvent(MotionEvent arg15) {
return true;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return CommonUtils.isConfirmKey(keyCode) || super.onKeyDown(keyCode, event);
}
public static boolean isConfirmKey(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_BUTTON_A:
case KeyEvent.KEYCODE_BUTTON_B:
case KeyEvent.KEYCODE_BUTTON_C:
case KeyEvent.KEYCODE_BUTTON_X:
case KeyEvent.KEYCODE_BUTTON_Y:
case KeyEvent.KEYCODE_BUTTON_Z:
case KeyEvent.KEYCODE_BUTTON_L1:
case KeyEvent.KEYCODE_BUTTON_R1:
case KeyEvent.KEYCODE_BUTTON_L2:
case KeyEvent.KEYCODE_BUTTON_R2:
case KeyEvent.KEYCODE_BUTTON_THUMBL:
case KeyEvent.KEYCODE_BUTTON_THUMBR:
case KeyEvent.KEYCODE_BUTTON_START:
case KeyEvent.KEYCODE_BUTTON_SELECT:
case KeyEvent.KEYCODE_BUTTON_MODE:
case KeyEvent.KEYCODE_BUTTON_1:
case KeyEvent.KEYCODE_BUTTON_2:
case KeyEvent.KEYCODE_BUTTON_3:
case KeyEvent.KEYCODE_BUTTON_4:
case KeyEvent.KEYCODE_BUTTON_5:
case KeyEvent.KEYCODE_BUTTON_6:
case KeyEvent.KEYCODE_BUTTON_7:
case KeyEvent.KEYCODE_BUTTON_8:
case KeyEvent.KEYCODE_BUTTON_9:
case KeyEvent.KEYCODE_BUTTON_10:
case KeyEvent.KEYCODE_BUTTON_11:
case KeyEvent.KEYCODE_BUTTON_12:
case KeyEvent.KEYCODE_BUTTON_13:
case KeyEvent.KEYCODE_BUTTON_14:
case KeyEvent.KEYCODE_BUTTON_15:
case KeyEvent.KEYCODE_BUTTON_16:
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
case KeyEvent.KEYCODE_SPACE:
case KeyEvent.KEYCODE_NUMPAD_ENTER:
return true;
default:
return false;
}
}
HID模式的鼠标键盘缺点
- HID模式的鼠标,可唤出手机上的鼠标指示键,但是游戏中鼠标指示键的点击是不给予识别的,所以在游戏中操作不了,