mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 11:48:55 +01:00
internal/gamepad: move constants from internal/driver
This commit is contained in:
parent
3bdd8097b5
commit
1bee10f999
2
input.go
2
input.go
@ -120,7 +120,7 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GamepadID represents a gamepad's identifier.
|
// 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.
|
// 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
|
// To detect devices, see also the community project of gamepad devices database: https://github.com/gabomdq/SDL_GameControllerDB
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
package driver
|
package driver
|
||||||
|
|
||||||
type GamepadID int
|
|
||||||
|
|
||||||
type TouchID int
|
type TouchID int
|
||||||
|
|
||||||
type Input interface {
|
type Input interface {
|
||||||
|
@ -22,6 +22,8 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
|
"github.com/hajimehoshi/ebiten/v2/internal/gamepaddb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ID int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
hatCentered = 0
|
hatCentered = 0
|
||||||
hatUp = 1
|
hatUp = 1
|
||||||
@ -45,7 +47,7 @@ type gamepads struct {
|
|||||||
var theGamepads gamepads
|
var theGamepads gamepads
|
||||||
|
|
||||||
// AppendGamepadIDs is concurrent-safe.
|
// AppendGamepadIDs is concurrent-safe.
|
||||||
func AppendGamepadIDs(ids []driver.GamepadID) []driver.GamepadID {
|
func AppendGamepadIDs(ids []ID) []ID {
|
||||||
return theGamepads.appendGamepadIDs(ids)
|
return theGamepads.appendGamepadIDs(ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,17 +57,17 @@ func Update() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get is concurrent-safe.
|
// Get is concurrent-safe.
|
||||||
func Get(id driver.GamepadID) *Gamepad {
|
func Get(id ID) *Gamepad {
|
||||||
return theGamepads.get(id)
|
return theGamepads.get(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gamepads) appendGamepadIDs(ids []driver.GamepadID) []driver.GamepadID {
|
func (g *gamepads) appendGamepadIDs(ids []ID) []ID {
|
||||||
g.m.Lock()
|
g.m.Lock()
|
||||||
defer g.m.Unlock()
|
defer g.m.Unlock()
|
||||||
|
|
||||||
for i, gp := range g.gamepads {
|
for i, gp := range g.gamepads {
|
||||||
if gp != nil {
|
if gp != nil {
|
||||||
ids = append(ids, driver.GamepadID(i))
|
ids = append(ids, ID(i))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ids
|
return ids
|
||||||
@ -97,7 +99,7 @@ func (g *gamepads) update() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gamepads) get(id driver.GamepadID) *Gamepad {
|
func (g *gamepads) get(id ID) *Gamepad {
|
||||||
g.m.Lock()
|
g.m.Lock()
|
||||||
defer g.m.Unlock()
|
defer g.m.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user