mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/gamepad: fix uint16 underflow handling in gamepads. (#2030)
Fixes crash where Ebiten considers a keyboard a gamepad with way too many buttons. Updates #2027
This commit is contained in:
parent
dcccd27629
commit
1de1bfef55
@ -328,7 +328,7 @@ func (g *nativeGamepad) update(gamepad *gamepads) error {
|
||||
|
||||
switch e.typ {
|
||||
case unix.EV_KEY:
|
||||
if int(e.code)-_BTN_MISC < len(g.keyMap) {
|
||||
if int(e.code-_BTN_MISC) < len(g.keyMap) {
|
||||
idx := g.keyMap[e.code-_BTN_MISC]
|
||||
g.buttons[idx] = e.value != 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user