Răsfoiți Sursa

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 13 ani în urmă
părinte
comite
33968b4c39
1 a modificat fișierele cu 16 adăugiri și 0 ștergeri
  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);