mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 06:35:39 +00:00
ControllerEmu: Virtualize settings
This will allow us to move Background Input to a global setting rather than a local setting.
This commit is contained in:
parent
a6dc3c47a9
commit
0d49bf65a7
@ -104,32 +104,32 @@ void PadSettingExtension::UpdateValue()
|
|||||||
extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection();
|
extension->switch_extension = ((wxChoice*)wxcontrol)->GetSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label)
|
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const _setting)
|
||||||
: PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(label))))
|
: PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(_setting->name))))
|
||||||
, value(_value)
|
, setting(_setting)
|
||||||
{
|
{
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PadSettingCheckBox::UpdateGUI()
|
void PadSettingCheckBox::UpdateGUI()
|
||||||
{
|
{
|
||||||
((wxCheckBox*)wxcontrol)->SetValue(value > 0);
|
((wxCheckBox*)wxcontrol)->SetValue(setting->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PadSettingCheckBox::UpdateValue()
|
void PadSettingCheckBox::UpdateValue()
|
||||||
{
|
{
|
||||||
// 0.01 so its saved to the ini file as just 1. :(
|
// 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()
|
void PadSettingSpin::UpdateGUI()
|
||||||
{
|
{
|
||||||
((wxSpinCtrl*)wxcontrol)->SetValue((int)(value * 100));
|
((wxSpinCtrl*)wxcontrol)->SetValue((int)(setting->GetValue() * 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PadSettingSpin::UpdateValue()
|
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)
|
ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, ControllerInterface::ControlReference* const ref)
|
||||||
@ -879,7 +879,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
|||||||
//options
|
//options
|
||||||
for (auto& groupSetting : group->settings)
|
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);
|
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink);
|
||||||
options.push_back(setting_cbox);
|
options.push_back(setting_cbox);
|
||||||
|
|
||||||
|
@ -69,25 +69,25 @@ public:
|
|||||||
class PadSettingSpin : public PadSetting
|
class PadSettingSpin : public PadSetting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting)
|
PadSettingSpin(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const _setting)
|
||||||
: PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition
|
: PadSetting(new wxSpinCtrl(parent, -1, wxEmptyString, wxDefaultPosition,
|
||||||
, wxSize(54, -1), 0, setting->low, setting->high, (int)(setting->value * 100)))
|
wxSize(54, -1), 0, _setting->low, _setting->high, (int)(_setting->value * 100)))
|
||||||
, value(setting->value) {}
|
, setting(_setting) {}
|
||||||
|
|
||||||
void UpdateGUI() override;
|
void UpdateGUI() override;
|
||||||
void UpdateValue() override;
|
void UpdateValue() override;
|
||||||
|
|
||||||
ControlState& value;
|
ControllerEmu::ControlGroup::Setting* const setting;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PadSettingCheckBox : public PadSetting
|
class PadSettingCheckBox : public PadSetting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const std::string& label);
|
PadSettingCheckBox(wxWindow* const parent, ControllerEmu::ControlGroup::Setting* const setting);
|
||||||
void UpdateGUI() override;
|
void UpdateGUI() override;
|
||||||
void UpdateValue() override;
|
void UpdateValue() override;
|
||||||
|
|
||||||
ControlState& value;
|
ControllerEmu::ControlGroup::Setting* const setting;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GamepadPage;
|
class GamepadPage;
|
||||||
|
@ -43,6 +43,8 @@ void ControllerEmu::ControlGroup::LoadConfig(IniFile::Section *sec, const std::s
|
|||||||
// settings
|
// settings
|
||||||
for (auto& s : settings)
|
for (auto& s : settings)
|
||||||
{
|
{
|
||||||
|
if (s->is_virtual)
|
||||||
|
continue;
|
||||||
sec->Get(group + s->name, &s->value, s->default_value * 100);
|
sec->Get(group + s->name, &s->value, s->default_value * 100);
|
||||||
s->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 += "/";
|
std::string group(base + name); group += "/";
|
||||||
|
|
||||||
for (auto& s : settings)
|
for (auto& s : settings)
|
||||||
|
{
|
||||||
|
if (s->is_virtual)
|
||||||
|
continue;
|
||||||
sec->Set(group + s->name, s->value*100.0f, s->default_value*100.0f);
|
sec->Set(group + s->name, s->value*100.0f, s->default_value*100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& c : controls)
|
for (auto& c : controls)
|
||||||
{
|
{
|
||||||
|
@ -94,12 +94,24 @@ public:
|
|||||||
, value(def_value)
|
, value(def_value)
|
||||||
, default_value(def_value)
|
, default_value(def_value)
|
||||||
, low(_low)
|
, low(_low)
|
||||||
, high(_high){}
|
, high(_high)
|
||||||
|
, is_virtual(false) {}
|
||||||
|
|
||||||
const std::string name;
|
const std::string name;
|
||||||
ControlState value;
|
ControlState value;
|
||||||
const ControlState default_value;
|
const ControlState default_value;
|
||||||
const unsigned int low, high;
|
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) {}
|
ControlGroup(const std::string& _name, const unsigned int _type = GROUP_TYPE_OTHER) : name(_name), type(_type) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user