examples: Use GamepadAxisValue

Updates #1719
This commit is contained in:
Hajime Hoshi 2021-07-19 01:31:17 +09:00
parent dbcb220742
commit 700052519c
2 changed files with 4 additions and 4 deletions

View File

@ -95,7 +95,7 @@ func (c *gamepadConfig) initializeIfNeeded() {
c.defaultAxesValues = map[int]float64{}
na := ebiten.GamepadAxisNum(c.gamepadID)
for a := 0; a < na; a++ {
c.defaultAxesValues[a] = ebiten.GamepadAxis(c.gamepadID, a)
c.defaultAxesValues[a] = ebiten.GamepadAxisValue(c.gamepadID, a)
}
}
}
@ -136,7 +136,7 @@ func (c *gamepadConfig) Scan(b virtualGamepadButton) bool {
na := ebiten.GamepadAxisNum(c.gamepadID)
for a := 0; a < na; a++ {
v := ebiten.GamepadAxis(c.gamepadID, a)
v := ebiten.GamepadAxisValue(c.gamepadID, a)
const delta = 0.25
// Check |v| < 1.0 because there is a bug that a button returns
@ -177,7 +177,7 @@ func (c *gamepadConfig) IsButtonPressed(b virtualGamepadButton) bool {
a, ok := c.axes[b]
if ok {
v := ebiten.GamepadAxis(c.gamepadID, a.id)
v := ebiten.GamepadAxisValue(c.gamepadID, a.id)
if a.positive {
return axisThreshold <= v && v <= 1.0
} else {

View File

@ -64,7 +64,7 @@ func (g *Game) Update() error {
for id := range g.gamepadIDs {
maxAxis := ebiten.GamepadAxisNum(id)
for a := 0; a < maxAxis; a++ {
v := ebiten.GamepadAxis(id, a)
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))