mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-11-01 20:22:37 +08:00
inpututil: Add APIs for the standard gamepad layout
This change adds these APIs to inpututil: * IsStandardGamepadButtonJustPressed * IsStandardGamepadButtonJustReleased * StandardGamepadButtonPressDuration Closes #1557
This commit is contained in:
@@ -67,6 +67,7 @@ func (g *Game) Update() error {
|
||||
v := ebiten.GamepadAxisValue(id, a)
|
||||
g.axes[id] = append(g.axes[id], fmt.Sprintf("%d:%+0.2f", a, v))
|
||||
}
|
||||
|
||||
maxButton := ebiten.GamepadButton(ebiten.GamepadButtonNum(id))
|
||||
for b := ebiten.GamepadButton(id); b < maxButton; b++ {
|
||||
if ebiten.IsGamepadButtonPressed(id, b) {
|
||||
@@ -81,6 +82,18 @@ func (g *Game) Update() error {
|
||||
log.Printf("button released: id: %d, button: %d", id, b)
|
||||
}
|
||||
}
|
||||
|
||||
if ebiten.HasGamepadStandardLayoutMapping(id) {
|
||||
for b := ebiten.StandardGamepadButton(0); b <= ebiten.StandardGamepadButtonMax; b++ {
|
||||
// Log button events.
|
||||
if inpututil.IsStandardGamepadButtonJustPressed(id, b) {
|
||||
log.Printf("standard button pressed: id: %d, button: %d", id, b)
|
||||
}
|
||||
if inpututil.IsStandardGamepadButtonJustReleased(id, b) {
|
||||
log.Printf("standard button released: id: %d, button: %d", id, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user