Merge pull request #8440 from rlnilsen/motion-input-tweaks

Motion Input enhancements
This commit is contained in:
JosJuice
2019-11-15 14:08:45 +01:00
committed by GitHub
6 changed files with 64 additions and 9 deletions

View File

@ -15,13 +15,16 @@
namespace ControllerEmu
{
ControlGroup::ControlGroup(std::string name_, const GroupType type_)
: name(name_), ui_name(std::move(name_)), type(type_)
ControlGroup::ControlGroup(std::string name_, const GroupType type_, CanBeDisabled can_be_disabled_)
: name(name_), ui_name(std::move(name_)), type(type_),
can_be_disabled(can_be_disabled_ == CanBeDisabled::Yes)
{
}
ControlGroup::ControlGroup(std::string name_, std::string ui_name_, const GroupType type_)
: name(std::move(name_)), ui_name(std::move(ui_name_)), type(type_)
ControlGroup::ControlGroup(std::string name_, std::string ui_name_, const GroupType type_,
CanBeDisabled can_be_disabled_)
: name(std::move(name_)), ui_name(std::move(ui_name_)), type(type_),
can_be_disabled(can_be_disabled_ == CanBeDisabled::Yes)
{
}
@ -43,6 +46,10 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
{
const std::string group(base + name + "/");
// enabled
if (can_be_disabled)
sec->Get(group + "Enabled", &enabled, true);
for (auto& setting : numeric_settings)
setting->LoadFromIni(*sec, group);
@ -88,6 +95,9 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
{
const std::string group(base + name + "/");
// enabled
sec->Set(group + "Enabled", enabled, true);
for (auto& setting : numeric_settings)
setting->SaveToIni(*sec, group);

View File

@ -48,8 +48,16 @@ enum class GroupType
class ControlGroup
{
public:
explicit ControlGroup(std::string name, GroupType type = GroupType::Other);
ControlGroup(std::string name, std::string ui_name, GroupType type = GroupType::Other);
enum class CanBeDisabled
{
No,
Yes,
};
explicit ControlGroup(std::string name, GroupType type = GroupType::Other,
CanBeDisabled can_be_disabled = CanBeDisabled::No);
ControlGroup(std::string name, std::string ui_name, GroupType type = GroupType::Other,
CanBeDisabled can_be_disabled = CanBeDisabled::No);
virtual ~ControlGroup();
virtual void LoadConfig(IniFile::Section* sec, const std::string& defdev = "",
@ -79,7 +87,9 @@ public:
const std::string name;
const std::string ui_name;
const GroupType type;
const bool can_be_disabled;
bool enabled = true;
std::vector<std::unique_ptr<Control>> controls;
std::vector<std::unique_ptr<NumericSettingBase>> numeric_settings;
};

View File

@ -18,7 +18,8 @@
namespace ControllerEmu
{
IMUCursor::IMUCursor(std::string name, std::string ui_name)
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUCursor)
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUCursor,
ControlGroup::CanBeDisabled::Yes)
{
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Recenter")));