Align joystick axis to gamepad button behavior

From upstream: 02874d9c14.
This commit is contained in:
Luflosi 2020-05-25 11:44:14 +02:00
parent e7447f38cf
commit fcc7a0255a
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0

6
glfw/input.c vendored
View File

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