love.joystick: more fixes for duplicate platform fields in gamepad mapping strings.

This commit is contained in:
Sasha Szpakowski
2023-06-18 11:54:17 -03:00
parent df7a55911d
commit 5f4f0b424b
+7 -3
View File
@@ -470,7 +470,9 @@ std::string JoystickModule::getGamepadMappingString(const std::string &guid) con
// Matches SDL_GameControllerAddMappingsFromRW.
if (mapping.find_last_of(',') != mapping.length() - 1)
mapping += ",";
mapping += "platform:" + std::string(SDL_GetPlatform());
if (mapping.find("platform:") == std::string::npos)
mapping += "platform:" + std::string(SDL_GetPlatform());
return mapping;
}
@@ -494,8 +496,10 @@ std::string JoystickModule::saveGamepadMappings()
mapping += ",";
// Matches SDL_GameControllerAddMappingsFromRW.
mapping += "platform:" + std::string(SDL_GetPlatform()) + ",\n";
mappings += mapping;
if (mapping.find("platform:") == std::string::npos)
mapping += "platform:" + std::string(SDL_GetPlatform()) + ",";
mappings += mapping + "\n";
}
return mappings;