summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java10
-rw-r--r--src/newt/native/WindowsWindow.c6
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;
}