mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
examples/gamepad: Add usage of inpututil
This commit is contained in:
parent
debe4735cd
commit
a7fafc74e7
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user