diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp index e13ef5beaf..53da135fb5 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.cpp +++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp @@ -10,6 +10,8 @@ #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" #include "InputCommon/KeyboardStatus.h" static const u16 keys0_bitmasks[] = {KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN, @@ -80,11 +82,9 @@ GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index) // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Background Input"))); - m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL)); + std::make_unique(_trans("Background Input"))); + m_options->boolean_settings.emplace_back(std::make_unique( + _trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL)); } std::string GCKeyboard::GetName() const diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index 820932a2e3..53a27cdba8 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -13,6 +13,8 @@ #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h" +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" #include "InputCommon/GCPadStatus.h" static const u16 button_bitmasks[] = { @@ -78,11 +80,9 @@ GCPad::GCPad(const unsigned int index) : m_index(index) // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Background Input"))); - m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL)); + std::make_unique(_trans("Background Input"))); + m_options->boolean_settings.emplace_back(std::make_unique( + _trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL)); } std::string GCPad::GetName() const diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index bb0b6427a9..9551e5b113 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -10,6 +10,7 @@ #include "Core/ConfigManager.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" //#define WIIMOTE_SPEAKER_DUMP #ifdef WIIMOTE_SPEAKER_DUMP diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index fed5ac3e23..b05b1869e3 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -36,6 +36,9 @@ #include "InputCommon/ControllerEmu/ControlGroup/Force.h" #include "InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.h" #include "InputCommon/ControllerEmu/ControlGroup/Tilt.h" +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace { @@ -280,7 +283,7 @@ Wiimote::Wiimote(const unsigned int index) m_extension->attachments.emplace_back(new WiimoteEmu::Turntable(m_reg_ext)); m_extension->boolean_settings.emplace_back( - std::make_unique(_trans("Motion Plus"), false)); + std::make_unique(_trans("Motion Plus"), false)); // rumble groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); @@ -294,23 +297,17 @@ Wiimote::Wiimote(const unsigned int index) // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Background Input"))); - m_options->boolean_settings.emplace_back( - std::make_unique( - "Sideways Wiimote", _trans("Sideways Wii Remote"), false)); - m_options->boolean_settings.emplace_back( - std::make_unique( - "Upright Wiimote", _trans("Upright Wii Remote"), false)); - m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL)); + std::make_unique(_trans("Background Input"))); + m_options->boolean_settings.emplace_back(std::make_unique( + "Sideways Wiimote", _trans("Sideways Wii Remote"), false)); + m_options->boolean_settings.emplace_back(std::make_unique( + "Upright Wiimote", _trans("Upright Wii Remote"), false)); + m_options->boolean_settings.emplace_back(std::make_unique( + _trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL)); m_options->numeric_settings.emplace_back( - std::make_unique(_trans("Speaker Pan"), 0, -127, - 127)); + std::make_unique(_trans("Speaker Pan"), 0, -127, 127)); m_options->numeric_settings.emplace_back( - std::make_unique(_trans("Battery"), 95.0 / 100, - 0, 255)); + std::make_unique(_trans("Battery"), 95.0 / 100, 0, 255)); // hotkeys groups.emplace_back(m_hotkeys = new ControllerEmu::ModifySettingsButton(_trans("Hotkeys"))); diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index cf95c3fdc6..41d914bb06 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -14,6 +14,8 @@ #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/ControlGroup/Buttons.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" #include "InputCommon/GCPadStatus.h" const std::string hotkey_labels[] = { @@ -273,11 +275,9 @@ HotkeyManager::HotkeyManager() groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Background Input"))); - m_options->boolean_settings.emplace_back( - std::make_unique( - _trans("Iterative Input"), false, ControllerEmu::ControlGroup::SettingType::VIRTUAL)); + std::make_unique(_trans("Background Input"))); + m_options->boolean_settings.emplace_back(std::make_unique( + _trans("Iterative Input"), false, ControllerEmu::SettingType::VIRTUAL)); } HotkeyManager::~HotkeyManager() diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index 2dbce7d21c..6e3ca5bb1b 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -63,6 +63,8 @@ #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/Extension.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" #include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/InputConfig.h" @@ -144,7 +146,7 @@ void PadSettingExtension::UpdateValue() } PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, - ControllerEmu::ControlGroup::BooleanSetting* const _setting) + ControllerEmu::BooleanSetting* const _setting) : PadSetting( new wxCheckBox(parent, wxID_ANY, wxGetTranslation(StrToWxStr(_setting->m_ui_name)))), setting(_setting) @@ -167,7 +169,7 @@ void PadSettingCheckBox::UpdateValue() } PadSettingSpin::PadSettingSpin(wxWindow* const parent, - ControllerEmu::ControlGroup::NumericSetting* const settings) + ControllerEmu::NumericSetting* const settings) : PadSetting(new wxSpinCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, settings->m_low, settings->m_high, (int)(settings->m_value * 100))), diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.h b/Source/Core/DolphinWX/Input/InputConfigDiag.h index 068b5c48cb..260cea24c7 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.h +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.h @@ -67,23 +67,21 @@ public: class PadSettingSpin : public PadSetting { public: - PadSettingSpin(wxWindow* const parent, - ControllerEmu::ControlGroup::NumericSetting* const setting); + PadSettingSpin(wxWindow* const parent, ControllerEmu::NumericSetting* const setting); void UpdateGUI() override; void UpdateValue() override; - ControllerEmu::ControlGroup::NumericSetting* const setting; + ControllerEmu::NumericSetting* const setting; }; class PadSettingCheckBox : public PadSetting { public: - PadSettingCheckBox(wxWindow* const parent, - ControllerEmu::ControlGroup::BooleanSetting* const setting); + PadSettingCheckBox(wxWindow* const parent, ControllerEmu::BooleanSetting* const setting); void UpdateGUI() override; void UpdateValue() override; - ControllerEmu::ControlGroup::BooleanSetting* const setting; + ControllerEmu::BooleanSetting* const setting; }; class InputEventFilter : public wxEventFilter diff --git a/Source/Core/DolphinWX/Input/WiimoteInputConfigDiag.cpp b/Source/Core/DolphinWX/Input/WiimoteInputConfigDiag.cpp index 86f5ecc72a..fc7fe5364b 100644 --- a/Source/Core/DolphinWX/Input/WiimoteInputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/WiimoteInputConfigDiag.cpp @@ -10,6 +10,10 @@ #include "Core/HW/Wiimote.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" +#include "InputCommon/ControllerEmu/Setting/BackgroundInputSetting.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" + WiimoteInputConfigDialog::WiimoteInputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name, const int port_num) : InputConfigDialog(parent, config, name, port_num) diff --git a/Source/Core/InputCommon/CMakeLists.txt b/Source/Core/InputCommon/CMakeLists.txt index 697845c494..f8ee22f565 100644 --- a/Source/Core/InputCommon/CMakeLists.txt +++ b/Source/Core/InputCommon/CMakeLists.txt @@ -14,6 +14,9 @@ set(SRCS InputConfig.cpp ControllerEmu/ControlGroup/Slider.cpp ControllerEmu/ControlGroup/Tilt.cpp ControllerEmu/ControlGroup/Triggers.cpp + ControllerEmu/Setting/BackgroundInputSetting.cpp + ControllerEmu/Setting/BooleanSetting.cpp + ControllerEmu/Setting/NumericSetting.cpp ControllerInterface/ControllerInterface.cpp ControllerInterface/Device.cpp ControlReference/ControlReference.cpp diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp index f8e2fabd59..2b7430dcbf 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp @@ -14,6 +14,7 @@ #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp index 5a86839380..e51d4f3711 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.cpp @@ -8,6 +8,7 @@ #include #include "Common/Common.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h index 9b1acd866c..14621f859a 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h @@ -9,6 +9,7 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp index 0b8b7f19d9..fd905ccf1e 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp @@ -11,6 +11,8 @@ #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/ControlGroup/Extension.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { @@ -27,8 +29,6 @@ ControlGroup::ControlGroup(const std::string& name_, const std::string& ui_name_ ControlGroup::~ControlGroup() = default; -ControlGroup::BooleanSetting::~BooleanSetting() = default; - void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev, const std::string& base) { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h index 212205f333..a03878bdaa 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h @@ -10,12 +10,13 @@ #include "Common/CommonTypes.h" #include "Common/IniFile.h" -#include "Core/ConfigManager.h" #include "InputCommon/ControllerInterface/Device.h" namespace ControllerEmu { +class BooleanSetting; class Control; +class NumericSetting; enum class GroupType { @@ -34,74 +35,6 @@ enum class GroupType class ControlGroup { public: - enum class SettingType - { - NORMAL, // normal settings are saved to configuration files - VIRTUAL, // virtual settings are not saved at all - }; - - 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) - : m_type(setting_type), m_name(setting_name), m_default_value(default_value), m_low(low), - m_high(high) - { - } - - ControlState GetValue() const { return m_value; } - void SetValue(ControlState value) { m_value = 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; - }; - - class BooleanSetting - { - public: - BooleanSetting(const std::string& setting_name, const std::string& ui_name, - const bool default_value, const SettingType setting_type = SettingType::NORMAL) - : m_type(setting_type), m_name(setting_name), m_ui_name(ui_name), - m_default_value(default_value) - { - } - BooleanSetting(const std::string& setting_name, const bool default_value, - const SettingType setting_type = SettingType::NORMAL) - : BooleanSetting(setting_name, setting_name, default_value, setting_type) - { - } - virtual ~BooleanSetting(); - - virtual bool GetValue() const { return m_value; } - virtual void SetValue(bool value) { m_value = value; } - const SettingType m_type; - const std::string m_name; - const std::string m_ui_name; - const bool m_default_value; - bool m_value; - }; - - class BackgroundInputSetting : public BooleanSetting - { - public: - BackgroundInputSetting(const std::string& setting_name) - : BooleanSetting(setting_name, false, SettingType::VIRTUAL) - { - } - - bool GetValue() const override { return SConfig::GetInstance().m_BackgroundInput; } - void SetValue(bool value) override - { - m_value = value; - SConfig::GetInstance().m_BackgroundInput = value; - } - }; - explicit ControlGroup(const std::string& name, GroupType type = GroupType::Other); ControlGroup(const std::string& name, const std::string& ui_name, GroupType type = GroupType::Other); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index bede6f1899..3b79a8fe61 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -16,6 +16,8 @@ #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index 43199810cb..a825ce51c9 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -13,6 +13,7 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.cpp index 4a35f8047a..8f26fde6fc 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/MixedTriggers.cpp @@ -13,6 +13,7 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Control.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp index b71b1ea2c1..d9c4a315e3 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp @@ -13,6 +13,8 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Input.h" +#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" #include "VideoCommon/OnScreenDisplay.h" namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp index c662ffc4ae..583038e142 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp @@ -13,6 +13,7 @@ #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Input.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index 1c124c2547..6154bfea68 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -13,6 +13,7 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Control.h" #include "InputCommon/ControllerEmu/Control/Input.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.cpp index 4680d4715b..daf7ef98d7 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Triggers.cpp @@ -12,6 +12,7 @@ #include "Common/Common.h" #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerEmu/Control/Control.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" namespace ControllerEmu { 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 + +#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 + +#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 diff --git a/Source/Core/InputCommon/InputCommon.vcxproj b/Source/Core/InputCommon/InputCommon.vcxproj index 954110646b..0552bfe052 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj +++ b/Source/Core/InputCommon/InputCommon.vcxproj @@ -50,6 +50,9 @@ + + + @@ -85,6 +88,10 @@ + + + + diff --git a/Source/Core/InputCommon/InputCommon.vcxproj.filters b/Source/Core/InputCommon/InputCommon.vcxproj.filters index 4302e1233d..07d4a161a8 100644 --- a/Source/Core/InputCommon/InputCommon.vcxproj.filters +++ b/Source/Core/InputCommon/InputCommon.vcxproj.filters @@ -22,6 +22,9 @@ {e805231c-dc4e-4540-8bf8-8c567f3d00ae} + + {ce661cb4-f23f-4ab2-952d-402d381735e5} + @@ -71,6 +74,15 @@ ControllerEmu\ControlGroup + + ControllerEmu\Setting + + + ControllerEmu\Setting + + + ControllerEmu\Setting + ControllerInterface\DInput @@ -151,6 +163,18 @@ ControllerEmu\ControlGroup + + ControllerEmu\Setting + + + ControllerEmu\Setting + + + ControllerEmu\Setting + + + ControllerEmu\Setting + ControllerInterface\DInput @@ -188,4 +212,4 @@ - \ No newline at end of file +