From 8777a6f0b8d5aa7c97643c68c4641593c6fa2c46 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Sep 2012 21:24:58 +0200 Subject: Complete 646714d3dab87396b9a3119bf90ca26e0b1c97ce / Fix Bug 601: Add missing enqueueKeyEvent(..) in WindowsDriver; Fix API doc typo. --- .../classes/com/jogamp/newt/event/KeyEvent.java | 2 +- .../jogamp/newt/driver/windows/WindowDriver.java | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index bd48981da..7daaeada6 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -45,7 +45,7 @@ package com.jogamp.newt.event; * deliver keyboard events in the above order or skip events, * the NEWT driver will reorder and inject synthetic events if required. *

- * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. *

*/ diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 18cc88472..71437c461 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -313,7 +313,27 @@ public class WindowDriver extends WindowImpl { public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + break; + case KeyEvent.EVENT_KEY_PRESSED: + if(pressedKeyBalance > 1) { + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + pressedKeyBalance--; + autoRepeat |= InputEvent.AUTOREPEAT_MASK; + } else { + autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + } + super.enqueueKeyEvent(wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + break; + case KeyEvent.EVENT_KEY_TYPED: + modifiers |= autoRepeat; + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + break; + } } //---------------------------------------------------------------------- -- cgit v1.2.3