From 09291050a028192a39fd745c6696df1c504eb38b Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 25 Jun 2014 16:50:27 +0900 Subject: [PATCH] [HW1] Fix some bugs with event handling With hardware events, we do have some events that have both a keycode and a code point, so we need a better way of distinguishing between auto-insert keystrokes and others. Change-Id: Ia23042989b4dca9d3a7d4a4c06bcebdabe324a7a --- java/src/com/android/inputmethod/event/Event.java | 7 +++++++ .../inputmethod/event/HardwareKeyboardEventDecoder.java | 2 +- .../android/inputmethod/latin/inputlogic/InputLogic.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 4a9163c8e..d257441e0 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -225,6 +225,13 @@ public class Event { null /* suggestedWordInfo */, FLAG_NONE, null); } + // Returns whether this is a function key like backspace, ctrl, settings... as opposed to keys + // that result in input like letters or space. + public boolean isFunctionalKeyEvent() { + // This logic may need to be refined in the future + return NOT_A_CODE_POINT == mCodePoint; + } + // Returns whether this event is for a dead character. @see {@link #FLAG_DEAD} public boolean isDead() { return 0 != (FLAG_DEAD & mFlags); diff --git a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java index 05ba99923..c61f45efa 100644 --- a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java +++ b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java @@ -74,7 +74,7 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { } // 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(codePointAndFlags, keyCode, null /* next */, isKeyRepeat); } return Event.createNotHandledEvent(); diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 4d3f5b50b..dd2a95ee0 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -399,7 +399,7 @@ public final class InputLogic { } boolean didAutoCorrect = false; - if (Event.NOT_A_KEY_CODE != event.mKeyCode) { + if (event.isFunctionalKeyEvent()) { // A special key, like delete, shift, emoji, or the settings key. switch (event.mKeyCode) { case Constants.CODE_DELETE: