From 9420e6f0d090f2f3fe61f71d5e05220f5245c861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 27 Mar 2019 19:35:19 +0100 Subject: [PATCH] Fix invalid ranges for gamepad axis sources Buttons and hat bits were mapped to [0,1] instead of [-1,1]. Fixes #1293. --- src/input.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 7ee42811..680de6e5 100644 --- a/src/input.c +++ b/src/input.c @@ -1286,9 +1286,11 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) const unsigned int bit = e->index & 0xf; if (js->hats[hat] & bit) state->axes[i] = 1.f; + else + state->axes[i] = -1.f; } else if (e->type == _GLFW_JOYSTICK_BUTTON) - state->axes[i] = (float) js->buttons[e->index]; + state->axes[i] = js->buttons[e->index] * 2.f - 1.f; } return GLFW_TRUE;