@Override public boolean onKeyDown(int keyCode, KeyEvent keyEvent) { // Log.i(TAG, "onKeyDown keyCode=" + DebugInput.debugGetButtonName(keyCode)); int playerNum = OuyaController.getPlayerNumByDeviceId(keyEvent.getDeviceId()); if (playerNum < 0) { Log.e(TAG, "Failed to find playerId for Controller=" + keyEvent.getDevice().getName()); return true; } int action = keyEvent.getAction(); dispatchKeyEventNative(playerNum, keyCode, action); return true; }
@Override public boolean onGenericMotionEvent(MotionEvent motionEvent) { // DebugInput.debugMotionEvent(motionEvent); int playerNum = OuyaController.getPlayerNumByDeviceId(motionEvent.getDeviceId()); if (playerNum < 0) { Log.e(TAG, "Failed to find playerId for Controller=" + motionEvent.getDevice().getName()); return true; } dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_LS_X, motionEvent.getAxisValue(OuyaController.AXIS_LS_X)); dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_LS_Y, motionEvent.getAxisValue(OuyaController.AXIS_LS_Y)); dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_RS_X, motionEvent.getAxisValue(OuyaController.AXIS_RS_X)); dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_RS_Y, motionEvent.getAxisValue(OuyaController.AXIS_RS_Y)); dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_L2, motionEvent.getAxisValue(OuyaController.AXIS_L2)); dispatchGenericMotionEventNative( playerNum, OuyaController.AXIS_R2, motionEvent.getAxisValue(OuyaController.AXIS_R2)); return true; }