@Override public String getJoystickDescriptor(InputDevice joystickDevice) { String desc = joystickDevice.getDescriptor(); if (desc != null && !desc.isEmpty()) { return desc; } return super.getJoystickDescriptor(joystickDevice); } }
/** * Saves the provided key input setting both to the INI file (so native code can use it) and as * an Android preference (so it persists correctly and is human-readable.) * * @param keyEvent KeyEvent of this key press. */ private void saveKeyInput(KeyEvent keyEvent) { InputDevice device = keyEvent.getDevice(); String bindStr = "Device '" + device.getDescriptor() + "'-Button " + keyEvent.getKeyCode(); String uiString = device.getName() + ": Button " + keyEvent.getKeyCode(); saveInput(bindStr, uiString); }
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (mMenuVisible) { return super.dispatchKeyEvent(event); } int action; switch (event.getAction()) { case KeyEvent.ACTION_DOWN: // Handling the case where the back button is pressed. if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { onBackPressed(); return true; } // Normal key events. action = NativeLibrary.ButtonState.PRESSED; break; case KeyEvent.ACTION_UP: action = NativeLibrary.ButtonState.RELEASED; break; default: return false; } InputDevice input = event.getDevice(); return NativeLibrary.onGamePadEvent(input.getDescriptor(), event.getKeyCode(), action); }
/** * Saves the provided motion input setting both to the INI file (so native code can use it) and as * an Android preference (so it persists correctly and is human-readable.) * * @param device InputDevice from which the input event originated. * @param motionRange MotionRange of the movement * @param axisDir Either '-' or '+' */ private void saveMotionInput(InputDevice device, InputDevice.MotionRange motionRange, char axisDir) { String bindStr = "Device '" + device.getDescriptor() + "'-Axis " + motionRange.getAxis() + axisDir; String uiString = device.getName() + ": Axis " + motionRange.getAxis() + axisDir; saveInput(bindStr, uiString); }
consumed = NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, axisValues[0], axisValues[1]); consumed = NativeLibrary.onGamePadMoveEvent(input.getDescriptor(), axis, 0.0f, 0.0f); return NativeLibrary.onGamePadAxisEvent(input.getDescriptor(),axis, value) || consumed;
if (null != dev) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { deviceString = dev.getDescriptor(); } else { deviceString = dev.getName();