examples/gamepad: Show SDL ID on the terminal

This commit is contained in:
Hajime Hoshi 2021-07-18 15:41:20 +09:00
parent a9241a45c6
commit af150ad67b

View File

@ -49,12 +49,12 @@ func (g *Game) Update() error {
// Log the gamepad connection events.
g.gamepadIDsBuf = inpututil.AppendJustConnectedGamepadIDs(g.gamepadIDsBuf[:0])
for _, id := range g.gamepadIDsBuf {
log.Printf("gamepad connected: id: %d", id)
log.Printf("gamepad connected: id: %d, SDL ID: %s", id, ebiten.GamepadSDLID(id))
g.gamepadIDs[id] = struct{}{}
}
for id := range g.gamepadIDs {
if inpututil.IsGamepadJustDisconnected(id) {
log.Printf("gamepad disconnected: id: %d", id)
log.Printf("gamepad disconnected: id: %d, SDL ID: %s", id, ebiten.GamepadSDLID(id))
delete(g.gamepadIDs, id)
}
}