diff --git a/examples/blocks/blocks/gamepad.go b/examples/blocks/blocks/gamepad.go index d311e3328..5502e304e 100644 --- a/examples/blocks/blocks/gamepad.go +++ b/examples/blocks/blocks/gamepad.go @@ -123,7 +123,7 @@ func (c *gamepadConfig) initializeIfNeeded() { // For example, on PS4 controllers, L2/R2's axes valuse can be -1.0. if c.defaultAxesValues == nil { c.defaultAxesValues = map[int]float64{} - na := ebiten.GamepadAxisNum(c.gamepadID) + na := ebiten.GamepadAxisCount(c.gamepadID) for a := 0; a < na; a++ { c.defaultAxesValues[a] = ebiten.GamepadAxisValue(c.gamepadID, a) } @@ -149,7 +149,7 @@ func (c *gamepadConfig) Scan(b virtualGamepadButton) bool { delete(c.buttons, b) delete(c.axes, b) - ebn := ebiten.GamepadButton(ebiten.GamepadButtonNum(c.gamepadID)) + ebn := ebiten.GamepadButton(ebiten.GamepadButtonCount(c.gamepadID)) for eb := ebiten.GamepadButton(0); eb < ebn; eb++ { if _, ok := c.assignedButtons[eb]; ok { continue @@ -161,7 +161,7 @@ func (c *gamepadConfig) Scan(b virtualGamepadButton) bool { } } - na := ebiten.GamepadAxisNum(c.gamepadID) + na := ebiten.GamepadAxisCount(c.gamepadID) for a := 0; a < na; a++ { v := ebiten.GamepadAxisValue(c.gamepadID, a) const delta = 0.25 diff --git a/examples/gamepad/main.go b/examples/gamepad/main.go index 6e9ad21a3..b22271276 100644 --- a/examples/gamepad/main.go +++ b/examples/gamepad/main.go @@ -63,13 +63,13 @@ func (g *Game) Update() error { g.axes = map[ebiten.GamepadID][]string{} g.pressedButtons = map[ebiten.GamepadID][]string{} for id := range g.gamepadIDs { - maxAxis := ebiten.GamepadAxisNum(id) + maxAxis := ebiten.GamepadAxisCount(id) for a := 0; a < maxAxis; 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)) + maxButton := ebiten.GamepadButton(ebiten.GamepadButtonCount(id)) for b := ebiten.GamepadButton(id); b < maxButton; b++ { if ebiten.IsGamepadButtonPressed(id, b) { g.pressedButtons[id] = append(g.pressedButtons[id], strconv.Itoa(int(b))) diff --git a/input.go b/input.go index 451f6b197..5387eac7d 100644 --- a/input.go +++ b/input.go @@ -168,10 +168,10 @@ func GamepadIDs() []GamepadID { return AppendGamepadIDs(nil) } -// GamepadAxisNum returns the number of axes of the gamepad (id). +// GamepadAxisCount returns the number of axes of the gamepad (id). // -// GamepadAxisNum is concurrent-safe. -func GamepadAxisNum(id GamepadID) int { +// GamepadAxisCount is concurrent-safe. +func GamepadAxisCount(id GamepadID) int { g := gamepad.Get(id) if g == nil { return 0 @@ -179,6 +179,13 @@ func GamepadAxisNum(id GamepadID) int { return g.AxisCount() } +// GamepadAxisNum returns the number of axes of the gamepad (id). +// +// Deprecated: as of v2.4. Use GamepadAxisCount instead. +func GamepadAxisNum(id GamepadID) int { + return GamepadAxisCount(id) +} + // GamepadAxisValue returns a float value [-1.0 - 1.0] of the given gamepad (id)'s axis (axis). // // GamepadAxisValue is concurrent-safe. @@ -197,10 +204,10 @@ func GamepadAxis(id GamepadID, axis int) float64 { return GamepadAxisValue(id, axis) } -// GamepadButtonNum returns the number of the buttons of the given gamepad (id). +// GamepadButtonCount returns the number of the buttons of the given gamepad (id). // -// GamepadButtonNum is concurrent-safe. -func GamepadButtonNum(id GamepadID) int { +// GamepadButtonCount is concurrent-safe. +func GamepadButtonCount(id GamepadID) int { g := gamepad.Get(id) if g == nil { return 0 @@ -210,6 +217,13 @@ func GamepadButtonNum(id GamepadID) int { return g.ButtonCount() + g.HatCount()*4 } +// GamepadButtonNum returns the number of the buttons of the given gamepad (id). +// +// Deprecated: as of v2.4. Use GamepadButtonCount instead. +func GamepadButtonNum(id GamepadID) int { + return GamepadButtonCount(id) +} + // IsGamepadButtonPressed reports whether the given button of the gamepad (id) is pressed or not. // // If you want to know whether the given button of gamepad (id) started being pressed in the current frame,