From 92757f8a9d5414101e5415a941b70b2cccea660f Mon Sep 17 00:00:00 2001 From: "jul..se" Date: Sun, 4 Aug 2013 08:36:06 +0000 Subject: [PATCH] Sends all key events (including repeat events) in the JOGL NEWT backend git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10744 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/input/jogl/NewtKeyInput.java | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/engine/src/jogl/com/jme3/input/jogl/NewtKeyInput.java b/engine/src/jogl/com/jme3/input/jogl/NewtKeyInput.java index fd43f54a2..8ae427074 100644 --- a/engine/src/jogl/com/jme3/input/jogl/NewtKeyInput.java +++ b/engine/src/jogl/com/jme3/input/jogl/NewtKeyInput.java @@ -39,7 +39,6 @@ import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.opengl.GLWindow; import java.util.ArrayList; -import java.util.BitSet; import java.util.logging.Level; import java.util.logging.Logger; @@ -50,7 +49,6 @@ public class NewtKeyInput implements KeyInput, KeyListener { private final ArrayList eventQueue = new ArrayList(); private RawInputListener listener; private GLWindow component; - private BitSet keyStateSet = new BitSet(0xFF); public NewtKeyInput() { } @@ -66,7 +64,6 @@ public class NewtKeyInput implements KeyInput, KeyListener { if (component != null){ component.removeKeyListener(this); eventQueue.clear(); - keyStateSet.clear(); } component = comp; component.addKeyListener(this); @@ -96,34 +93,23 @@ public class NewtKeyInput implements KeyInput, KeyListener { } public void keyTyped(KeyEvent evt) { - // key code is zero for typed events } public void keyPressed(KeyEvent evt) { int code = convertNewtKey(evt.getKeySymbol()); - - // Check if key was already pressed - if (!keyStateSet.get(code)){ - keyStateSet.set(code); - KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, false); - keyEvent.setTime(evt.getWhen()); - synchronized (eventQueue){ - eventQueue.add(keyEvent); - } + KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), true, evt.isAutoRepeat()); + keyEvent.setTime(evt.getWhen()); + synchronized (eventQueue){ + eventQueue.add(keyEvent); } } public void keyReleased(KeyEvent evt) { int code = convertNewtKey(evt.getKeySymbol()); - - // Check if key was already released - if (keyStateSet.get(code)) { - keyStateSet.clear(code); - KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, false); - keyEvent.setTime(evt.getWhen()); - synchronized (eventQueue){ - eventQueue.add(keyEvent); - } + KeyInputEvent keyEvent = new KeyInputEvent(code, evt.getKeyChar(), false, evt.isAutoRepeat()); + keyEvent.setTime(evt.getWhen()); + synchronized (eventQueue) { + eventQueue.add(keyEvent); } }