internal/gamepad: bug fix: crash when a too big button code is reported on Linux

Updates #2027
This commit is contained in:
Hajime Hoshi 2022-03-25 14:28:07 +09:00
parent d74a627f41
commit b985689010

View File

@ -328,8 +328,10 @@ func (g *nativeGamepad) update(gamepad *gamepads) error {
switch e.typ {
case unix.EV_KEY:
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)
}