mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/gamepad: bug fix: crash when a too big button code is reported on Linux
Updates #2027
This commit is contained in:
parent
d74a627f41
commit
b985689010
@ -328,8 +328,10 @@ func (g *nativeGamepad) update(gamepad *gamepads) error {
|
||||
|
||||
switch e.typ {
|
||||
case unix.EV_KEY:
|
||||
idx := g.keyMap[e.code-_BTN_MISC]
|
||||
g.buttons[idx] = e.value != 0
|
||||
if e.code-_BTN_MISC < len(g.keyMap) {
|
||||
idx := g.keyMap[e.code-_BTN_MISC]
|
||||
g.buttons[idx] = e.value != 0
|
||||
}
|
||||
case unix.EV_ABS:
|
||||
g.handleAbsEvent(int(e.code), e.value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user