@Override public void onInputEvent(InputEvent event) { boolean handled = false; try { if (event instanceof MotionEvent && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { MotionEvent dup = MotionEvent.obtainNoHistory((MotionEvent) event); dispatchPointer(dup); handled = true; } } finally { finishInputEvent(event, handled); } }
// We simply grab the first input device to produce an event and ignore all others that are // connected. @TargetApi(Build.VERSION_CODES.GINGERBREAD) private InputDeviceState getInputDeviceState(InputEvent event) { InputDevice device = event.getDevice(); if (device == null) { return null; } if (inputPlayerA == null) { inputPlayerADesc = getInputDesc(device); Log.i(TAG, "Input player A registered: desc = " + inputPlayerADesc); inputPlayerA = new InputDeviceState(device); } if (inputPlayerA.getDevice() == device) { return inputPlayerA; } if (inputPlayerB == null) { Log.i(TAG, "Input player B registered: desc = " + getInputDesc(device)); inputPlayerB = new InputDeviceState(device); } if (inputPlayerB.getDevice() == device) { return inputPlayerB; } if (inputPlayerC == null) { Log.i(TAG, "Input player C registered"); inputPlayerC = new InputDeviceState(device); } if (inputPlayerC.getDevice() == device) { return inputPlayerC; } return inputPlayerA; }