diff --git a/examples/gamepad/main.go b/examples/gamepad/main.go index 839d55c42..64860eb11 100644 --- a/examples/gamepad/main.go +++ b/examples/gamepad/main.go @@ -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) + } } }