mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
InputCommon: Clean up creation of inputs.
This commit is contained in:
@ -10,14 +10,15 @@
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Control::Control(std::unique_ptr<ControlReference> ref, Translatability translate_,
|
||||
const std::string& name_, const std::string& ui_name_)
|
||||
: control_ref(std::move(ref)), translate(translate_), name(name_), ui_name(ui_name_)
|
||||
std::string name_, std::string ui_name_)
|
||||
: control_ref(std::move(ref)), translate(translate_), name(std::move(name_)),
|
||||
ui_name(std::move(ui_name_))
|
||||
{
|
||||
}
|
||||
|
||||
Control::Control(std::unique_ptr<ControlReference> ref, Translatability translate_,
|
||||
const std::string& name_)
|
||||
: Control(std::move(ref), translate_, name_, name_)
|
||||
std::string name_)
|
||||
: control_ref(std::move(ref)), translate(translate_), name(name_), ui_name(std::move(name_))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,9 @@ public:
|
||||
const std::string ui_name;
|
||||
|
||||
protected:
|
||||
Control(std::unique_ptr<ControlReference> ref, Translatability translate, const std::string& name,
|
||||
const std::string& ui_name);
|
||||
Control(std::unique_ptr<ControlReference> ref, Translatability translate,
|
||||
const std::string& name);
|
||||
Control(std::unique_ptr<ControlReference> ref, Translatability translate, std::string name,
|
||||
std::string ui_name);
|
||||
Control(std::unique_ptr<ControlReference> ref, Translatability translate, std::string name);
|
||||
};
|
||||
|
||||
} // namespace ControllerEmu
|
||||
|
@ -10,13 +10,13 @@
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Input::Input(Translatability translate_, const std::string& name_, const std::string& ui_name_)
|
||||
: Control(std::make_unique<InputReference>(), translate_, name_, ui_name_)
|
||||
Input::Input(Translatability translate_, std::string name_, std::string ui_name_)
|
||||
: Control(std::make_unique<InputReference>(), translate_, std::move(name_), std::move(ui_name_))
|
||||
{
|
||||
}
|
||||
|
||||
Input::Input(Translatability translate_, const std::string& name_)
|
||||
: Control(std::make_unique<InputReference>(), translate_, name_)
|
||||
Input::Input(Translatability translate_, std::string name_)
|
||||
: Control(std::make_unique<InputReference>(), translate_, std::move(name_))
|
||||
{
|
||||
}
|
||||
} // namespace ControllerEmu
|
||||
|
@ -12,7 +12,7 @@ namespace ControllerEmu
|
||||
class Input : public Control
|
||||
{
|
||||
public:
|
||||
Input(Translatability translate, const std::string& name, const std::string& ui_name);
|
||||
Input(Translatability translate, const std::string& name);
|
||||
Input(Translatability translate, std::string name, std::string ui_name);
|
||||
Input(Translatability translate, std::string name);
|
||||
};
|
||||
} // namespace ControllerEmu
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
Output::Output(Translatability translate_, const std::string& name_)
|
||||
: Control(std::make_unique<OutputReference>(), translate_, name_)
|
||||
Output::Output(Translatability translate_, std::string name_)
|
||||
: Control(std::make_unique<OutputReference>(), translate_, std::move(name_))
|
||||
{
|
||||
}
|
||||
} // namespace ControllerEmu
|
||||
|
@ -12,6 +12,6 @@ namespace ControllerEmu
|
||||
class Output : public Control
|
||||
{
|
||||
public:
|
||||
Output(Translatability translate, const std::string& name);
|
||||
Output(Translatability translate, std::string name);
|
||||
};
|
||||
} // namespace ControllerEmu
|
||||
|
@ -27,9 +27,9 @@ AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
|
||||
: ReshapableInput(name_, ui_name_, GroupType::Stick), m_stick_gate(std::move(stick_gate))
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, named_direction));
|
||||
AddInput(Translate, named_direction);
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Modifier")));
|
||||
AddInput(Translate, _trans("Modifier"));
|
||||
}
|
||||
|
||||
AnalogStick::ReshapeData AnalogStick::GetReshapableState(bool adjusted)
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
#include "InputCommon/ControlReference/ControlReference.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Output.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
@ -138,4 +139,20 @@ void ControlGroup::SetControlExpression(int index, const std::string& expression
|
||||
{
|
||||
controls.at(index)->control_ref->SetExpression(expression);
|
||||
}
|
||||
|
||||
void ControlGroup::AddInput(Translatability translate, std::string name_)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(translate, std::move(name_)));
|
||||
}
|
||||
|
||||
void ControlGroup::AddInput(Translatability translate, std::string name_, std::string ui_name_)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(translate, std::move(name_), std::move(ui_name_)));
|
||||
}
|
||||
|
||||
void ControlGroup::AddOutput(Translatability translate, std::string name_)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Output>(translate, std::move(name_)));
|
||||
}
|
||||
|
||||
} // namespace ControllerEmu
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
@ -67,6 +68,10 @@ public:
|
||||
|
||||
void SetControlExpression(int index, const std::string& expression);
|
||||
|
||||
void AddInput(Translatability translate, std::string name);
|
||||
void AddInput(Translatability translate, std::string name, std::string ui_name);
|
||||
void AddOutput(Translatability translate, std::string name);
|
||||
|
||||
template <typename T>
|
||||
void AddSetting(SettingValue<T>* value, const NumericSettingDetails& details,
|
||||
std::common_type_t<T> default_value, std::common_type_t<T> min_value = {},
|
||||
|
@ -26,12 +26,12 @@ Cursor::Cursor(std::string name, std::string ui_name)
|
||||
m_last_update(Clock::now())
|
||||
{
|
||||
for (auto& named_direction : named_directions)
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, named_direction));
|
||||
AddInput(Translate, named_direction);
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Hide")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Recenter")));
|
||||
AddInput(Translate, _trans("Hide"));
|
||||
AddInput(Translate, _trans("Recenter"));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Relative Input Hold")));
|
||||
AddInput(Translate, _trans("Relative Input Hold"));
|
||||
|
||||
// Default values are optimized for "Super Mario Galaxy 2".
|
||||
// This seems to be acceptable for a good number of games.
|
||||
|
@ -18,12 +18,12 @@ namespace ControllerEmu
|
||||
{
|
||||
Force::Force(const std::string& name_) : ReshapableInput(name_, name_, GroupType::Force)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Up")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Down")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
|
||||
AddInput(Translate, _trans("Up"));
|
||||
AddInput(Translate, _trans("Down"));
|
||||
AddInput(Translate, _trans("Left"));
|
||||
AddInput(Translate, _trans("Right"));
|
||||
AddInput(Translate, _trans("Forward"));
|
||||
AddInput(Translate, _trans("Backward"));
|
||||
|
||||
AddSetting(&m_distance_setting,
|
||||
{_trans("Distance"),
|
||||
@ -127,11 +127,11 @@ Shake::Shake(const std::string& name_, ControlState default_intensity_scale)
|
||||
: ControlGroup(name_, name_, GroupType::Shake)
|
||||
{
|
||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||
controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("X")));
|
||||
AddInput(ControllerEmu::Translate, _trans("X"));
|
||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||
controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Y")));
|
||||
AddInput(ControllerEmu::Translate, _trans("Y"));
|
||||
// i18n: Refers to a 3D axis (used when mapping motion controls)
|
||||
controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Z")));
|
||||
AddInput(ControllerEmu::Translate, _trans("Z"));
|
||||
|
||||
AddDeadzoneSetting(&m_deadzone_setting, 50);
|
||||
|
||||
|
@ -17,12 +17,12 @@ namespace ControllerEmu
|
||||
IMUAccelerometer::IMUAccelerometer(std::string name, std::string ui_name)
|
||||
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUAccelerometer)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Up")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Down")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
|
||||
AddInput(Translate, _trans("Up"));
|
||||
AddInput(Translate, _trans("Down"));
|
||||
AddInput(Translate, _trans("Left"));
|
||||
AddInput(Translate, _trans("Right"));
|
||||
AddInput(Translate, _trans("Forward"));
|
||||
AddInput(Translate, _trans("Backward"));
|
||||
}
|
||||
|
||||
std::optional<IMUAccelerometer::StateData> IMUAccelerometer::GetState() const
|
||||
|
@ -20,7 +20,7 @@ IMUCursor::IMUCursor(std::string name, std::string ui_name)
|
||||
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUCursor,
|
||||
ControlGroup::CanBeDisabled::Yes)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Recenter")));
|
||||
AddInput(Translate, _trans("Recenter"));
|
||||
|
||||
// Default values are optimized for "Super Mario Galaxy 2".
|
||||
// This seems to be acceptable for a good number of games.
|
||||
|
@ -17,12 +17,12 @@ namespace ControllerEmu
|
||||
IMUGyroscope::IMUGyroscope(std::string name, std::string ui_name)
|
||||
: ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUGyroscope)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Pitch Up")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Pitch Down")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Roll Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Roll Right")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Yaw Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Yaw Right")));
|
||||
AddInput(Translate, _trans("Pitch Up"));
|
||||
AddInput(Translate, _trans("Pitch Down"));
|
||||
AddInput(Translate, _trans("Roll Left"));
|
||||
AddInput(Translate, _trans("Roll Right"));
|
||||
AddInput(Translate, _trans("Yaw Left"));
|
||||
AddInput(Translate, _trans("Yaw Right"));
|
||||
}
|
||||
|
||||
std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState() const
|
||||
|
@ -25,7 +25,7 @@ ModifySettingsButton::ModifySettingsButton(std::string button_name)
|
||||
|
||||
void ModifySettingsButton::AddInput(std::string button_name, bool toggle)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, std::move(button_name)));
|
||||
ControlGroup::AddInput(Translate, std::move(button_name));
|
||||
threshold_exceeded.emplace_back(false);
|
||||
associated_settings.emplace_back(false);
|
||||
associated_settings_toggle.emplace_back(toggle);
|
||||
|
@ -19,8 +19,8 @@ namespace ControllerEmu
|
||||
Slider::Slider(const std::string& name_, const std::string& ui_name_)
|
||||
: ControlGroup(name_, ui_name_, GroupType::Slider)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
||||
AddInput(Translate, _trans("Left"));
|
||||
AddInput(Translate, _trans("Right"));
|
||||
|
||||
AddDeadzoneSetting(&m_deadzone_setting, 50);
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ namespace ControllerEmu
|
||||
{
|
||||
Tilt::Tilt(const std::string& name_) : ReshapableInput(name_, name_, GroupType::Tilt)
|
||||
{
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Forward")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Backward")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Left")));
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Right")));
|
||||
AddInput(Translate, _trans("Forward"));
|
||||
AddInput(Translate, _trans("Backward"));
|
||||
AddInput(Translate, _trans("Left"));
|
||||
AddInput(Translate, _trans("Right"));
|
||||
|
||||
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Modifier")));
|
||||
AddInput(Translate, _trans("Modifier"));
|
||||
|
||||
AddSetting(&m_max_angle_setting,
|
||||
{_trans("Angle"),
|
||||
|
Reference in New Issue
Block a user