summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2020-02-09 01:37:30 +0000
committerGitHub <noreply@github.com>2020-02-09 01:37:30 +0000
commit2e2540317e8752b8fe2e4d549a0b5c1ab1911041 (patch)
treec5997fb92fc14a5dbbc061a5b572da18d0877e86 /Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
parent7fe11c95782a305e1e03a401e54d819700b39805 (diff)
parent0a1634bedf17f7b27a3781d8e5ac6bafb20cd546 (diff)
Merge pull request #8417 from jordan-woyak/setting-expressions
InputCommon: Allow controller settings specified with input expresions.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
index 40ccae24f7..1a262a8dfd 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
@@ -74,15 +74,19 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
ext->SetSelectedAttachment(0);
u32 n = 0;
- std::string extname;
- sec->Get(base + name, &extname, "");
+ std::string attachment_text;
+ sec->Get(base + name, &attachment_text, "");
+
+ // First assume attachment string is a valid expression.
+ // If it instead matches one of the names of our attachments it is overridden below.
+ ext->GetSelectionSetting().GetInputReference().SetExpression(attachment_text);
for (auto& ai : ext->GetAttachmentList())
{
ai->SetDefaultDevice(defdev);
ai->LoadConfig(sec, base + ai->GetName() + "/");
- if (ai->GetName() == extname)
+ if (ai->GetName() == attachment_text)
ext->SetSelectedAttachment(n);
n++;
@@ -114,8 +118,16 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
if (type == GroupType::Attachments)
{
auto* const ext = static_cast<Attachments*>(this);
- sec->Set(base + name, ext->GetAttachmentList()[ext->GetSelectedAttachment()]->GetName(),
- "None");
+
+ if (ext->GetSelectionSetting().IsSimpleValue())
+ {
+ sec->Set(base + name, ext->GetAttachmentList()[ext->GetSelectedAttachment()]->GetName(),
+ "None");
+ }
+ else
+ {
+ sec->Set(base + name, ext->GetSelectionSetting().GetInputReference().GetExpression(), "None");
+ }
for (auto& ai : ext->GetAttachmentList())
ai->SaveConfig(sec, base + ai->GetName() + "/");