mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 07:34:35 +00:00
Fix half-axis to gamepad button value mapping
Negative half-axes were not negated when mapped onto gamepad buttons.
This commit is contained in:
parent
cad22cb2f6
commit
c32dc3a085
10
src/input.c
10
src/input.c
@ -1258,9 +1258,19 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
|||||||
if (e->type == _GLFW_JOYSTICK_AXIS)
|
if (e->type == _GLFW_JOYSTICK_AXIS)
|
||||||
{
|
{
|
||||||
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
|
||||||
|
// TODO: Bake into transform when implementing output modifiers
|
||||||
|
if (e->axisScale < 0 || e->axisOffset < 0)
|
||||||
|
{
|
||||||
if (value > 0.f)
|
if (value > 0.f)
|
||||||
state->buttons[i] = GLFW_PRESS;
|
state->buttons[i] = GLFW_PRESS;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (value < 0.f)
|
||||||
|
state->buttons[i] = GLFW_PRESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
else if (e->type == _GLFW_JOYSTICK_HATBIT)
|
||||||
{
|
{
|
||||||
const unsigned int hat = e->index >> 4;
|
const unsigned int hat = e->index >> 4;
|
||||||
|
Loading…
Reference in New Issue
Block a user