InputCommon/ControllerEmu: Break out functionality of EmulatedController

to eliminate redundant unused members in Wii Remote extension objects.
This commit is contained in:
Jordan Woyak
2025-01-20 23:19:56 -06:00
parent 225039f742
commit ddb82a5e8c
26 changed files with 312 additions and 245 deletions

View File

@ -3,19 +3,23 @@
#pragma once
#include <atomic>
#include <memory>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/HW/WiimoteEmu/ExtensionPort.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
namespace ControllerEmu
{
class AttachedController : public ControlGroupContainer
{
public:
virtual void LoadDefaults();
};
// A container of the selected and available attachments
// for configuration saving/loading purposes
class Attachments : public ControlGroup
@ -23,7 +27,7 @@ class Attachments : public ControlGroup
public:
explicit Attachments(const std::string& name);
void AddAttachment(std::unique_ptr<EmulatedController> att);
void AddAttachment(std::unique_ptr<AttachedController> att);
u32 GetSelectedAttachment() const;
void SetSelectedAttachment(u32 val);
@ -31,16 +35,20 @@ public:
NumericSetting<int>& GetSelectionSetting();
SubscribableSettingValue<int>& GetAttachmentSetting();
const std::vector<std::unique_ptr<EmulatedController>>& GetAttachmentList() const;
const std::vector<std::unique_ptr<AttachedController>>& GetAttachmentList() const;
void LoadConfig(Common::IniFile::Section* sec, const std::string& base) override;
void SaveConfig(Common::IniFile::Section* sec, const std::string& base) override;
void UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) override;
private:
SubscribableSettingValue<int> m_selection_value;
// This is here and not added to the list of numeric_settings because it's serialized differently,
// by string (to be independent from the enum), and visualized differently in the UI.
// For the rest, it's treated similarly to other numeric_settings in the group.
NumericSetting<int> m_selection_setting = {
&m_selection_value, {""}, 0, 0, WiimoteEmu::ExtensionNumber::MAX - 1};
NumericSetting<int> m_selection_setting = {&m_selection_value, {""}, 0, 0, 0};
std::vector<std::unique_ptr<EmulatedController>> m_attachments;
std::vector<std::unique_ptr<AttachedController>> m_attachments;
};
} // namespace ControllerEmu