diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp index b8132882e1..6e0fcbd5ef 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/InputConfigDiag.cpp @@ -104,32 +104,32 @@ void PadSettingExtension::UpdateValue() extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection(); } -PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label) - : PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(label)))) - , value(_value) +PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const _setting) + : PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(_setting->name)))) + , setting(_setting) { UpdateGUI(); } void PadSettingCheckBox::UpdateGUI() { - ((wxCheckBox*)wxcontrol)->SetValue(value > 0); + ((wxCheckBox*)wxcontrol)->SetValue(setting->GetValue()); } void PadSettingCheckBox::UpdateValue() { // 0.01 so its saved to the ini file as just 1. :( - value = 0.01 * ((wxCheckBox*)wxcontrol)->GetValue(); + setting->SetValue(0.01 * ((wxCheckBox*)wxcontrol)->GetValue()); } void PadSettingSpin::UpdateGUI() { - ((wxSpinCtrl*)wxcontrol)->SetValue((int)(value * 100)); + ((wxSpinCtrl*)wxcontrol)->SetValue((int)(setting->GetValue() * 100)); } void PadSettingSpin::UpdateValue() { - value = float(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100; + setting->SetValue(float(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100); } ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref) @@ -879,7 +879,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin //options for (auto& groupSetting : group->settings) { - PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting->value, groupSetting->name); + PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get()); setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink); options.push_back(setting_cbox); diff --git a/Source/Core/DolphinWX/InputConfigDiag.h b/Source/Core/DolphinWX/InputConfigDiag.h index 8c0ade99bb..12223bed9c 100644 --- a/Source/Core/DolphinWX/InputConfigDiag.h +++ b/Source/Core/DolphinWX/InputConfigDiag.h @@ -69,25 +69,25 @@ public: class PadSettingSpin : public PadSetting { public: - PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting) - : PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition - , wxSize(54, -1), 0, setting->low, setting->high, (int)(setting->value * 100))) - , value(setting->value) {} + PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const _setting) + : PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition, + wxSize(54, -1), 0, _setting->low, _setting->high, (int)(_setting->value * 100))) + , setting(_setting) {} void UpdateGUI() override; void UpdateValue() override; - ControlState& value; + ControllerEmu::ControlGroup::Setting* const setting; }; class PadSettingCheckBox : public PadSetting { public: - PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label); + PadSettingCheckBox(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting); void UpdateGUI() override; void UpdateValue() override; - ControlState& value; + ControllerEmu::ControlGroup::Setting* const setting; }; class GamepadPage; diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index e01ab90fb9..6e2bf8aa73 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -43,6 +43,8 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s // settings for (auto& s : settings) { + if (s->is_virtual) + continue; sec->Get(group + s->name, &s->value, s->default_value * 100); s->value /= 100; } @@ -99,7 +101,11 @@ void ControllerEmu::ControlGroup::SaveConfig(IniFile::Section *sec, const std::s std::string group(base + name); group += "/"; for (auto& s : settings) + { + if (s->is_virtual) + continue; sec->Set(group + s->name, s->value*100.0f, s->default_value*100.0f); + } for (auto& c : controls) { diff --git a/Source/Core/InputCommon/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu.h index 9f8bc50985..46f5477ff2 100644 --- a/Source/Core/InputCommon/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu.h @@ -94,12 +94,24 @@ public: , value(def_value) , default_value(def_value) , low(_low) - , high(_high){} + , high(_high) + , is_virtual(false) {} const std::string name; ControlState value; const ControlState default_value; const unsigned int low, high; + bool is_virtual; + + virtual void SetValue(ControlState new_value) + { + value = new_value; + } + + virtual ControlState GetValue() + { + return value; + } }; ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}