diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-01-20 23:19:56 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2025-03-15 14:30:43 -0500 |
| commit | ddb82a5e8ca84df1b95942c8b3a1fa6c9071010b (patch) | |
| tree | 996de0475d813c192e64a0f3d6004181cdf54b8e /Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp | |
| parent | 225039f742d14eacd704490bb1a66dc119a91320 (diff) | |
InputCommon/ControllerEmu: Break out functionality of EmulatedController
to eliminate redundant unused members in Wii Remote extension objects.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp | 60 |
1 files changed, 9 insertions, 51 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp index 2896acd070..93367649f9 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp @@ -3,13 +3,11 @@ #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" -#include "Common/CommonTypes.h" #include "Common/IniFile.h" #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/Control/Output.h" -#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" #include "InputCommon/ControllerEmu/Setting/NumericSetting.h" @@ -50,8 +48,7 @@ void ControlGroup::AddDeadzoneSetting(SettingValue<double>* value, double maximu ControlGroup::~ControlGroup() = default; -void ControlGroup::LoadConfig(Common::IniFile::Section* sec, const std::string& defdev, - const std::string& base) +void ControlGroup::LoadConfig(Common::IniFile::Section* sec, const std::string& base) { const std::string group(base + name + "/"); @@ -75,36 +72,9 @@ void ControlGroup::LoadConfig(Common::IniFile::Section* sec, const std::string& sec->Get(group + c->name + "/Range", &c->control_ref->range, 100.0); c->control_ref->range /= 100; } - - // extensions - if (type == GroupType::Attachments) - { - auto* const ext = static_cast<Attachments*>(this); - - ext->SetSelectedAttachment(0); - u32 n = 0; - 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() == attachment_text) - ext->SetSelectedAttachment(n); - - n++; - } - } } -void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string& defdev, - const std::string& base) +void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string& base) { const std::string group(base + name + "/"); @@ -125,27 +95,15 @@ void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string& // range sec->Set(group + c->name + "/Range", c->control_ref->range * 100.0, 100.0); } +} - // extensions - if (type == GroupType::Attachments) - { - auto* const ext = static_cast<Attachments*>(this); - - if (ext->GetSelectionSetting().IsSimpleValue()) - { - sec->Set(base + name, ext->GetAttachmentList()[ext->GetSelectedAttachment()]->GetName(), - "None"); - } - else - { - std::string expression = ext->GetSelectionSetting().GetInputReference().GetExpression(); - ReplaceBreaksWithSpaces(expression); - sec->Set(base + name, expression, "None"); - } +void ControlGroup::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) +{ + for (auto& control : controls) + control->control_ref->UpdateReference(env); - for (auto& ai : ext->GetAttachmentList()) - ai->SaveConfig(sec, base + ai->GetName() + "/"); - } + for (auto& setting : numeric_settings) + setting->GetInputReference().UpdateReference(env); } void ControlGroup::SetControlExpression(int index, const std::string& expression) |
