From ea39fca10c3bed676d642b553d1966cf6dc20abf Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 2 Feb 2022 02:01:46 +0900 Subject: [PATCH] internal/gamepad: rename functions *Num -> *Count --- internal/gamepad/gamepad.go | 18 +++++++++--------- internal/gamepad/gamepad_darwin.go | 6 +++--- internal/gamepad/gamepad_js.go | 6 +++--- internal/gamepad/gamepad_windows.go | 6 +++--- internal/uidriver/glfw/gamepad_native.go | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/gamepad/gamepad.go b/internal/gamepad/gamepad.go index cc13e56da..729da77de 100644 --- a/internal/gamepad/gamepad.go +++ b/internal/gamepad/gamepad.go @@ -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. diff --git a/internal/gamepad/gamepad_darwin.go b/internal/gamepad/gamepad_darwin.go index 8761f63d7..b85e21d50 100644 --- a/internal/gamepad/gamepad_darwin.go +++ b/internal/gamepad/gamepad_darwin.go @@ -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) } diff --git a/internal/gamepad/gamepad_js.go b/internal/gamepad/gamepad_js.go index 4d56308ed..d70386bd9 100644 --- a/internal/gamepad/gamepad_js.go +++ b/internal/gamepad/gamepad_js.go @@ -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 } diff --git a/internal/gamepad/gamepad_windows.go b/internal/gamepad/gamepad_windows.go index 26ca95c03..4f97de5c1 100644 --- a/internal/gamepad/gamepad_windows.go +++ b/internal/gamepad/gamepad_windows.go @@ -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) } diff --git a/internal/uidriver/glfw/gamepad_native.go b/internal/uidriver/glfw/gamepad_native.go index 58fee2021..b9c37622a 100644 --- a/internal/uidriver/glfw/gamepad_native.go +++ b/internal/uidriver/glfw/gamepad_native.go @@ -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<