mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +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 {
|
switch e.typ {
|
||||||
case unix.EV_KEY:
|
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]
|
idx := g.keyMap[e.code-_BTN_MISC]
|
||||||
g.buttons[idx] = e.value != 0
|
g.buttons[idx] = e.value != 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user