Loading java/src/com/android/inputmethod/event/DeadKeyCombiner.java +6 −2 Original line number Diff line number Diff line Loading @@ -52,12 +52,16 @@ public class DeadKeyCombiner implements Combiner { // how dead keys work). // If the event is a space, we should commit the dead char alone, but if it's // not, we need to commit both. // TODO: this is not necessarily triggered by hardware key events, so it's not // a good idea to masquerade as one. This should be typed as a software // composite event or something. return Event.createHardwareKeypressEvent(deadCodePoint, event.mKeyCode, Constants.CODE_SPACE == event.mCodePoint ? null : event /* next */); Constants.CODE_SPACE == event.mCodePoint ? null : event /* next */, false /* isKeyRepeat */); } else { // We could combine the characters. return Event.createHardwareKeypressEvent(resultingCodePoint, event.mKeyCode, null /* next */); null /* next */, false /* isKeyRepeat */); } } } Loading java/src/com/android/inputmethod/event/Event.java +10 −4 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ public class Event { // This event is a dead character, usually input by a dead key. Examples include dead-acute // or dead-abovering. final private static int FLAG_DEAD = 0x1; // This event is coming from a key repeat, software or hardware. final private static int FLAG_REPEAT = 0x2; final private int mEventType; // The type of event - one of the constants above // The code point associated with the event, if relevant. This is a unicode code point, and Loading Loading @@ -130,16 +132,16 @@ public class Event { } public static Event createSoftwareKeypressEvent(final int codePoint, final int keyCode, final int x, final int y) { final int x, final int y, final boolean isKeyRepeat) { return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y, null /* suggestedWordInfo */, FLAG_NONE, null /* next */); null /* suggestedWordInfo */, isKeyRepeat ? FLAG_REPEAT : FLAG_NONE, null); } public static Event createHardwareKeypressEvent(final int codePoint, final int keyCode, final Event next) { final Event next, final boolean isKeyRepeat) { return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, next); null /* suggestedWordInfo */, isKeyRepeat ? FLAG_REPEAT : FLAG_NONE, next); } // This creates an input event for a dead character. @see {@link #FLAG_DEAD} Loading Loading @@ -228,6 +230,10 @@ public class Event { return 0 != (FLAG_DEAD & mFlags); } public boolean isKeyRepeat() { return 0 != (FLAG_REPEAT & mFlags); } // Returns whether this is a fake key press from the suggestion strip. This happens with // punctuation signs selected from the suggestion strip. public boolean isSuggestionStripPress() { Loading java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,10 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { // do not necessarily map to a unicode character. This represents a physical key, like // the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock. final int keyCode = keyEvent.getKeyCode(); final boolean isKeyRepeat = (0 != keyEvent.getRepeatCount()); if (KeyEvent.KEYCODE_DEL == keyCode) { return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE, null /* next */); null /* next */, isKeyRepeat); } if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) { Loading @@ -65,15 +66,16 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { // Latin IME decide what to do with it. if (keyEvent.isShiftPressed()) { return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_SHIFT_ENTER, null /* next */); Constants.CODE_SHIFT_ENTER, null /* next */, isKeyRepeat); } else { return Event.createHardwareKeypressEvent(Constants.CODE_ENTER, keyCode, null /* next */); null /* next */, isKeyRepeat); } } // If not Enter, then this is just a regular keypress event for a normal character // that can be committed right away, taking into account the current state. return Event.createHardwareKeypressEvent(keyCode, codePointAndFlags, null /* next */); return Event.createHardwareKeypressEvent(keyCode, codePointAndFlags, null /* next */, isKeyRepeat); } return Event.createNotHandledEvent(); } Loading java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +6 −4 Original line number Diff line number Diff line Loading @@ -606,7 +606,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange return; } final int code = (Integer) tag; mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey(code, false /* withSliding */); } Loading Loading @@ -634,7 +635,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange if (code == Constants.CODE_OUTPUT_TEXT) { mKeyboardActionListener.onTextInput(key.getOutputText()); } else { mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); } mKeyboardActionListener.onReleaseKey(code, false /* withSliding */); } Loading Loading @@ -901,8 +903,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange } private void handleKeyUp() { mKeyboardActionListener.onCodeInput( Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey( Constants.CODE_DELETE, false /* withSliding */); ++mRepeatCount; Loading java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +4 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,10 @@ public interface KeyboardActionListener { * {@link PointerTracker} or so, the value should be * {@link Constants#NOT_A_COORDINATE}.If it's called on insertion from the * suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}. * @param isKeyRepeat true if this is a key repeat, false otherwise */ public void onCodeInput(int primaryCode, int x, int y); // TODO: change this to send an Event object instead public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat); /** * Sends a string of characters to the listener. Loading Loading @@ -107,7 +109,7 @@ public interface KeyboardActionListener { @Override public void onReleaseKey(int primaryCode, boolean withSliding) {} @Override public void onCodeInput(int primaryCode, int x, int y) {} public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat) {} @Override public void onTextInput(String text) {} @Override Loading Loading
java/src/com/android/inputmethod/event/DeadKeyCombiner.java +6 −2 Original line number Diff line number Diff line Loading @@ -52,12 +52,16 @@ public class DeadKeyCombiner implements Combiner { // how dead keys work). // If the event is a space, we should commit the dead char alone, but if it's // not, we need to commit both. // TODO: this is not necessarily triggered by hardware key events, so it's not // a good idea to masquerade as one. This should be typed as a software // composite event or something. return Event.createHardwareKeypressEvent(deadCodePoint, event.mKeyCode, Constants.CODE_SPACE == event.mCodePoint ? null : event /* next */); Constants.CODE_SPACE == event.mCodePoint ? null : event /* next */, false /* isKeyRepeat */); } else { // We could combine the characters. return Event.createHardwareKeypressEvent(resultingCodePoint, event.mKeyCode, null /* next */); null /* next */, false /* isKeyRepeat */); } } } Loading
java/src/com/android/inputmethod/event/Event.java +10 −4 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ public class Event { // This event is a dead character, usually input by a dead key. Examples include dead-acute // or dead-abovering. final private static int FLAG_DEAD = 0x1; // This event is coming from a key repeat, software or hardware. final private static int FLAG_REPEAT = 0x2; final private int mEventType; // The type of event - one of the constants above // The code point associated with the event, if relevant. This is a unicode code point, and Loading Loading @@ -130,16 +132,16 @@ public class Event { } public static Event createSoftwareKeypressEvent(final int codePoint, final int keyCode, final int x, final int y) { final int x, final int y, final boolean isKeyRepeat) { return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y, null /* suggestedWordInfo */, FLAG_NONE, null /* next */); null /* suggestedWordInfo */, isKeyRepeat ? FLAG_REPEAT : FLAG_NONE, null); } public static Event createHardwareKeypressEvent(final int codePoint, final int keyCode, final Event next) { final Event next, final boolean isKeyRepeat) { return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE, null /* suggestedWordInfo */, FLAG_NONE, next); null /* suggestedWordInfo */, isKeyRepeat ? FLAG_REPEAT : FLAG_NONE, next); } // This creates an input event for a dead character. @see {@link #FLAG_DEAD} Loading Loading @@ -228,6 +230,10 @@ public class Event { return 0 != (FLAG_DEAD & mFlags); } public boolean isKeyRepeat() { return 0 != (FLAG_REPEAT & mFlags); } // Returns whether this is a fake key press from the suggestion strip. This happens with // punctuation signs selected from the suggestion strip. public boolean isSuggestionStripPress() { Loading
java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java +6 −4 Original line number Diff line number Diff line Loading @@ -46,9 +46,10 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { // do not necessarily map to a unicode character. This represents a physical key, like // the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock. final int keyCode = keyEvent.getKeyCode(); final boolean isKeyRepeat = (0 != keyEvent.getRepeatCount()); if (KeyEvent.KEYCODE_DEL == keyCode) { return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE, null /* next */); null /* next */, isKeyRepeat); } if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) { Loading @@ -65,15 +66,16 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { // Latin IME decide what to do with it. if (keyEvent.isShiftPressed()) { return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_SHIFT_ENTER, null /* next */); Constants.CODE_SHIFT_ENTER, null /* next */, isKeyRepeat); } else { return Event.createHardwareKeypressEvent(Constants.CODE_ENTER, keyCode, null /* next */); null /* next */, isKeyRepeat); } } // If not Enter, then this is just a regular keypress event for a normal character // that can be committed right away, taking into account the current state. return Event.createHardwareKeypressEvent(keyCode, codePointAndFlags, null /* next */); return Event.createHardwareKeypressEvent(keyCode, codePointAndFlags, null /* next */, isKeyRepeat); } return Event.createNotHandledEvent(); } Loading
java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java +6 −4 Original line number Diff line number Diff line Loading @@ -606,7 +606,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange return; } final int code = (Integer) tag; mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey(code, false /* withSliding */); } Loading Loading @@ -634,7 +635,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange if (code == Constants.CODE_OUTPUT_TEXT) { mKeyboardActionListener.onTextInput(key.getOutputText()); } else { mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); } mKeyboardActionListener.onReleaseKey(code, false /* withSliding */); } Loading Loading @@ -901,8 +903,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange } private void handleKeyUp() { mKeyboardActionListener.onCodeInput( Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE); mKeyboardActionListener.onCodeInput(Constants.CODE_DELETE, NOT_A_COORDINATE, NOT_A_COORDINATE, false /* isKeyRepeat */); mKeyboardActionListener.onReleaseKey( Constants.CODE_DELETE, false /* withSliding */); ++mRepeatCount; Loading
java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +4 −2 Original line number Diff line number Diff line Loading @@ -53,8 +53,10 @@ public interface KeyboardActionListener { * {@link PointerTracker} or so, the value should be * {@link Constants#NOT_A_COORDINATE}.If it's called on insertion from the * suggestion strip, it should be {@link Constants#SUGGESTION_STRIP_COORDINATE}. * @param isKeyRepeat true if this is a key repeat, false otherwise */ public void onCodeInput(int primaryCode, int x, int y); // TODO: change this to send an Event object instead public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat); /** * Sends a string of characters to the listener. Loading Loading @@ -107,7 +109,7 @@ public interface KeyboardActionListener { @Override public void onReleaseKey(int primaryCode, boolean withSliding) {} @Override public void onCodeInput(int primaryCode, int x, int y) {} public void onCodeInput(int primaryCode, int x, int y, boolean isKeyRepeat) {} @Override public void onTextInput(String text) {} @Override Loading