internal/gamepaddb: Bug fix: ButtonValue must return [0, 1]

This commit is contained in:
Hajime Hoshi 2021-09-23 15:18:16 +09:00
parent 0fdec144ef
commit 226378da88

View File

@ -407,9 +407,9 @@ func ButtonValue(id string, button driver.StandardGamepadButton, state GamepadSt
case mappingTypeAxis:
v := state.Axis(m.Index)*float64(m.AxisScale) + float64(m.AxisOffset)
if v > 1 {
return 1
v = 1
} else if v < -1 {
return -1
v = -1
}
// Adjust [-1, 1] to [0, 1]
return (v + 1) / 2