examples/gamepad: Add usage of inpututil

This commit is contained in:
Hajime Hoshi 2018-02-17 03:50:43 +09:00
parent debe4735cd
commit a7fafc74e7

View File

@ -24,6 +24,7 @@ import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
"github.com/hajimehoshi/ebiten/inpututil"
)
const (
@ -47,6 +48,14 @@ func update(screen *ebiten.Image) error {
if ebiten.IsGamepadButtonPressed(id, b) {
pressedButtons[id] = append(pressedButtons[id], strconv.Itoa(int(b)))
}
// Log some events.
if inpututil.IsGamepadButtonJustPressed(id, b) {
log.Printf("Button Just Pressed: id(%d), button(%d)", id, b)
}
if inpututil.IsGamepadButtonJustReleased(id, b) {
log.Printf("Button Just Released: id(%d), button(%d)", id, b)
}
}
}