mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/gamepad: bug fix: a wireless Xbox controller didn't work correctly on macOS
The button and hat values must be adjusted by their minimum values. See also GLFW's implementation. Closes #266
This commit is contained in:
parent
62ad95186f
commit
1a2e93c594
@ -380,7 +380,7 @@ func (g *nativeGamepadImpl) update(gamepads *gamepads) error {
|
||||
}
|
||||
|
||||
for i, b := range g.buttons {
|
||||
g.buttonValues[i] = g.elementValue(&b) > 0
|
||||
g.buttonValues[i] = (g.elementValue(&b) - b.minimum) > 0
|
||||
}
|
||||
|
||||
hatStates := []int{
|
||||
@ -394,7 +394,7 @@ func (g *nativeGamepadImpl) update(gamepads *gamepads) error {
|
||||
hatLeftUp,
|
||||
}
|
||||
for i, h := range g.hats {
|
||||
if state := g.elementValue(&h); state < 0 || state >= len(hatStates) {
|
||||
if state := g.elementValue(&h) - h.minimum; state < 0 || state >= len(hatStates) {
|
||||
g.hatValues[i] = hatCentered
|
||||
} else {
|
||||
g.hatValues[i] = hatStates[state]
|
||||
|
Loading…
Reference in New Issue
Block a user