mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
inpututil: allow an arbitrary number of gamepad buttons. (#2031)
Fixes crash in inpututil when a gamepad with more than "allowed" buttons is connected. Closes #2027
This commit is contained in:
parent
79e93d3b12
commit
0fd630100f
@ -137,12 +137,9 @@ func (i *inputState) update() {
|
||||
for _, id := range i.gamepadIDsBuf {
|
||||
i.gamepadIDs[id] = struct{}{}
|
||||
|
||||
if _, ok := i.gamepadButtonDurations[id]; !ok {
|
||||
i.gamepadButtonDurations[id] = make([]int, ebiten.GamepadButtonMax+1)
|
||||
}
|
||||
n := ebiten.GamepadButtonNum(id)
|
||||
if n > int(ebiten.GamepadButtonMax)+1 {
|
||||
n = int(ebiten.GamepadButtonMax) + 1
|
||||
if n != len(i.gamepadButtonDurations[id]) {
|
||||
i.gamepadButtonDurations[id] = make([]int, n)
|
||||
}
|
||||
for b := ebiten.GamepadButton(0); b < ebiten.GamepadButton(n); b++ {
|
||||
if ebiten.IsGamepadButtonPressed(id, b) {
|
||||
|
Loading…
Reference in New Issue
Block a user