diff options
| author | Michael Maltese <michaeljosephmaltese@gmail.com> | 2017-02-26 12:00:24 -0800 |
|---|---|---|
| committer | Michael Maltese <michaeljosephmaltese@gmail.com> | 2017-03-02 18:08:37 -0800 |
| commit | 1539ff669119ad796201c72052113e84862e1e98 (patch) | |
| tree | cec863647b0f6b60794e20a2be995d9dac086222 /Source/Core/InputCommon/ControllerEmu/Setting | |
| parent | 4e062d1bf6e1754325b5d55e6df65ee3d4769a9c (diff) | |
InputCommon: move Setting classes out of ControlGroup
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/Setting')
7 files changed, 182 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.cpp b/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.cpp new file mode 100644 index 0000000000..0e7b3d785e --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.cpp @@ -0,0 +1,26 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "Core/ConfigManager.h" +#include "InputCommon/ControllerEmu/Setting/Setting.h" + +namespace ControllerEmu +{ +BackgroundInputSetting::BackgroundInputSetting(const std::string& setting_name) + : BooleanSetting(setting_name, false, SettingType::VIRTUAL) +{ +} + +bool BackgroundInputSetting::GetValue() const +{ + return SConfig::GetInstance().m_BackgroundInput; +} +void BackgroundInputSetting::SetValue(bool value) +{ + m_value = value; + SConfig::GetInstance().m_BackgroundInput = value; +} + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h new file mode 100644 index 0000000000..fc1f8c1de3 --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h @@ -0,0 +1,20 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" + +namespace ControllerEmu +{ +class BackgroundInputSetting : public BooleanSetting +{ +public: + BackgroundInputSetting(const std::string& setting_name); + + bool GetValue() const override; + void SetValue(bool value) override; +}; + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.cpp b/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.cpp new file mode 100644 index 0000000000..2679ed46b1 --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.cpp @@ -0,0 +1,32 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" + +namespace ControllerEmu +{ +BooleanSetting::BooleanSetting(const std::string& setting_name, const std::string& ui_name, + const bool default_value, const SettingType setting_type) + : m_type(setting_type), m_name(setting_name), m_ui_name(ui_name), m_default_value(default_value) +{ +} + +BooleanSetting::BooleanSetting(const std::string& setting_name, const bool default_value, + const SettingType setting_type) + : BooleanSetting(setting_name, setting_name, default_value, setting_type) +{ +} + +BooleanSetting::~BooleanSetting() = default; + +bool BooleanSetting::GetValue() const +{ + return m_value; +} +void BooleanSetting::SetValue(bool value) +{ + m_value = value; +} + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.h new file mode 100644 index 0000000000..754d697d2b --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.h @@ -0,0 +1,32 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include <string> + +#include "InputCommon/ControllerEmu/Setting/Setting.h" +#include "InputCommon/ControllerInterface/Device.h" + +namespace ControllerEmu +{ +class BooleanSetting +{ +public: + BooleanSetting(const std::string& setting_name, const std::string& ui_name, + const bool default_value, const SettingType setting_type = SettingType::NORMAL); + BooleanSetting(const std::string& setting_name, const bool default_value, + const SettingType setting_type = SettingType::NORMAL); + virtual ~BooleanSetting(); + + virtual bool GetValue() const; + virtual void SetValue(bool value); + const SettingType m_type; + const std::string m_name; + const std::string m_ui_name; + const bool m_default_value; + bool m_value; +}; + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.cpp b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.cpp new file mode 100644 index 0000000000..17a0fd11b1 --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.cpp @@ -0,0 +1,25 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" + +namespace ControllerEmu +{ +NumericSetting::NumericSetting(const std::string& setting_name, const ControlState default_value, + const u32 low, const u32 high, const SettingType setting_type) + : m_type(setting_type), m_name(setting_name), m_default_value(default_value), m_low(low), + m_high(high) +{ +} + +ControlState NumericSetting::GetValue() const +{ + return m_value; +} +void NumericSetting::SetValue(ControlState value) +{ + m_value = value; +} + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h new file mode 100644 index 0000000000..2e84d383ba --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h @@ -0,0 +1,32 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include <string> + +#include "Common/CommonTypes.h" +#include "InputCommon/ControllerEmu/Setting/Setting.h" +#include "InputCommon/ControllerInterface/Device.h" + +namespace ControllerEmu +{ +class NumericSetting +{ +public: + NumericSetting(const std::string& setting_name, const ControlState default_value, + const u32 low = 0, const u32 high = 100, + const SettingType setting_type = SettingType::NORMAL); + + ControlState GetValue() const; + void SetValue(ControlState value); + const SettingType m_type; + const std::string m_name; + const ControlState m_default_value; + const u32 m_low; + const u32 m_high; + ControlState m_value; +}; + +} // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/Setting.h b/Source/Core/InputCommon/ControllerEmu/Setting/Setting.h new file mode 100644 index 0000000000..955e3d8c8b --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/Setting/Setting.h @@ -0,0 +1,15 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +namespace ControllerEmu +{ +enum class SettingType +{ + NORMAL, // normal settings are saved to configuration files + VIRTUAL, // virtual settings are not saved at all +}; + +} // namespace ControllerEmu |
