[java-atk-wrapper] Add non-alphanumeric key mapping



commit 44021c6b890c305e2d10da43d38f19a988e852df
Author: Ke Wang <ke wang sun com>
Date:   Thu Jan 28 17:19:54 2010 +0800

    Add non-alphanumeric key mapping

 wrapper/org/GNOME/Accessibility/AtkKeyEvent.java |   43 ++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/wrapper/org/GNOME/Accessibility/AtkKeyEvent.java b/wrapper/org/GNOME/Accessibility/AtkKeyEvent.java
index f6c0f2c..6a15762 100644
--- a/wrapper/org/GNOME/Accessibility/AtkKeyEvent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkKeyEvent.java
@@ -25,6 +25,8 @@ import java.util.HashMap;
 
 public class AtkKeyEvent {
 
+	private static HashMap nonAlphaNumericMap = null;
+
 	public static final int ATK_KEY_EVENT_PRESSED = 0;
 	public static final int ATK_KEY_EVENT_RELEASED = 1;
 
@@ -38,6 +40,43 @@ public class AtkKeyEvent {
 	public int keycode;
 	public int timestamp;
 
+	static {
+		// Non-alphanumeric symbols that need to be mapped to X11 keysym names
+		nonAlphaNumericMap = new HashMap( 40 );
+		nonAlphaNumericMap.put("!", "exclam");
+		nonAlphaNumericMap.put("@", "at");
+		nonAlphaNumericMap.put("#", "numbersign");
+		nonAlphaNumericMap.put("$", "dollar");
+		nonAlphaNumericMap.put("%", "percent");
+		nonAlphaNumericMap.put("^", "asciicircum");
+		nonAlphaNumericMap.put("&", "ampersand");
+		nonAlphaNumericMap.put("*", "asterisk");
+		nonAlphaNumericMap.put("(", "parenleft");
+		nonAlphaNumericMap.put(")", "parenright");
+		nonAlphaNumericMap.put("-", "minus");
+		nonAlphaNumericMap.put("_", "underscore");
+		nonAlphaNumericMap.put("=", "equal");
+		nonAlphaNumericMap.put("+", "plus");
+		nonAlphaNumericMap.put("\\", "backslash");
+		nonAlphaNumericMap.put("|", "bar");
+		nonAlphaNumericMap.put("`", "grave");
+		nonAlphaNumericMap.put("~", "asciitilde");
+		nonAlphaNumericMap.put("[", "bracketleft");
+		nonAlphaNumericMap.put("{", "braceleft");
+		nonAlphaNumericMap.put("]", "bracketright");
+		nonAlphaNumericMap.put("}", "braceright");
+		nonAlphaNumericMap.put(";", "semicolon");
+		nonAlphaNumericMap.put(":", "colon");
+		nonAlphaNumericMap.put("'", "apostrophe");
+		nonAlphaNumericMap.put("\"", "quotedbl");
+		nonAlphaNumericMap.put(",", "comma");
+		nonAlphaNumericMap.put("<", "less");
+		nonAlphaNumericMap.put(".", "period");
+		nonAlphaNumericMap.put(">", "greater");
+		nonAlphaNumericMap.put("/", "slash");
+		nonAlphaNumericMap.put("?", "question");
+	}
+
 	public AtkKeyEvent (KeyEvent e) {
 		//type
 		switch (e.getID()) {
@@ -99,6 +138,10 @@ public class AtkKeyEvent {
 
 		keycode = e.getKeyCode();
 		timestamp = (int)e.getWhen();
+
+		String nonAlphaNumericString = (String) nonAlphaNumericMap.get(string);
+		if (nonAlphaNumericString != null)
+			string = nonAlphaNumericString;
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]