diff --git a/input.go b/input.go index f048707f0..d37acad20 100644 --- a/input.go +++ b/input.go @@ -304,6 +304,15 @@ func IsStandardGamepadLayoutAvailable(id GamepadID) bool { // When using this facility to support new hardware, please also send a pull request to // https://github.com/gabomdq/SDL_GameControllerDB to make your mapping available to everyone else. // +// A platform field in a line corresponds with a GOOS like the following: +// +// "Windows": GOOS=windows +// "Mac OS X": GOOS=darwin (not ios) +// "Linux": GOOS=linux (not android) +// "Android": GOOS=android +// "iOS": GOOS=ios +// "": Any GOOS +// // On platforms where gamepad mappings are not managed by Ebiten, this always returns false and nil. // // UpdateStandardGamepadLayoutMappings is concurrent-safe. diff --git a/internal/gamepaddb/gamepaddb.go b/internal/gamepaddb/gamepaddb.go index d033ddf88..dfcfdfcfc 100644 --- a/internal/gamepaddb/gamepaddb.go +++ b/internal/gamepaddb/gamepaddb.go @@ -145,6 +145,8 @@ func processLine(line string, platform platform) error { continue } tks := strings.Split(token, ":") + + // Note that the platform part is listed in the definition of SDL_GetPlatform. if tks[0] == "platform" { switch tks[1] { case "Windows": @@ -167,6 +169,8 @@ func processLine(line string, platform platform) error { if platform != platformIOS { return nil } + case "": + // Allow any platforms default: return fmt.Errorf("gamepaddb: unexpected platform: %s", tks[1]) } @@ -503,10 +507,6 @@ func IsButtonPressed(id string, button StandardButton, state GamepadState) bool // Update adds new gamepad mappings. // The string must be in the format of SDL_GameControllerDB. func Update(mapping []byte) (bool, error) { - if currentPlatform == platformUnknown { - return false, nil - } - mappingsM.Lock() defer mappingsM.Unlock()