diff options
author | Sven Gothel <[email protected]> | 2012-10-31 21:52:21 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-10-31 21:52:21 +0100 |
commit | c135d638fe820457977747e3d45960da64038d53 (patch) | |
tree | d06c63ff10944d91fa2427f9a03c0e39e4dc562f /src/newt | |
parent | 40090a5fe7f5b42c2212d9dd5351730e0f38d601 (diff) |
NEWT Windows KeyEvent: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..)
Partially reverts commit: b62e1d027c289877686d6008ea8dd40e4e1541ec
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 10 | ||||
-rw-r--r-- | src/newt/native/WindowsWindow.c | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c513b9e84..6aac8617c 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -266,6 +267,9 @@ public class WindowDriver extends WindowImpl { super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } } + + /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */ + private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); @@ -282,6 +286,10 @@ public class WindowDriver extends WindowImpl { } keyPressedState.put(keyCode, false); } + final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 != keyCharTyped ) { + keyChar = (char)keyCharTyped; + } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; @@ -304,6 +312,8 @@ public class WindowDriver extends WindowImpl { modifiers |= InputEvent.AUTOREPEAT_MASK; emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } else if( 0 != keyCode ) { + typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 2152166e4..e3d5cffa0 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -557,7 +557,7 @@ static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE } static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } @@ -584,7 +584,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, - (jint) -1, + (jint) 0, (jchar) '\177'); } @@ -592,7 +592,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s } static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } |