Debian Codegraph @

Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h

raw symbols SCIP
1 // Copyright 2017 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <memory>
7 #include <string>
8 #include <vector>
9
10 #include "Common/CommonTypes.h"
11 #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
12 #include "InputCommon/ControllerEmu/ControllerEmu.h"
13 #include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
14
15 namespace ControllerEmu
16 {
17 class AttachedController : public ControlGroupContainer
18 {
19 public:
20 virtual void LoadDefaults();
21 };
22
23 // A container of the selected and available attachments
24 // for configuration saving/loading purposes
25 class Attachments : public ControlGroup
26 {
27 public:
28 explicit Attachments(const std::string& name);
29
30 void AddAttachment(std::unique_ptr<AttachedController> att);
31
32 u32 GetSelectedAttachment() const;
33 void SetSelectedAttachment(u32 val);
34
35 NumericSetting<int>& GetSelectionSetting();
36 SubscribableSettingValue<int>& GetAttachmentSetting();
37
38 const std::vector<std::unique_ptr<AttachedController>>& GetAttachmentList() const;
39
40 void LoadConfig(Common::IniFile::Section* sec, const std::string& base) override;
41 void SaveConfig(Common::IniFile::Section* sec, const std::string& base) override;
42
43 void UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) override;
44
45 private:
46 SubscribableSettingValue<int> m_selection_value;
47 // This is here and not added to the list of numeric_settings because it's serialized differently,
48 // by string (to be independent from the enum), and visualized differently in the UI.
49 // For the rest, it's treated similarly to other numeric_settings in the group.
50 NumericSetting<int> m_selection_setting = {&m_selection_value, {""}, 0, 0, 0};
51
52 std::vector<std::unique_ptr<AttachedController>> m_attachments;
53 };
54 } // namespace ControllerEmu