From 349f0bee6fc203975aeb3dc1f6324cc5f671265e Mon Sep 17 00:00:00 2001 From: juloo Date: Sat, 1 Aug 2015 21:36:40 +0200 Subject: Send keys to the application --- srcs/juloo.keyboard2/Keyboard2.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2.java') diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java index 38a9294..ce2f011 100644 --- a/srcs/juloo.keyboard2/Keyboard2.java +++ b/srcs/juloo.keyboard2/Keyboard2.java @@ -27,9 +27,26 @@ public class Keyboard2 extends InputMethodService return (_inputView); } - public void handleKey(KeyValue key) + public void handleKeyUp(KeyValue key) { - Keyboard2.log("Key up " + key.getName()); + int eventCode = key.getEventCode(); + + switch (eventCode) + { + case KeyValue.EVENT_NONE: + sendKeyChar(key.getChar()); + break ; + case KeyValue.EVENT_DELETE: + getCurrentInputConnection().deleteSurroundingText(0, 1); + break ; + case KeyValue.EVENT_BACKSPACE: + getCurrentInputConnection().deleteSurroundingText(1, 0); + break ; + default: + getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, eventCode)); + getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, eventCode)); + break ; + } } public static void log(String str) -- cgit v1.2.3