[java-atk-wrapper/gnome-2-28] Add non-alphanumeric key mapping



commit 4559549a8e457cd9494aae9bfef1d3abccae121d
Author: Ke Wang <ke wang sun com>
Date:   Fri Jan 29 14:27:22 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]