From 33968b4c39c629a1d915f85e5aff785bc06482e2 Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Wed, 26 Sep 2012 06:05:24 +0000 Subject: [PATCH] Added code to reset the actions of opposite joystick axes during analog processing. Actions were always invoked for the active axis direction but if the stick flipped to fast across the middle then the reverse axis' actions were still "pressed" and would get stuck. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9779 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/input/InputManager.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/engine/src/core/com/jme3/input/InputManager.java b/engine/src/core/com/jme3/input/InputManager.java index 9c49032c7..8c76c77b6 100644 --- a/engine/src/core/com/jme3/input/InputManager.java +++ b/engine/src/core/com/jme3/input/InputManager.java @@ -324,12 +324,28 @@ public class InputManager implements RawInputListener { } else if (value < 0) { int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); + + // Clear the reverse direction's actions in case we + // crossed center too quickly + Float otherVal = axisValues.get(otherHash); + if (otherVal != null && otherVal.floatValue() > axisDeadZone) { + invokeActions(otherHash, false); + } + invokeAnalogsAndActions(hash, -value, true); axisValues.put(hash, -value); axisValues.remove(otherHash); } else { int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); + + // Clear the reverse direction's actions in case we + // crossed center too quickly + Float otherVal = axisValues.get(otherHash); + if (otherVal != null && otherVal.floatValue() > axisDeadZone) { + invokeActions(otherHash, false); + } + invokeAnalogsAndActions(hash, value, true); axisValues.put(hash, value); axisValues.remove(otherHash);