summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2021-05-11 16:30:29 +0300
committerFiloppi <filippotarpini@hotmail.it>2021-05-12 18:25:56 +0300
commit574477866fe3e82a87214848d3d4b505535f2d3b (patch)
treeec9a72016dbc420cd200ad7c8c2a9bb571eefc4f /Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
parenteb5cd9be78c76b9ccbab9e5fbd1721ef6876cd68 (diff)
InputCommon: fix serialization of control expression with line breaks
The control expression editor allows line breaks, but the serialization was losing anything after the first line break (/r /n). Instead of opting to encode them and decode them on serialization (which I tried but was not safe, as it would lose /n written in the string by users), I opted to replace them with a space.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
index 84c7238e48..2862445392 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
@@ -117,7 +117,10 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
for (auto& c : controls)
{
// control expression
- sec->Set(group + c->name, c->control_ref->GetExpression(), "");
+ std::string expression = c->control_ref->GetExpression();
+ // We can't save line breaks in a single line config. Restoring them is too complicated.
+ ReplaceBreaksWithSpaces(expression);
+ sec->Set(group + c->name, expression, "");
// range
sec->Set(group + c->name + "/Range", c->control_ref->range * 100.0, 100.0);
@@ -135,7 +138,9 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
}
else
{
- sec->Set(base + name, ext->GetSelectionSetting().GetInputReference().GetExpression(), "None");
+ std::string expression = ext->GetSelectionSetting().GetInputReference().GetExpression();
+ ReplaceBreaksWithSpaces(expression);
+ sec->Set(base + name, expression, "None");
}
for (auto& ai : ext->GetAttachmentList())