Java Code Examples for android.view.KeyEvent#keyCodeToString()
The following examples show how to use
android.view.KeyEvent#keyCodeToString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyMapperActivity.java From J2ME-Loader with Apache License 2.0 | 6 votes |
private void showMappingDialog(int canvasKey) { int id = androidToMIDP.indexOfValue(canvasKey); String keyName = ""; if (id >= 0) { keyName = KeyEvent.keyCodeToString(androidToMIDP.keyAt(id)); } AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(R.string.mapping_dialog_title) .setMessage(getString(R.string.mapping_dialog_message, keyName)) .setOnKeyListener((dialog, keyCode, event) -> { if (keyCode == KeyEvent.KEYCODE_BACK) { dialog.dismiss(); return false; } else { deleteDuplicates(canvasKey); androidToMIDP.put(keyCode, canvasKey); KeyMapper.saveArrayPref(params, androidToMIDP); dialog.dismiss(); return true; } }); builder.show(); }
Example 2
Source File: GamePadActivity.java From bombsquad-remote-android with Apache License 2.0 | 5 votes |
public String getPrettyKeyName(int keyCode) { String val = KeyEvent.keyCodeToString(keyCode); if (val.startsWith("KEYCODE_")) { val = val.replaceAll("KEYCODE_", ""); } if (val.startsWith("BUTTON_")) { val = val.replaceAll("BUTTON_", ""); } return val; }
Example 3
Source File: Performance.java From talkback with Apache License 2.0 | 5 votes |
@Override public String toString() { String subtypeString; switch (mEventType) { case EVENT_TYPE_ACCESSIBILITY: subtypeString = AccessibilityEventUtils.typeToString(mEventSubtype); break; case EVENT_TYPE_KEY: subtypeString = KeyEvent.keyCodeToString(mEventSubtype); break; case EVENT_TYPE_GESTURE: subtypeString = AccessibilityServiceCompatUtils.gestureIdToString(mEventSubtype); break; case EVENT_TYPE_FINGERPRINT_GESTURE: subtypeString = AccessibilityServiceCompatUtils.fingerprintGestureIdToString(mEventSubtype); break; default: subtypeString = Integer.toString(mEventSubtype); } return "type:" + EVENT_TYPE_NAMES[mEventType] + " subtype:" + subtypeString + " time:" + mEventTimeMs; }
Example 4
Source File: ButtonMappingDialogPreference.java From crazyflie-android-client with GNU General Public License v2.0 | 5 votes |
@Override public boolean onKey(DialogInterface dialog, int pKeyCode, KeyEvent event) { if(pKeyCode != KeyEvent.KEYCODE_BACK) { this.mKeyCode = KeyEvent.keyCodeToString(pKeyCode); mValueTextView.setText(mKeyCode); } else { dialog.dismiss(); } return true; }
Example 5
Source File: GameControllerInput.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public boolean onKeyDown(KeyEvent event) { final int keyCode = event.getKeyCode(); if (isGameKey(keyCode)) { if (event.getRepeatCount() == 0) { final String symbolicName = KeyEvent.keyCodeToString(keyCode); mKeys.put(keyCode, 1); Log.i(TAG, mDevice.getName() + " - Key Down: " + symbolicName); } return true; } return false; }
Example 6
Source File: GameControllerInput.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public boolean onKeyUp(KeyEvent event) { final int keyCode = event.getKeyCode(); if (isGameKey(keyCode)) { int index = mKeys.indexOfKey(keyCode); if (index >= 0) { final String symbolicName = KeyEvent.keyCodeToString(keyCode); mKeys.put(keyCode, 0); Log.i(TAG, mDevice.getName() + " - Key Up: " + symbolicName); } return true; } return false; }
Example 7
Source File: KeyComboManager.java From talkback with Apache License 2.0 | 4 votes |
/** Returns user friendly string representations of key combo code */ public String getKeyComboStringRepresentation(long keyComboCode) { if (keyComboCode == KeyComboModel.KEY_COMBO_CODE_UNASSIGNED) { return mContext.getString(R.string.keycombo_unassigned); } int triggerModifier = mKeyComboModel.getTriggerModifier(); int modifier = getModifier(keyComboCode); int modifierWithoutTriggerModifier = modifier & ~triggerModifier; int keyCode = getKeyCode(keyComboCode); StringBuilder sb = new StringBuilder(); // Append trigger modifier if key combo code contains it. if ((triggerModifier & modifier) != 0) { appendModifiers(triggerModifier, sb); } // Append modifier except trigger modifier. appendModifiers(modifierWithoutTriggerModifier, sb); // Append key code. if (keyCode > 0 && !KeyEvent.isModifierKey(keyCode)) { appendPlusSignIfNotEmpty(sb); switch (keyCode) { case KeyEvent.KEYCODE_DPAD_RIGHT: sb.append(mContext.getString(R.string.keycombo_key_arrow_right)); break; case KeyEvent.KEYCODE_DPAD_LEFT: sb.append(mContext.getString(R.string.keycombo_key_arrow_left)); break; case KeyEvent.KEYCODE_DPAD_UP: sb.append(mContext.getString(R.string.keycombo_key_arrow_up)); break; case KeyEvent.KEYCODE_DPAD_DOWN: sb.append(mContext.getString(R.string.keycombo_key_arrow_down)); break; default: String keyCodeString = KeyEvent.keyCodeToString(keyCode); if (keyCodeString != null) { String keyCodeNoPrefix; if (keyCodeString.startsWith(KEYCODE_PREFIX)) { keyCodeNoPrefix = keyCodeString.substring(KEYCODE_PREFIX.length()); } else { keyCodeNoPrefix = keyCodeString; } sb.append(keyCodeNoPrefix.replace('_', ' ')); } break; } } return sb.toString(); }
Example 8
Source File: AndroidJoystickJoyInput14.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected JoystickButton addButton( int keyCode ) { // logger.log(Level.FINE, "Adding button: {0}", keyCode); String name = KeyEvent.keyCodeToString(keyCode); String original = KeyEvent.keyCodeToString(keyCode); // A/B/X/Y buttons if (keyCode == KeyEvent.KEYCODE_BUTTON_Y) { original = JoystickButton.BUTTON_0; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_B) { original = JoystickButton.BUTTON_1; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_A) { original = JoystickButton.BUTTON_2; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_X) { original = JoystickButton.BUTTON_3; // Front buttons Some of these have the top ones and the bottoms ones flipped. } else if (keyCode == KeyEvent.KEYCODE_BUTTON_L1) { original = JoystickButton.BUTTON_4; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_R1) { original = JoystickButton.BUTTON_5; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_L2) { original = JoystickButton.BUTTON_6; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_R2) { original = JoystickButton.BUTTON_7; // // Dpad buttons // } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { // original = JoystickButton.BUTTON_8; // } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { // original = JoystickButton.BUTTON_9; // } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { // original = JoystickButton.BUTTON_8; // } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { // original = JoystickButton.BUTTON_9; // Select and start buttons } else if (keyCode == KeyEvent.KEYCODE_BUTTON_SELECT) { original = JoystickButton.BUTTON_8; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_START) { original = JoystickButton.BUTTON_9; // Joystick push buttons } else if (keyCode == KeyEvent.KEYCODE_BUTTON_THUMBL) { original = JoystickButton.BUTTON_10; } else if (keyCode == KeyEvent.KEYCODE_BUTTON_THUMBR) { original = JoystickButton.BUTTON_11; } String logicalId = JoystickCompatibilityMappings.remapComponent( getName(), original ); if( logicalId == null ? original != null : !logicalId.equals(original) ) { logger.log(Level.FINE, "Remapped: {0} to: {1}", new Object[]{original, logicalId}); } JoystickButton button = new DefaultJoystickButton( getInputManager(), this, getButtonCount(), name, logicalId ); addButton(button); buttonIndex.put( keyCode, button ); return button; }