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/Attachments.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/Attachments.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.cpp | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.cpp index b4bb1699c0..45ce337d6c 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.cpp @@ -5,11 +5,16 @@ namespace ControllerEmu { + +void AttachedController::LoadDefaults() +{ +} + Attachments::Attachments(const std::string& name_) : ControlGroup(name_, GroupType::Attachments) { } -void Attachments::AddAttachment(std::unique_ptr<EmulatedController> att) +void Attachments::AddAttachment(std::unique_ptr<AttachedController> att) { m_attachments.emplace_back(std::move(att)); } @@ -40,9 +45,61 @@ SubscribableSettingValue<int>& Attachments::GetAttachmentSetting() return m_selection_value; } -const std::vector<std::unique_ptr<EmulatedController>>& Attachments::GetAttachmentList() const +const std::vector<std::unique_ptr<AttachedController>>& Attachments::GetAttachmentList() const { return m_attachments; } +void Attachments::LoadConfig(Common::IniFile::Section* sec, const std::string& base) +{ + ControlGroup::LoadConfig(sec, base); + + SetSelectedAttachment(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. + GetSelectionSetting().GetInputReference().SetExpression(attachment_text); + + u32 n = 0; + for (auto& ai : GetAttachmentList()) + { + ai->LoadGroupsConfig(sec, base + ai->GetName() + "/"); + + if (ai->GetName() == attachment_text) + SetSelectedAttachment(n); + + ++n; + } +} + +void Attachments::SaveConfig(Common::IniFile::Section* sec, const std::string& base) +{ + if (GetSelectionSetting().IsSimpleValue()) + { + sec->Set(base + name, GetAttachmentList()[GetSelectedAttachment()]->GetName(), "None"); + } + else + { + std::string expression = GetSelectionSetting().GetInputReference().GetExpression(); + ReplaceBreaksWithSpaces(expression); + sec->Set(base + name, expression, "None"); + } + + for (auto& ai : GetAttachmentList()) + ai->SaveGroupsConfig(sec, base + ai->GetName() + "/"); +} + +void Attachments::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) +{ + ControlGroup::UpdateReferences(env); + + GetSelectionSetting().GetInputReference().UpdateReference(env); + + for (auto& attachment : GetAttachmentList()) + attachment->UpdateGroupsReferences(env); +} + } // namespace ControllerEmu |
