Merge "Add a next Event (B2)"
commit
424d76fbf5
|
@ -61,23 +61,26 @@ public class Event {
|
||||||
// ctrl, there is no code point associated so this should be NOT_A_CODE_POINT to avoid
|
// 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.
|
// unintentional use of its value when it's not relevant.
|
||||||
final public int mCodePoint;
|
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.
|
// 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;
|
mType = type;
|
||||||
mCodePoint = codePoint;
|
mCodePoint = codePoint;
|
||||||
|
mNextEvent = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event createDeadEvent(final int codePoint) {
|
public static Event createDeadEvent(final int codePoint, final Event next) {
|
||||||
return new Event(EVENT_DEAD, codePoint);
|
return new Event(EVENT_DEAD, codePoint, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event createCommittableEvent(final int codePoint) {
|
public static Event createCommittableEvent(final int codePoint, final Event next) {
|
||||||
return new Event(EVENT_COMMITTABLE, codePoint);
|
return new Event(EVENT_COMMITTABLE, codePoint, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Event createNotHandledEvent() {
|
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() {
|
public boolean isCommittable() {
|
||||||
|
|
|
@ -106,19 +106,17 @@ public class EventInterpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onEvent(final Event event) {
|
private boolean onEvent(final Event event) {
|
||||||
if (event.isCommittable()) {
|
Event currentlyProcessingEvent = event;
|
||||||
mLatinIme.onCodeInput(event.mCodePoint,
|
boolean processed = false;
|
||||||
Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE);
|
while (null != currentlyProcessingEvent) {
|
||||||
return true;
|
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)
|
return processed;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,17 +47,18 @@ public class HardwareKeyboardEventDecoder implements HardwareEventDecoder {
|
||||||
// the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
|
// the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
|
||||||
final int keyCode = keyEvent.getKeyCode();
|
final int keyCode = keyEvent.getKeyCode();
|
||||||
if (KeyEvent.KEYCODE_DEL == keyCode) {
|
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
|
if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode
|
||||||
|| KeyEvent.KEYCODE_ENTER == keyCode) {
|
|| KeyEvent.KEYCODE_ENTER == keyCode) {
|
||||||
if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
|
if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
|
||||||
// A dead key.
|
// A dead key.
|
||||||
return Event.createDeadEvent(codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK);
|
return Event.createDeadEvent(
|
||||||
|
codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, null /* next */);
|
||||||
} else {
|
} else {
|
||||||
// A committable character. This should be committed right away, taking into
|
// A committable character. This should be committed right away, taking into
|
||||||
// account the current state.
|
// account the current state.
|
||||||
return Event.createCommittableEvent(codePointAndFlags);
|
return Event.createCommittableEvent(codePointAndFlags, null /* next */);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Event.createNotHandledEvent();
|
return Event.createNotHandledEvent();
|
||||||
|
|
Loading…
Reference in New Issue