input: Rename GamepadGUID -> GamepadSDLID (#1049)

Gamepad GUID is a SDL specific notion and, strictly speaking,
they are not GUID (UUID) since they don't follow UUID's
specifications.

Renaming the function makes the situation clearer.

Updates #1048
This commit is contained in:
Hajime Hoshi 2020-01-11 15:50:37 +09:00 committed by GitHub
parent 68d58d7452
commit b4819c4523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 9 deletions

View File

@ -92,13 +92,14 @@ func IsMouseButtonPressed(mouseButton MouseButton) bool {
return uiDriver().Input().IsMouseButtonPressed(driver.MouseButton(mouseButton))
}
// GamepadGUID returns a string with the uuid.
// 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
//
// GamepadGUID always returns an empty string on browsers and mobiles.
// GamepadSDLID always returns an empty string on browsers and mobiles.
//
// GamepadGUID is concurrent-safe.
func GamepadGUID(id int) string {
return uiDriver().Input().GamepadGUID(id)
// GamepadSDLID is concurrent-safe.
func GamepadSDLID(id int) string {
return uiDriver().Input().GamepadSDLID(id)
}
// GamepadName returns a string with the name.

View File

@ -16,7 +16,7 @@ package driver
type Input interface {
CursorPosition() (x, y int)
GamepadGUID(id int) string
GamepadSDLID(id int) string
GamepadName(id int) string
GamepadAxis(id int, axis int) float64
GamepadAxisNum(id int) int

View File

@ -87,7 +87,7 @@ func (i *Input) GamepadIDs() []int {
return r
}
func (i *Input) GamepadGUID(id int) string {
func (i *Input) GamepadSDLID(id int) string {
if !i.ui.isRunning() {
return ""
}
@ -356,6 +356,7 @@ func (i *Input) update(window *glfw.Window, context driver.UIContext) {
continue
}
i.gamepads[id].valid = true
// Note that GLFW's gamepad GUID follows SDL's GUID.
i.gamepads[id].guid = id.GetGUID()
i.gamepads[id].name = id.GetName()

View File

@ -57,7 +57,9 @@ func (i *Input) CursorPosition() (x, y int) {
return int(xf), int(yf)
}
func (i *Input) GamepadGUID(id int) string {
func (i *Input) GamepadSDLID(id int) string {
// TODO: Implement this. See the implementation of SDL:
// https://github.com/spurious/SDL-mirror/blob/master/src/joystick/emscripten/SDL_sysjoystick.c
return ""
}

View File

@ -42,7 +42,7 @@ func (i *Input) GamepadIDs() []int {
return nil
}
func (i *Input) GamepadGUID(id int) string {
func (i *Input) GamepadSDLID(id int) string {
return ""
}