mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
internal/gamepad: rename functions *Num -> *Count
This commit is contained in:
parent
a8576008f0
commit
ea39fca10c
@ -183,28 +183,28 @@ func (g *Gamepad) SDLID() string {
|
||||
return g.sdlID
|
||||
}
|
||||
|
||||
// AxisNum is concurrent-safe.
|
||||
func (g *Gamepad) AxisNum() int {
|
||||
// AxisCount is concurrent-safe.
|
||||
func (g *Gamepad) AxisCount() int {
|
||||
g.m.Lock()
|
||||
defer g.m.Unlock()
|
||||
|
||||
return g.nativeGamepad.axisNum()
|
||||
return g.nativeGamepad.axisCount()
|
||||
}
|
||||
|
||||
// ButtonNum is concurrent-safe.
|
||||
func (g *Gamepad) ButtonNum() int {
|
||||
// ButtonCount is concurrent-safe.
|
||||
func (g *Gamepad) ButtonCount() int {
|
||||
g.m.Lock()
|
||||
defer g.m.Unlock()
|
||||
|
||||
return g.nativeGamepad.buttonNum()
|
||||
return g.nativeGamepad.buttonCount()
|
||||
}
|
||||
|
||||
// HatNum is concurrent-safe.
|
||||
func (g *Gamepad) HatNum() int {
|
||||
// HatCount is concurrent-safe.
|
||||
func (g *Gamepad) HatCount() int {
|
||||
g.m.Lock()
|
||||
defer g.m.Unlock()
|
||||
|
||||
return g.nativeGamepad.hatNum()
|
||||
return g.nativeGamepad.hatCount()
|
||||
}
|
||||
|
||||
// Axis is concurrent-safe.
|
||||
|
@ -396,15 +396,15 @@ func (g *nativeGamepad) hasOwnStandardLayoutMapping() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) axisNum() int {
|
||||
func (g *nativeGamepad) axisCount() int {
|
||||
return len(g.axisValues)
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) buttonNum() int {
|
||||
func (g *nativeGamepad) buttonCount() int {
|
||||
return len(g.buttonValues)
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) hatNum() int {
|
||||
func (g *nativeGamepad) hatCount() int {
|
||||
return len(g.hatValues)
|
||||
}
|
||||
|
||||
|
@ -111,15 +111,15 @@ func (g *nativeGamepad) update(gamepads *gamepads) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) axisNum() int {
|
||||
func (g *nativeGamepad) axisCount() int {
|
||||
return g.value.Get("axes").Length()
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) buttonNum() int {
|
||||
func (g *nativeGamepad) buttonCount() int {
|
||||
return g.value.Get("buttons").Length()
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) hatNum() int {
|
||||
func (g *nativeGamepad) hatCount() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -666,21 +666,21 @@ func (g *nativeGamepad) update(gamepads *gamepads) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) axisNum() int {
|
||||
func (g *nativeGamepad) axisCount() int {
|
||||
if g.usesDInput() {
|
||||
return len(g.dinputAxes)
|
||||
}
|
||||
return 6
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) buttonNum() int {
|
||||
func (g *nativeGamepad) buttonCount() int {
|
||||
if g.usesDInput() {
|
||||
return len(g.dinputButtons)
|
||||
}
|
||||
return len(xinputButtons)
|
||||
}
|
||||
|
||||
func (g *nativeGamepad) hatNum() int {
|
||||
func (g *nativeGamepad) hatCount() int {
|
||||
if g.usesDInput() {
|
||||
return len(g.dinputHats)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func (i *Input) GamepadAxisNum(id driver.GamepadID) int {
|
||||
if g == nil {
|
||||
return 0
|
||||
}
|
||||
return g.AxisNum()
|
||||
return g.AxisCount()
|
||||
}
|
||||
|
||||
func (i *Input) GamepadAxisValue(id driver.GamepadID, axis int) float64 {
|
||||
@ -74,7 +74,7 @@ func (i *Input) GamepadButtonNum(id driver.GamepadID) int {
|
||||
}
|
||||
|
||||
// For backward compatibility, hats are treated as buttons in GLFW.
|
||||
return g.ButtonNum() + g.HatNum()*4
|
||||
return g.ButtonCount() + g.HatCount()*4
|
||||
}
|
||||
|
||||
func (i *Input) IsGamepadButtonPressed(id driver.GamepadID, button driver.GamepadButton) bool {
|
||||
@ -83,13 +83,13 @@ func (i *Input) IsGamepadButtonPressed(id driver.GamepadID, button driver.Gamepa
|
||||
return false
|
||||
}
|
||||
|
||||
nbuttons := g.ButtonNum()
|
||||
nbuttons := g.ButtonCount()
|
||||
if int(button) < nbuttons {
|
||||
return g.Button(int(button))
|
||||
}
|
||||
|
||||
// For backward compatibility, hats are treated as buttons in GLFW.
|
||||
if hat := (int(button) - nbuttons) / 4; hat < g.HatNum() {
|
||||
if hat := (int(button) - nbuttons) / 4; hat < g.HatCount() {
|
||||
dir := (int(button) - nbuttons) % 4
|
||||
return g.Hat(hat)&(1<<dir) != 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user