aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/event
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/event')
-rw-r--r--java/src/com/android/inputmethod/event/DeadKeyCombiner.java8
-rw-r--r--java/src/com/android/inputmethod/event/Event.java14
-rw-r--r--java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java10
3 files changed, 22 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
index 89e623a1d..bef4d8594 100644
--- a/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
+++ b/java/src/com/android/inputmethod/event/DeadKeyCombiner.java
@@ -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 */);
}
}
}
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java
index 6535d2d76..4a9163c8e 100644
--- a/java/src/com/android/inputmethod/event/Event.java
+++ b/java/src/com/android/inputmethod/event/Event.java
@@ -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
@@ -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}
@@ -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() {
diff --git a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
index da6780e08..05ba99923 100644
--- a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
+++ b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java
@@ -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) {
@@ -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();
}