examples/gamepad: Refactoring

This commit is contained in:
Hajime Hoshi 2018-04-30 03:07:02 +09:00
parent c9a244f498
commit b1c55f395f

View File

@ -33,10 +33,6 @@ const (
)
func update(screen *ebiten.Image) error {
ids := ebiten.GamepadIDs()
axes := map[int][]string{}
pressedButtons := map[int][]string{}
for _, id := range inpututil.JustConnectedGamepadIDs() {
log.Printf("gamepad connected: id: %d", id)
}
@ -44,6 +40,10 @@ func update(screen *ebiten.Image) error {
log.Printf("gamepad disconnected: id: %d", id)
}
ids := ebiten.GamepadIDs()
axes := map[int][]string{}
pressedButtons := map[int][]string{}
for _, id := range ids {
maxAxis := ebiten.GamepadAxisNum(id)
for a := 0; a < maxAxis; a++ {