summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/Attachments.h
blob: 1573b01bca1b5803563bd088c26610924ab20dbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <memory>
#include <string>
#include <vector>

#include "Common/CommonTypes.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
{
public:
  explicit Attachments(const std::string& name);

  void AddAttachment(std::unique_ptr<AttachedController> att);

  u32 GetSelectedAttachment() const;
  void SetSelectedAttachment(u32 val);

  NumericSetting<int>& GetSelectionSetting();
  SubscribableSettingValue<int>& GetAttachmentSetting();

  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, 0};

  std::vector<std::unique_ptr<AttachedController>> m_attachments;
};
}  // namespace ControllerEmu