本文整理汇总了Java中android.view.KeyEvent.getScanCode方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getScanCode方法的具体用法?Java KeyEvent.getScanCode怎么用?Java KeyEvent.getScanCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.getScanCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyEvent
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
protected boolean onKeyEvent(KeyEvent event) {
if (Methods.isHeadSetUse(this) && CheckCalling()) {
if (scancode_up != 0 && scancode_down != 0) {
int keycode = event.getKeyCode();
int scancode = event.getScanCode();
int keyaction = event.getAction();
boolean longpressmode = Methods.getLongPressGet(sp);
if (keycode == KeyEvent.KEYCODE_VOLUME_UP && scancode == scancode_up) {
if (keyaction == KeyEvent.ACTION_DOWN) {
KeyUpAction(event, longpressmode, 1);
} else if (keyaction == KeyEvent.ACTION_UP && LongPressed) {
LongPressed = false;
if (Methods.getLongPressCustom(sp)) {
Methods.sendKeyCode(this, KeyEvent.KEYCODE_MEDIA_PREVIOUS, process, output, Methods.getLongPressSend(sp));
} else {
Methods.sendKeyCode(this, KeyEvent.KEYCODE_VOLUME_UP, process, output, Methods.getLongPressSend(sp));
}
}
return true;
} else if (keycode == KeyEvent.KEYCODE_VOLUME_DOWN && scancode == scancode_down) {
if (keyaction == KeyEvent.ACTION_DOWN) {
KeyUpAction(event, longpressmode, 2);
} else if (keyaction == KeyEvent.ACTION_UP && LongPressed) {
LongPressed = false;
if (Methods.getLongPressCustom(sp)) {
Methods.sendKeyCode(this, KeyEvent.KEYCODE_MEDIA_NEXT, process, output, Methods.getLongPressSend(sp));
} else {
Methods.sendKeyCode(this, KeyEvent.KEYCODE_VOLUME_DOWN, process, output, Methods.getLongPressSend(sp));
}
}
return true;
}
} else {
Toast.makeText(this, R.string.correct_device, Toast.LENGTH_SHORT).show();
}
}
return false;
}
示例2: onKeyDown
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
onAnyKeyDown();
switch (event.getScanCode()) {
case ScalarInput.ISV_KEY_UP:
return onUpKeyDown();
case ScalarInput.ISV_KEY_DOWN:
return onDownKeyDown();
case ScalarInput.ISV_KEY_LEFT:
return onLeftKeyDown();
case ScalarInput.ISV_KEY_RIGHT:
return onRightKeyDown();
case ScalarInput.ISV_KEY_ENTER:
return onEnterKeyDown();
case ScalarInput.ISV_KEY_FN:
return onFnKeyDown();
case ScalarInput.ISV_KEY_AEL:
return onAelKeyDown();
case ScalarInput.ISV_KEY_MENU:
case ScalarInput.ISV_KEY_SK1:
return onMenuKeyDown();
case ScalarInput.ISV_KEY_S1_1:
return onFocusKeyDown();
case ScalarInput.ISV_KEY_S1_2:
return true;
case ScalarInput.ISV_KEY_S2:
return onShutterKeyDown();
case ScalarInput.ISV_KEY_PLAY:
return onPlayKeyDown();
case ScalarInput.ISV_KEY_STASTOP:
return onMovieKeyDown();
case ScalarInput.ISV_KEY_CUSTOM1:
return onC1KeyDown();
case ScalarInput.ISV_KEY_DELETE:
case ScalarInput.ISV_KEY_SK2:
return onDeleteKeyDown();
case ScalarInput.ISV_KEY_LENS_ATTACH:
return onLensAttached();
case ScalarInput.ISV_DIAL_1_CLOCKWISE:
case ScalarInput.ISV_DIAL_1_COUNTERCW:
return onUpperDialChanged(getDialStatus(ScalarInput.ISV_DIAL_1_STATUS) / 22);
case ScalarInput.ISV_DIAL_2_CLOCKWISE:
case ScalarInput.ISV_DIAL_2_COUNTERCW:
return onLowerDialChanged(getDialStatus(ScalarInput.ISV_DIAL_2_STATUS) / 22);
case ScalarInput.ISV_DIAL_3_CLOCKWISE:
case ScalarInput.ISV_DIAL_3_COUNTERCW:
return onThirdDialChanged(getDialStatus(ScalarInput.ISV_DIAL_3_STATUS) / 22);
case ScalarInput.ISV_DIAL_KURU_CLOCKWISE:
case ScalarInput.ISV_DIAL_KURU_COUNTERCW:
return onKuruDialChanged(getDialStatus(ScalarInput.ISV_DIAL_KURU_STATUS) / 22);
case ScalarInput.ISV_KEY_MODE_DIAL:
return onModeDialChanged(getDialStatus(ScalarInput.ISV_KEY_MODE_DIAL));
default:
return super.onKeyDown(keyCode, event);
}
}
示例3: onKeyUp
import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
onAnyKeyUp();
switch (event.getScanCode()) {
case ScalarInput.ISV_KEY_UP:
return onUpKeyUp();
case ScalarInput.ISV_KEY_DOWN:
return onDownKeyUp();
case ScalarInput.ISV_KEY_LEFT:
return onLeftKeyUp();
case ScalarInput.ISV_KEY_RIGHT:
return onRightKeyUp();
case ScalarInput.ISV_KEY_ENTER:
return onEnterKeyUp();
case ScalarInput.ISV_KEY_FN:
return onFnKeyUp();
case ScalarInput.ISV_KEY_AEL:
return onAelKeyUp();
case ScalarInput.ISV_KEY_MENU:
case ScalarInput.ISV_KEY_SK1:
return onMenuKeyUp();
case ScalarInput.ISV_KEY_S1_1:
return onFocusKeyUp();
case ScalarInput.ISV_KEY_S1_2:
return true;
case ScalarInput.ISV_KEY_S2:
return onShutterKeyUp();
case ScalarInput.ISV_KEY_PLAY:
return onPlayKeyUp();
case ScalarInput.ISV_KEY_STASTOP:
return onMovieKeyUp();
case ScalarInput.ISV_KEY_CUSTOM1:
return onC1KeyUp();
case ScalarInput.ISV_KEY_DELETE:
case ScalarInput.ISV_KEY_SK2:
return onDeleteKeyUp();
case ScalarInput.ISV_KEY_LENS_ATTACH:
return onLensDetached();
case ScalarInput.ISV_DIAL_1_CLOCKWISE:
case ScalarInput.ISV_DIAL_1_COUNTERCW:
return true;
case ScalarInput.ISV_DIAL_2_CLOCKWISE:
case ScalarInput.ISV_DIAL_2_COUNTERCW:
return true;
case ScalarInput.ISV_KEY_MODE_DIAL:
return true;
default:
return super.onKeyUp(keyCode, event);
}
}