From 6c75253c114991f9878822f018898d7f4bd90986 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 8 Jan 2013 15:09:04 +0900 Subject: [PATCH] Add a next Event (B2) Change-Id: If2fe6f0f4f88a6ae1f22664ded61cec6942c18b9 --- .../com/android/inputmethod/event/Event.java | 15 +++++++----- .../inputmethod/event/EventInterpreter.java | 24 +++++++++---------- .../event/HardwareKeyboardEventDecoder.java | 7 +++--- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 3fe5d5b68..2165933c4 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -61,23 +61,26 @@ public class Event { // ctrl, there is no code point associated so this should be NOT_A_CODE_POINT to avoid // unintentional use of its value when it's not relevant. final public int mCodePoint; + // The next event, if any. Null if there is no next event yet. + final public Event mNextEvent; // This method is private - to create a new event, use one of the create* utility methods. - private Event(final int type, final int codePoint) { + private Event(final int type, final int codePoint, final Event next) { mType = type; mCodePoint = codePoint; + mNextEvent = next; } - public static Event createDeadEvent(final int codePoint) { - return new Event(EVENT_DEAD, codePoint); + public static Event createDeadEvent(final int codePoint, final Event next) { + return new Event(EVENT_DEAD, codePoint, next); } - public static Event createCommittableEvent(final int codePoint) { - return new Event(EVENT_COMMITTABLE, codePoint); + public static Event createCommittableEvent(final int codePoint, final Event next) { + return new Event(EVENT_COMMITTABLE, codePoint, next); } public static Event createNotHandledEvent() { - return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT); + return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT, null); } public boolean isCommittable() { diff --git a/java/src/com/android/inputmethod/event/EventInterpreter.java b/java/src/com/android/inputmethod/event/EventInterpreter.java index f9185788e..2874970ec 100644 --- a/java/src/com/android/inputmethod/event/EventInterpreter.java +++ b/java/src/com/android/inputmethod/event/EventInterpreter.java @@ -106,19 +106,17 @@ public class EventInterpreter { } private boolean onEvent(final Event event) { - if (event.isCommittable()) { - mLatinIme.onCodeInput(event.mCodePoint, - Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE); - return true; + Event currentlyProcessingEvent = event; + boolean processed = false; + while (null != currentlyProcessingEvent) { + if (currentlyProcessingEvent.isCommittable()) { + mLatinIme.onCodeInput(currentlyProcessingEvent.mCodePoint, + Constants.EXTERNAL_KEYBOARD_COORDINATE, + Constants.EXTERNAL_KEYBOARD_COORDINATE); + processed = true; + } + currentlyProcessingEvent = currentlyProcessingEvent.mNextEvent; } - // TODO: Classify the event - input or non-input (see design doc) - // TODO: IF action event - // Send decoded action back to LatinIME - // ELSE - // Send input event to the combiner - // Get back new input material + visual feedback + combiner state - // Route the event to Latin IME - // ENDIF - return false; + return processed; } } diff --git a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java index 554319e51..2fb7fe8b4 100644 --- a/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java +++ b/java/src/com/android/inputmethod/event/HardwareKeyboardEventDecoder.java @@ -47,17 +47,18 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder { // the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock. final int keyCode = keyEvent.getKeyCode(); if (KeyEvent.KEYCODE_DEL == keyCode) { - return Event.createCommittableEvent(Constants.CODE_DELETE); + return Event.createCommittableEvent(Constants.CODE_DELETE, null /* next */); } if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode || KeyEvent.KEYCODE_ENTER == keyCode) { if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) { // A dead key. - return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK); + return Event.createDeadEvent( + codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, null /* next */); } else { // A committable character. This should be committed right away, taking into // account the current state. - return Event.createCommittableEvent(codePointAndFlags); + return Event.createCommittableEvent(codePointAndFlags, null /* next */); } } else { return Event.createNotHandledEvent();