gamepad: Accept older 'Mac OS X' mappings on macOS
This commit is contained in:
@@ -2360,14 +2360,25 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id
|
|||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SDL_PrivateIsGamepadPlatformMatch(const char *platform, size_t platform_len)
|
||||||
|
{
|
||||||
|
#ifdef SDL_PLATFORM_MACOS
|
||||||
|
// We also accept the older SDL2 platform name for macOS
|
||||||
|
if (SDL_strncasecmp(platform, "Mac OS X", platform_len) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return SDL_strncasecmp(platform, SDL_GetPlatform(), platform_len) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add or update an entry into the Mappings Database
|
* Add or update an entry into the Mappings Database
|
||||||
*/
|
*/
|
||||||
int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio)
|
int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio)
|
||||||
{
|
{
|
||||||
const char *platform = SDL_GetPlatform();
|
|
||||||
int gamepads = 0;
|
int gamepads = 0;
|
||||||
char *buf, *line, *line_end, *tmp, *comma, line_platform[64];
|
char *buf, *line, *line_end, *tmp, *comma, *platform;
|
||||||
size_t db_size;
|
size_t db_size;
|
||||||
size_t platform_len;
|
size_t platform_len;
|
||||||
|
|
||||||
@@ -2396,16 +2407,14 @@ int SDL_AddGamepadMappingsFromIO(SDL_IOStream *src, bool closeio)
|
|||||||
tmp += SDL_GAMEPAD_PLATFORM_FIELD_SIZE;
|
tmp += SDL_GAMEPAD_PLATFORM_FIELD_SIZE;
|
||||||
comma = SDL_strchr(tmp, ',');
|
comma = SDL_strchr(tmp, ',');
|
||||||
if (comma) {
|
if (comma) {
|
||||||
platform_len = comma - tmp + 1;
|
platform = tmp;
|
||||||
if (platform_len + 1 < SDL_arraysize(line_platform)) {
|
platform_len = comma - platform;
|
||||||
SDL_strlcpy(line_platform, tmp, platform_len);
|
if (SDL_PrivateIsGamepadPlatformMatch(platform, platform_len) &&
|
||||||
if (SDL_strncasecmp(line_platform, platform, platform_len) == 0 &&
|
|
||||||
SDL_AddGamepadMapping(line) > 0) {
|
SDL_AddGamepadMapping(line) > 0) {
|
||||||
gamepads++;
|
gamepads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
line = line_end + 1;
|
line = line_end + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user