mirror of
https://github.com/love2d/love.git
synced 2026-08-21 21:15:09 +02:00
Fix love.joystick.setGamepadMapping breaking the mapping string when replacing an existing binding.
issue #1936.
This commit is contained in:
@@ -259,11 +259,16 @@ bool JoystickModule::setGamepadMapping(const std::string &guid, Joystick::Gamepa
|
||||
if (endpos == std::string::npos)
|
||||
endpos = mapstr.length() - 1;
|
||||
|
||||
mapstr.replace(findpos + 1, endpos - findpos + 1, insertstr);
|
||||
mapstr.replace(findpos + 1, endpos - findpos, insertstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just append to the end if we don't need to replace anything.
|
||||
// Just append to the end (or before the platform section if that exists),
|
||||
// if we don't need to replace anything.
|
||||
size_t platformpos = mapstr.find("platform:");
|
||||
if (platformpos != std::string::npos)
|
||||
mapstr.insert(platformpos, insertstr);
|
||||
else
|
||||
mapstr += insertstr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user