From 02874d9c148cf549abc403e07856d7531f4fcce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Mar 2019 23:01:27 +0100 Subject: [PATCH] Align joystick axis to gamepad button behavior This is an SDL2 compatibility fix. --- src/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index a2ba1249..030cbe80 100644 --- a/src/input.c +++ b/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; } }