inpututil: bug fix: out of range at scanning buttons

Updates #2169
This commit is contained in:
Hajime Hoshi 2022-06-29 15:55:05 +09:00
parent ddef7351c1
commit a1db69000e

View File

@ -140,8 +140,7 @@ func (i *inputState) update() {
if _, ok := i.gamepadButtonDurations[id]; !ok { if _, ok := i.gamepadButtonDurations[id]; !ok {
i.gamepadButtonDurations[id] = make([]int, ebiten.GamepadButtonMax+1) i.gamepadButtonDurations[id] = make([]int, ebiten.GamepadButtonMax+1)
} }
n := ebiten.GamepadButtonNum(id) for b := ebiten.GamepadButton(0); b <= ebiten.GamepadButtonMax; b++ {
for b := ebiten.GamepadButton(0); b < ebiten.GamepadButton(n); b++ {
if ebiten.IsGamepadButtonPressed(id, b) { if ebiten.IsGamepadButtonPressed(id, b) {
i.gamepadButtonDurations[id][b]++ i.gamepadButtonDurations[id][b]++
} else { } else {