List of usage examples for android.view KeyEvent getUnicodeChar
public int getUnicodeChar(int metaState)
From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java
/** * This translates incoming hard key events in to edit operations on an * InputConnection. It is only needed when using the * PROCESS_HARD_KEYS option.//from w w w .ja va 2s . c o m */ private boolean translateKeyDown(int keyCode, KeyEvent event) { mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event); int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState)); mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState); InputConnection ic = getCurrentInputConnection(); if (c == 0 || ic == null) { return false; } boolean dead = false; if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) { dead = true; c = c & KeyCharacterMap.COMBINING_ACCENT_MASK; } if (mComposing.length() > 0) { char accent = mComposing.charAt(mComposing.length() - 1); int composed = KeyEvent.getDeadChar(accent, c); if (composed != 0) { c = composed; mComposing.setLength(mComposing.length() - 1); } } Log.d("Cum", "Cum"); onKey(c, null); return true; }
From source file:es.farfuteam.vncpp.controller.CanvasActivity.java
/** * @param event The event//from w w w. j a v a2 s . c o m * @brief Captures the keys of the keyboard * @details Capture the keys of the keyboard. If the character has to be pressed with a combination of the shift key * and other key then adds 100 to the modKeyCount attribute to applies the offset */ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_UP || event.getAction() == KeyEvent.ACTION_MULTIPLE) { int keyunicode = event.getUnicodeChar(event.getMetaState()); char character = (char) keyunicode; int key = event.getKeyCode(); if (key == 59) { if (modKeyCount == 0) { modKeyCount = 100; } else { modKeyCount = 0; } } else if (key >= 7) { boolean down = event.getAction() == KeyEvent.ACTION_DOWN; vnc.sendKey(modKeyCount + key, down); } Log.e(DEBUG_TAG, String.valueOf(event.getKeyCode())); } return super.dispatchKeyEvent(event); }
From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java
/** * This translates incoming hard key events in to edit operations on an * InputConnection. It is only needed when using the * PROCESS_HARD_KEYS option./*from ww w .ja v a2s . c o m*/ */ private boolean translateKeyDown(int keyCode, KeyEvent event) { mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event); int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState)); mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState); //InputConnection ic = ic; if (c == 0 || ic == null) { return false; } if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) { c = c & KeyCharacterMap.COMBINING_ACCENT_MASK; } if (mComposing.length() > 0) { char accent = mComposing.charAt(mComposing.length() - 1); int composed = KeyEvent.getDeadChar(accent, c); if (composed != 0) { c = composed; mComposing.setLength(mComposing.length() - 1); } } onKey(c, null); return true; }