Fix invalid ranges for gamepad axis sources

Buttons and hat bits were mapped to [0,1] instead of [-1,1].

Fixes #1293.
This commit is contained in:
Camilla Löwy 2019-03-27 19:35:19 +01:00
parent 980fc9b52f
commit 9420e6f0d0

View File

@ -1286,9 +1286,11 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
const unsigned int bit = e->index & 0xf; const unsigned int bit = e->index & 0xf;
if (js->hats[hat] & bit) if (js->hats[hat] & bit)
state->axes[i] = 1.f; state->axes[i] = 1.f;
else
state->axes[i] = -1.f;
} }
else if (e->type == _GLFW_JOYSTICK_BUTTON) 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; return GLFW_TRUE;