Selaa lähdekoodia

Align joystick axis to gamepad button behavior

This is an SDL2 compatibility fix.
Camilla Löwy 6 vuotta sitten
vanhempi
commit
02874d9c14
1 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 3 3
      src/input.c

+ 3 - 3
src/input.c

@@ -1260,14 +1260,14 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
             const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
             // HACK: This should be baked into the value transform
             // TODO: Bake into transform when implementing output modifiers
-            if (e->axisScale < 0 || e->axisOffset < 0)
+            if (e->axisOffset < 0 || (e->axisOffset == 0 && e->axisScale > 0))
             {
-                if (value > 0.f)
+                if (value >= 0.f)
                     state->buttons[i] = GLFW_PRESS;
             }
             else
             {
-                if (value < 0.f)
+                if (value <= 0.f)
                     state->buttons[i] = GLFW_PRESS;
             }
         }