List of usage examples for android.view KeyEvent getDevice
public final InputDevice getDevice()
From source file:com.example.android.visualgamecontroller.FullscreenActivity.java
@Override public boolean onKeyUp(final int keyCode, KeyEvent ev) { // Log.d(TAG, "onKeyUp: " + ev); InputDevice device = ev.getDevice(); // Only care about game controllers. if (device != null && device.getId() == mCurrentDeviceId) { if (isGamepad(device)) { int index = getButtonMappingIndex(keyCode); if (index >= 0) { mButtons[index] = 0;/* w ww. ja v a2 s. com*/ mControllerView.invalidate(); } return true; } } return super.onKeyUp(keyCode, ev); }
From source file:com.example.android.visualgamecontroller.FullscreenActivity.java
@Override public boolean onKeyDown(final int keyCode, KeyEvent ev) { // Log.d(TAG, "onKeyDown: " + ev); InputDevice device = ev.getDevice(); // Only care about game controllers. if (device != null && device.getId() == mCurrentDeviceId) { if (isGamepad(device)) { int index = getButtonMappingIndex(keyCode); if (index >= 0) { mButtons[index] = 1;/*from w w w . j av a 2 s. com*/ mControllerView.invalidate(); } return true; } } return super.onKeyDown(keyCode, ev); }