abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyValue.java
diff options
context:
space:
mode:
authorjuloo2015-08-01 21:36:40 +0200
committerjuloo2015-08-01 21:36:40 +0200
commit349f0bee6fc203975aeb3dc1f6324cc5f671265e (patch)
tree1a3327db80427bac9e9f596b6c14de08d91d03d7 /srcs/juloo.keyboard2/KeyValue.java
parent3b7141e3a05e44a907ab403ec5de52a1ad988224 (diff)
downloadunexpected-keyboard-349f0bee6fc203975aeb3dc1f6324cc5f671265e.tar.gz
unexpected-keyboard-349f0bee6fc203975aeb3dc1f6324cc5f671265e.zip
Send keys to the application
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValue.java')
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java71
1 files changed, 48 insertions, 23 deletions
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 1b6ef23..e4beae5 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -5,9 +5,14 @@ import java.util.HashMap;
class KeyValue
{
+ public static final int EVENT_NONE = -1;
+ public static final int EVENT_BACKSPACE = -2;
+ public static final int EVENT_DELETE = -3;
+
private String _name;
private String _symbol;
private char _char;
+ private int _eventCode;
public String getName()
{
@@ -24,13 +29,35 @@ class KeyValue
return (_char);
}
+ public int getEventCode()
+ {
+ return (_eventCode);
+ }
+
private static HashMap<String, KeyValue> keys = new HashMap<String, KeyValue>();
+ private KeyValue(String name)
+ {
+ this(name, name, name.charAt(0), EVENT_NONE);
+ }
+
private KeyValue(String name, String symbol, char c)
{
+ this(name, symbol, c, EVENT_NONE);
+ }
+
+ private KeyValue(String name, String symbol, int eventCode)
+ {
+ this(name, symbol, name.charAt(0), eventCode);
+ }
+
+ private KeyValue(String name, String symbol, char c, int eventCode)
+ {
_name = name;
_symbol = symbol;
_char = c;
+ _eventCode = eventCode;
+ KeyValue.keys.put(name, this);
}
public static KeyValue getKeyByName(String name)
@@ -38,11 +65,6 @@ class KeyValue
return (KeyValue.keys.get(name));
}
- private static void add(String name, String symbol, char c)
- {
- keys.put(name, new KeyValue(name, symbol, c));
- }
-
static
{
String chars = "abcdefghijklmnopqrstuvwxyz"
@@ -52,23 +74,26 @@ class KeyValue
+ "~#{[|`\\^@]}"
+ "^$ù*,;:!¨£%µ?./§";
for (int i = 0; i < chars.length(); i++)
- add(chars.substring(i, i + 1), chars.substring(i, i + 1), chars.charAt(i));
- add("shift", "Shift", 'S');
- add("ctrl", "Ctrl", 'C');
- add("alt", "Alt", 'A');
-
- add("back", "⌫", '\u007F');
- add("up", "↑", 'U');
- add("right", "→", 'R');
- add("down", "↓", 'D');
- add("left", "←", 'L');
- add("page_up", "⇞", 'U');
- add("page_down", "⇟", 'D');
- add("home", "↖", 'H');
- add("end", "↗", 'E');
- add("tab", "↹", '\t');
- add("return", "↵", '\n');
- add("space", " ", ' ');
- add("delete", "⌦", 'D');
+ new KeyValue(chars.substring(i, i + 1));
+
+ new KeyValue("shift", "Shift", EVENT_NONE);
+ new KeyValue("ctrl", "Ctrl", EVENT_NONE);
+ new KeyValue("alt", "Alt", EVENT_NONE);
+
+ new KeyValue("backspace", "⌫", EVENT_BACKSPACE);
+ new KeyValue("delete", "⌦", EVENT_DELETE);
+
+ new KeyValue("enter", "↵", KeyEvent.KEYCODE_ENTER);
+ new KeyValue("up", "↑", KeyEvent.KEYCODE_DPAD_UP);
+ new KeyValue("right", "→", KeyEvent.KEYCODE_DPAD_RIGHT);
+ new KeyValue("down", "↓", KeyEvent.KEYCODE_DPAD_DOWN);
+ new KeyValue("left", "←", KeyEvent.KEYCODE_DPAD_LEFT);
+ new KeyValue("page_up", "⇞", KeyEvent.KEYCODE_PAGE_DOWN);
+ new KeyValue("page_down", "⇟", KeyEvent.KEYCODE_PAGE_UP);
+ new KeyValue("home", "↖", KeyEvent.KEYCODE_HOME);
+ new KeyValue("end", "↗", KeyEvent.KEYCODE_MOVE_END);
+
+ new KeyValue("tab", "↹", '\t');
+ new KeyValue("space", " ", ' ');
}
}