mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/gamepaddb: allow the standard layout mapping for any platforms
Closes #1957
This commit is contained in:
parent
19bfc97a5e
commit
93b2a0756b
9
input.go
9
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
|
// 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.
|
// 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.
|
// On platforms where gamepad mappings are not managed by Ebiten, this always returns false and nil.
|
||||||
//
|
//
|
||||||
// UpdateStandardGamepadLayoutMappings is concurrent-safe.
|
// UpdateStandardGamepadLayoutMappings is concurrent-safe.
|
||||||
|
@ -145,6 +145,8 @@ func processLine(line string, platform platform) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tks := strings.Split(token, ":")
|
tks := strings.Split(token, ":")
|
||||||
|
|
||||||
|
// Note that the platform part is listed in the definition of SDL_GetPlatform.
|
||||||
if tks[0] == "platform" {
|
if tks[0] == "platform" {
|
||||||
switch tks[1] {
|
switch tks[1] {
|
||||||
case "Windows":
|
case "Windows":
|
||||||
@ -167,6 +169,8 @@ func processLine(line string, platform platform) error {
|
|||||||
if platform != platformIOS {
|
if platform != platformIOS {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
case "":
|
||||||
|
// Allow any platforms
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("gamepaddb: unexpected platform: %s", tks[1])
|
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.
|
// Update adds new gamepad mappings.
|
||||||
// The string must be in the format of SDL_GameControllerDB.
|
// The string must be in the format of SDL_GameControllerDB.
|
||||||
func Update(mapping []byte) (bool, error) {
|
func Update(mapping []byte) (bool, error) {
|
||||||
if currentPlatform == platformUnknown {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
mappingsM.Lock()
|
mappingsM.Lock()
|
||||||
defer mappingsM.Unlock()
|
defer mappingsM.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user