aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-03-13 00:50:51 +0000
committerSven Gothel <[email protected]>2009-03-13 00:50:51 +0000
commit3f0266e5d20216f68f515a943ad647d01e0ff567 (patch)
tree7bdddb18ac91f0b559457c5d18f7906b33450078 /src
parent3481005944d8f7f2ce1ec09158bd177a2b379e0a (diff)
Fix NEWT X11 Keymapping
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1862 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/javafx/newt/KeyEvent.java2
-rw-r--r--src/classes/com/sun/javafx/newt/MouseEvent.java4
-rwxr-xr-xsrc/classes/com/sun/javafx/newt/Window.java5
-rw-r--r--src/native/newt/KeyEvent.h197
-rwxr-xr-xsrc/native/newt/X11Window.c41
5 files changed, 245 insertions, 4 deletions
diff --git a/src/classes/com/sun/javafx/newt/KeyEvent.java b/src/classes/com/sun/javafx/newt/KeyEvent.java
index b2ab58cba..7e224dbad 100644
--- a/src/classes/com/sun/javafx/newt/KeyEvent.java
+++ b/src/classes/com/sun/javafx/newt/KeyEvent.java
@@ -53,7 +53,7 @@ public class KeyEvent extends InputEvent
public String toString() {
return "KeyEvent["+getEventTypeString(getEventType())+
- ", code "+keyCode+", char "+keyChar+", isActionKey "+isActionKey()+", "+super.toString()+"]";
+ ", code "+keyCode+"(0x"+Integer.toHexString(keyCode)+"), char <"+keyChar+"> (0x"+Integer.toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]";
}
public static String getEventTypeString(int type) {
diff --git a/src/classes/com/sun/javafx/newt/MouseEvent.java b/src/classes/com/sun/javafx/newt/MouseEvent.java
index 47d2803c0..79e11b875 100644
--- a/src/classes/com/sun/javafx/newt/MouseEvent.java
+++ b/src/classes/com/sun/javafx/newt/MouseEvent.java
@@ -38,6 +38,10 @@ public class MouseEvent extends InputEvent
public static final int BUTTON1 = 1;
public static final int BUTTON2 = 2;
public static final int BUTTON3 = 3;
+ public static final int BUTTON4 = 4;
+ public static final int BUTTON5 = 5;
+ public static final int BUTTON6 = 6;
+ public static final int BUTTON_NUMBER = 6;
protected MouseEvent(boolean sysEvent, int eventType, Window source, long when, int modifiers, int x, int y, int clickCount, int button)
{
diff --git a/src/classes/com/sun/javafx/newt/Window.java b/src/classes/com/sun/javafx/newt/Window.java
index 58f91be55..155eda8a3 100755
--- a/src/classes/com/sun/javafx/newt/Window.java
+++ b/src/classes/com/sun/javafx/newt/Window.java
@@ -369,13 +369,16 @@ public abstract class Window implements NativeWindow
private long lastMousePressed = 0;
private int lastMouseClickCount = 0;
public static final int ClickTimeout = 300;
- private boolean[] buttonStates = new boolean[3];
+ private boolean[] buttonStates = new boolean[MouseEvent.BUTTON_NUMBER];
protected void sendMouseEvent(int eventType, int modifiers, int x, int y, int button) {
if(DEBUG_MOUSE_EVENT) {
System.out.println("sendMouseEvent: "+MouseEvent.getEventTypeString(eventType)+
", mod "+modifiers+", pos "+x+"/"+y+", button "+button);
}
+ if(button<0||button>MouseEvent.BUTTON_NUMBER) {
+ throw new RuntimeException("Invalid mouse button number" + button);
+ }
long when = System.currentTimeMillis();
MouseEvent eClicked = null;
MouseEvent e = null;
diff --git a/src/native/newt/KeyEvent.h b/src/native/newt/KeyEvent.h
index 8f032a182..eb5547b21 100644
--- a/src/native/newt/KeyEvent.h
+++ b/src/native/newt/KeyEvent.h
@@ -6,5 +6,202 @@
#define EVENT_KEY_RELEASED 301
// Send by Java: EVENT_KEY_TYPED 302
+#define VK_ENTER '\n'
+#define VK_BACK_SPACE '\b'
+#define VK_TAB '\t'
+#define VK_CANCEL 0x03
+#define VK_CLEAR 0x0C
+#define VK_SHIFT 0x10
+#define VK_CONTROL 0x11
+#define VK_ALT 0x12
+#define VK_PAUSE 0x13
+#define VK_CAPS_LOCK 0x14
+#define VK_ESCAPE 0x1B
+#define VK_SPACE 0x20
+#define VK_PAGE_UP 0x21
+#define VK_PAGE_DOWN 0x22
+#define VK_END 0x23
+#define VK_HOME 0x24
+
+#define VK_LEFT 0x25
+
+#define VK_UP 0x26
+
+#define VK_RIGHT 0x27
+
+#define VK_DOWN 0x28
+
+#define VK_COMMA 0x2C
+
+#define VK_MINUS 0x2D
+
+#define VK_PERIOD 0x2E
+
+#define VK_SLASH 0x2F
+
+#define VK_0 0x30
+#define VK_1 0x31
+#define VK_2 0x32
+#define VK_3 0x33
+#define VK_4 0x34
+#define VK_5 0x35
+#define VK_6 0x36
+#define VK_7 0x37
+#define VK_8 0x38
+#define VK_9 0x39
+
+#define VK_SEMICOLON 0x3B
+
+#define VK_EQUALS 0x3D
+
+#define VK_A 0x41
+#define VK_B 0x42
+#define VK_C 0x43
+#define VK_D 0x44
+#define VK_E 0x45
+#define VK_F 0x46
+#define VK_G 0x47
+#define VK_H 0x48
+#define VK_I 0x49
+#define VK_J 0x4A
+#define VK_K 0x4B
+#define VK_L 0x4C
+#define VK_M 0x4D
+#define VK_N 0x4E
+#define VK_O 0x4F
+#define VK_P 0x50
+#define VK_Q 0x51
+#define VK_R 0x52
+#define VK_S 0x53
+#define VK_T 0x54
+#define VK_U 0x55
+#define VK_V 0x56
+#define VK_W 0x57
+#define VK_X 0x58
+#define VK_Y 0x59
+#define VK_Z 0x5A
+
+#define VK_OPEN_BRACKET 0x5B
+
+#define VK_BACK_SLASH 0x5C
+
+#define VK_CLOSE_BRACKET 0x5D
+
+#define VK_NUMPAD0 0x60
+#define VK_NUMPAD1 0x61
+#define VK_NUMPAD2 0x62
+#define VK_NUMPAD3 0x63
+#define VK_NUMPAD4 0x64
+#define VK_NUMPAD5 0x65
+#define VK_NUMPAD6 0x66
+#define VK_NUMPAD7 0x67
+#define VK_NUMPAD8 0x68
+#define VK_NUMPAD9 0x69
+#define VK_MULTIPLY 0x6A
+#define VK_ADD 0x6B
+
+#define VK_SEPARATER 0x6C
+
+#define VK_SEPARATOR VK_SEPARATER
+
+#define VK_SUBTRACT 0x6D
+#define VK_DECIMAL 0x6E
+#define VK_DIVIDE 0x6F
+#define VK_DELETE 0x7F; /* ASCII DEL */
+#define VK_NUM_LOCK 0x90
+#define VK_SCROLL_LOCK 0x91
+
+#define VK_F1 0x70
+
+#define VK_F2 0x71
+
+#define VK_F3 0x72
+
+#define VK_F4 0x73
+
+#define VK_F5 0x74
+
+#define VK_F6 0x75
+
+#define VK_F7 0x76
+
+#define VK_F8 0x77
+
+#define VK_F9 0x78
+
+#define VK_F10 0x79
+
+#define VK_F11 0x7A
+
+#define VK_F12 0x7B
+
+#define VK_F13 0xF000
+
+#define VK_F14 0xF001
+
+#define VK_F15 0xF002
+
+#define VK_F16 0xF003
+
+#define VK_F17 0xF004
+
+#define VK_F18 0xF005
+
+#define VK_F19 0xF006
+
+#define VK_F20 0xF007
+
+#define VK_F21 0xF008
+
+#define VK_F22 0xF009
+
+#define VK_F23 0xF00A
+
+#define VK_F24 0xF00B
+
+#define VK_PRINTSCREEN 0x9A
+#define VK_INSERT 0x9B
+#define VK_HELP 0x9C
+#define VK_META 0x9D
+
+#define VK_BACK_QUOTE 0xC0
+#define VK_QUOTE 0xDE
+
+#define VK_KP_UP 0xE0
+
+#define VK_KP_DOWN 0xE1
+
+#define VK_KP_LEFT 0xE2
+
+#define VK_KP_RIGHT 0xE3
+
+#define VK_AT 0x0200
+
+#define VK_COLON 0x0201
+
+#define VK_CIRCUMFLEX 0x0202
+
+#define VK_DOLLAR 0x0203
+
+#define VK_EURO_SIGN 0x0204
+
+#define VK_EXCLAMATION_MARK 0x0205
+
+#define VK_INVERTED_EXCLAMATION_MARK 0x0206
+
+#define VK_LEFT_PARENTHESIS 0x0207
+
+#define VK_NUMBER_SIGN 0x0208
+
+#define VK_PLUS 0x0209
+
+#define VK_RIGHT_PARENTHESIS 0x020A
+
+#define VK_UNDERSCORE 0x020B
+
+#define VK_WINDOWS 0x020C
+
+#define VK_CONTEXT_MENU 0x020D
+
#endif
diff --git a/src/native/newt/X11Window.c b/src/native/newt/X11Window.c
index d5933838c..7789e11b1 100755
--- a/src/native/newt/X11Window.c
+++ b/src/native/newt/X11Window.c
@@ -81,6 +81,43 @@
#endif
/**
+ * Keycode
+ */
+
+#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b))
+
+static jint X11KeySym2NewtVKey(KeySym keySym) {
+ if(IS_WITHIN(keySym,XK_F1,XK_F12))
+ return (keySym-XK_F1)+VK_F1;
+
+ switch(keySym) {
+ case XK_Alt_L:
+ case XK_Alt_R:
+ return VK_ALT;
+
+ case XK_Left:
+ return VK_LEFT;
+ case XK_Right:
+ return VK_RIGHT;
+ case XK_Up:
+ return VK_UP;
+ case XK_Down:
+ return VK_DOWN;
+ case XK_Page_Up:
+ return VK_PAGE_UP;
+ case XK_Page_Down:
+ return VK_PAGE_DOWN;
+ case XK_Shift_L:
+ case XK_Shift_R:
+ return VK_SHIFT;
+ case XK_Control_L:
+ case XK_Control_R:
+ return VK_CONTROL;
+ }
+ return keySym;
+}
+
+/**
* Display
*/
@@ -466,7 +503,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages
}
(*env)->CallVoidMethod(env, obj, sendKeyEventID, (jint) EVENT_KEY_PRESSED,
(jint) evt.xkey.state,
- (jint) keySym, (jchar) keyChar);
+ X11KeySym2NewtVKey(keySym), (jchar) keyChar);
}
break;
case KeyRelease:
@@ -478,7 +515,7 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_x11_X11Window_DispatchMessages
}
(*env)->CallVoidMethod(env, obj, sendKeyEventID, (jint) EVENT_KEY_RELEASED,
(jint) evt.xkey.state,
- (jint) keySym, (jchar) keyChar);
+ X11KeySym2NewtVKey(keySym), (jchar) keyChar);
}
break;
case FocusIn: