Quellcode durchsuchen

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

PSp..om vor 13 Jahren
Ursprung
Commit
33968b4c39
1 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen
  1. 16 0
      engine/src/core/com/jme3/input/InputManager.java

+ 16 - 0
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);