Skip to content

Commit

Permalink
internal/gamepad: move constants from internal/driver
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Feb 5, 2022
1 parent 3bdd809 commit 1bee10f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion input.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool {
}

// GamepadID represents a gamepad's identifier.
type GamepadID = driver.GamepadID
type GamepadID = gamepad.ID

// GamepadSDLID returns a string with the GUID generated in the same way as SDL.
// To detect devices, see also the community project of gamepad devices database: https://github.com/gabomdq/SDL_GameControllerDB
Expand Down
2 changes: 0 additions & 2 deletions internal/driver/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

package driver

type GamepadID int

type TouchID int

type Input interface {
Expand Down
12 changes: 7 additions & 5 deletions internal/gamepad/gamepad.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
)

type ID int

const (
hatCentered = 0
hatUp = 1
Expand All @@ -45,7 +47,7 @@ type gamepads struct {
var theGamepads gamepads

// AppendGamepadIDs is concurrent-safe.
func AppendGamepadIDs(ids []driver.GamepadID) []driver.GamepadID {
func AppendGamepadIDs(ids []ID) []ID {
return theGamepads.appendGamepadIDs(ids)
}

Expand All @@ -55,17 +57,17 @@ func Update() error {
}

// Get is concurrent-safe.
func Get(id driver.GamepadID) *Gamepad {
func Get(id ID) *Gamepad {
return theGamepads.get(id)
}

func (g *gamepads) appendGamepadIDs(ids []driver.GamepadID) []driver.GamepadID {
func (g *gamepads) appendGamepadIDs(ids []ID) []ID {
g.m.Lock()
defer g.m.Unlock()

for i, gp := range g.gamepads {
if gp != nil {
ids = append(ids, driver.GamepadID(i))
ids = append(ids, ID(i))
}
}
return ids
Expand Down Expand Up @@ -97,7 +99,7 @@ func (g *gamepads) update() error {
return nil
}

func (g *gamepads) get(id driver.GamepadID) *Gamepad {
func (g *gamepads) get(id ID) *Gamepad {
g.m.Lock()
defer g.m.Unlock()

Expand Down

0 comments on commit 1bee10f

Please sign in to comment.