internal/gamepad: skip gamepads with more than 32 buttons

This change was removed at ef45058037
accidentally.

Updates #1173
Updates #2039
This commit is contained in:
Hajime Hoshi 2022-04-01 02:22:25 +09:00
parent b5a9ff007c
commit 07a7aca1b3

View File

@ -87,6 +87,13 @@ func (g *gamepads) update() error {
return err return err
} }
// A gamepad can be detected even though there are not. Apparently, some special devices are
// recognized as gamepads by OSes. In this case, the number of the 'buttons' can exceeds the
// maximum. Skip such devices as a tentative solution (#1173, #2039).
g.remove(func(gamepad *Gamepad) bool {
return gamepad.ButtonCount() > ButtonNum
})
for _, gp := range g.gamepads { for _, gp := range g.gamepads {
if gp == nil { if gp == nil {
continue continue