本文整理了Java中android.view.KeyEvent.getDeviceId()
方法的一些代码示例,展示了KeyEvent.getDeviceId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getDeviceId()
方法的具体详情如下:
包路径:android.view.KeyEvent
类名称:KeyEvent
方法名:getDeviceId
暂无
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public boolean onKey(KeyEvent event) {
boolean consumed = false;
// logger.log(Level.INFO, "onKey event: {0}", event);
event.getDeviceId();
event.getSource();
AndroidJoystick joystick = joystickIndex.get(event.getDeviceId());
if (joystick != null) {
JoystickButton button = joystick.getButton(event.getKeyCode());
boolean pressed = event.getAction() == KeyEvent.ACTION_DOWN;
if (button != null) {
JoyButtonEvent buttonEvent = new JoyButtonEvent(button, pressed);
joyInput.addEvent(buttonEvent);
consumed = true;
} else {
JoystickButton newButton = joystick.addButton(event.getKeyCode());
JoyButtonEvent buttonEvent = new JoyButtonEvent(newButton, pressed);
joyInput.addEvent(buttonEvent);
consumed = true;
}
}
return consumed;
}
代码示例来源:origin: libgdx/libgdx
return false;
AndroidController controller = controllerMap.get(keyEvent.getDeviceId());
if(controller != null) {
if(controller.getButton(keyCode) && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
代码示例来源:origin: rockon999/LeanbackLauncher
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
if (Util.isConfirmKey(event.getKeyCode())) {
if (event.isLongPress()) {
this.mEatDpadCenterKeyDown = true;
Util.playErrorSound(getContext());
return true;
} else if (action == 1) {
if (this.mEatDpadCenterKeyDown) {
this.mEatDpadCenterKeyDown = false;
return true;
}
this.mClickDeviceId = event.getDeviceId();
}
}
return super.dispatchKeyEvent(event);
}
代码示例来源:origin: MoMoWait/LeanbackLauncher
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
if (Util.isConfirmKey(event.getKeyCode())) {
if (event.isLongPress()) {
this.mEatDpadCenterKeyDown = true;
Util.playErrorSound(getContext());
return true;
} else if (action == 1) {
if (this.mEatDpadCenterKeyDown) {
this.mEatDpadCenterKeyDown = false;
return true;
}
this.mClickDeviceId = event.getDeviceId();
}
}
return super.dispatchKeyEvent(event);
}
代码示例来源:origin: limboemu/limbo
if (SDLControllerManager.isDeviceSDLJoystick(event.getDeviceId())) {
if (SDLControllerManager.onNativePadDown(event.getDeviceId(), keyCode) == 0) {
return true;
if (SDLControllerManager.onNativePadUp(event.getDeviceId(), keyCode) == 0) {
return true;
代码示例来源:origin: JimSeker/bluetooth
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
int deviceId = event.getDeviceId();
if (deviceId != -1) {
Ship currentShip = getShipForId(deviceId);
if (currentShip.onKeyDown(keyCode, event)) {
step(event.getEventTime());
return true;
}
}
return super.onKeyDown(keyCode, event);
}
代码示例来源:origin: JimSeker/bluetooth
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
int deviceId = event.getDeviceId();
if (deviceId != -1) {
Ship currentShip = getShipForId(deviceId);
if (currentShip.onKeyUp(keyCode, event)) {
step(event.getEventTime());
return true;
}
}
return super.onKeyUp(keyCode, event);
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Update device state for visualization and logging.
InputDeviceState state = getInputDeviceState(event.getDeviceId());
if (state != null) {
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
if (state.onKeyDown(event)) {
mSummaryAdapter.show(state);
}
break;
case KeyEvent.ACTION_UP:
if (state.onKeyUp(event)) {
mSummaryAdapter.show(state);
}
break;
}
}
return super.dispatchKeyEvent(event);
}
代码示例来源:origin: li2/learning-android-open-source
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Update device state for visualization and logging.
InputDeviceState state = getInputDeviceState(event.getDeviceId());
if (state != null) {
switch (event.getAction()) {
case KeyEvent.ACTION_DOWN:
if (state.onKeyDown(event)) {
mSummaryAdapter.show(state);
}
break;
case KeyEvent.ACTION_UP:
if (state.onKeyUp(event)) {
mSummaryAdapter.show(state);
}
break;
}
}
return super.dispatchKeyEvent(event);
}
代码示例来源:origin: PhilippC/keepass2android
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT:
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
// Enable shift key and DPAD to do selections
if (inputView != null && inputView.isShown()
&& inputView.isShifted()) {
event = new KeyEvent(event.getDownTime(), event.getEventTime(),
event.getAction(), event.getKeyCode(), event.getRepeatCount(),
event.getDeviceId(), event.getScanCode(),
KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON);
InputConnection ic = getCurrentInputConnection();
if (ic != null) ic.sendKeyEvent(event);
return true;
}
break;
}
return super.onKeyUp(keyCode, event);
}
内容来源于网络,如有侵权,请联系作者删除!