ControlGroup: Convert group type enum into an enum class

Gets some constants out of the ControllerEmu namespace, and modifies
ControlGroup so that it uses the enum type itself to represent the
underlying type, rather than a u32 value.
This commit is contained in:
Lioncash
2017-02-25 00:35:02 -05:00
parent 51136681df
commit 26f17a1723
14 changed files with 61 additions and 59 deletions

View File

@ -24,7 +24,7 @@ AnalogStick::AnalogStick(const char* const name_, ControlState default_radius)
AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
ControlState default_radius)
: ControlGroup(name_, ui_name_, GROUP_TYPE_STICK)
: ControlGroup(name_, ui_name_, GroupType::Stick)
{
for (auto& named_direction : named_directions)
controls.emplace_back(std::make_unique<Input>(named_direction));

View File

@ -16,7 +16,7 @@ Buttons::Buttons(const std::string& name_) : Buttons(name_, name_)
}
Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
: ControlGroup(ini_name, group_name, GROUP_TYPE_BUTTONS)
: ControlGroup(ini_name, group_name, GroupType::Buttons)
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
}

View File

@ -14,12 +14,13 @@
namespace ControllerEmu
{
ControlGroup::ControlGroup(const std::string& name_, const u32 type_)
ControlGroup::ControlGroup(const std::string& name_, const GroupType type_)
: name(name_), ui_name(name_), type(type_)
{
}
ControlGroup::ControlGroup(const std::string& name_, const std::string& ui_name_, const u32 type_)
ControlGroup::ControlGroup(const std::string& name_, const std::string& ui_name_,
const GroupType type_)
: name(name_), ui_name(ui_name_), type(type_)
{
}
@ -62,7 +63,7 @@ void ControlGroup::LoadConfig(IniFile::Section* sec, const std::string& defdev,
}
// extensions
if (type == GROUP_TYPE_EXTENSION)
if (type == GroupType::Extension)
{
Extension* const ext = (Extension*)this;
@ -115,7 +116,7 @@ void ControlGroup::SaveConfig(IniFile::Section* sec, const std::string& defdev,
}
// extensions
if (type == GROUP_TYPE_EXTENSION)
if (type == GroupType::Extension)
{
Extension* const ext = (Extension*)this;
sec->Set(base + name, ext->attachments[ext->switch_extension]->GetName(), "None");

View File

@ -17,18 +17,18 @@ namespace ControllerEmu
{
class Control;
enum
enum class GroupType
{
GROUP_TYPE_OTHER,
GROUP_TYPE_STICK,
GROUP_TYPE_MIXED_TRIGGERS,
GROUP_TYPE_BUTTONS,
GROUP_TYPE_FORCE,
GROUP_TYPE_EXTENSION,
GROUP_TYPE_TILT,
GROUP_TYPE_CURSOR,
GROUP_TYPE_TRIGGERS,
GROUP_TYPE_SLIDER
Other,
Stick,
MixedTriggers,
Buttons,
Force,
Extension,
Tilt,
Cursor,
Triggers,
Slider
};
class ControlGroup
@ -102,8 +102,9 @@ public:
}
};
explicit ControlGroup(const std::string& name, u32 type = GROUP_TYPE_OTHER);
ControlGroup(const std::string& name, const std::string& ui_name, u32 type = GROUP_TYPE_OTHER);
explicit ControlGroup(const std::string& name, GroupType type = GroupType::Other);
ControlGroup(const std::string& name, const std::string& ui_name,
GroupType type = GroupType::Other);
virtual ~ControlGroup();
virtual void LoadConfig(IniFile::Section* sec, const std::string& defdev = "",
@ -115,7 +116,7 @@ public:
const std::string name;
const std::string ui_name;
const u32 type;
const GroupType type;
std::vector<std::unique_ptr<Control>> controls;
std::vector<std::unique_ptr<NumericSetting>> numeric_settings;

View File

@ -19,7 +19,7 @@
namespace ControllerEmu
{
Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_CURSOR)
Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GroupType::Cursor)
{
for (auto& named_direction : named_directions)
controls.emplace_back(std::make_unique<Input>(named_direction));

View File

@ -10,7 +10,7 @@
namespace ControllerEmu
{
Extension::Extension(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_EXTENSION)
Extension::Extension(const std::string& name_) : ControlGroup(name_, GroupType::Extension)
{
}
} // namespace ControllerEmu

View File

@ -16,7 +16,7 @@
namespace ControllerEmu
{
Force::Force(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_FORCE)
Force::Force(const std::string& name_) : ControlGroup(name_, GroupType::Force)
{
controls.emplace_back(std::make_unique<Input>(_trans("Up")));
controls.emplace_back(std::make_unique<Input>(_trans("Down")));

View File

@ -17,7 +17,7 @@
namespace ControllerEmu
{
MixedTriggers::MixedTriggers(const std::string& name_)
: ControlGroup(name_, GROUP_TYPE_MIXED_TRIGGERS)
: ControlGroup(name_, GroupType::MixedTriggers)
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.9));
}

View File

@ -16,7 +16,7 @@
namespace ControllerEmu
{
Slider::Slider(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_SLIDER)
Slider::Slider(const std::string& name_) : ControlGroup(name_, GroupType::Slider)
{
controls.emplace_back(std::make_unique<Input>("Left"));
controls.emplace_back(std::make_unique<Input>("Right"));

View File

@ -16,7 +16,7 @@
namespace ControllerEmu
{
Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TILT)
Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GroupType::Tilt)
{
controls.emplace_back(std::make_unique<Input>("Forward"));
controls.emplace_back(std::make_unique<Input>("Backward"));

View File

@ -15,7 +15,7 @@
namespace ControllerEmu
{
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TRIGGERS)
Triggers::Triggers(const std::string& name_) : ControlGroup(name_, GroupType::Triggers)
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
}