summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers')
-rw-r--r--src/input_common/helpers/stick_from_buttons.cpp70
-rw-r--r--src/input_common/helpers/stick_from_buttons.h4
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp29
-rw-r--r--src/input_common/helpers/touch_from_buttons.h4
4 files changed, 57 insertions, 50 deletions
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp
index 806a0e8bb..1d5948f79 100644
--- a/src/input_common/helpers/stick_from_buttons.cpp
+++ b/src/input_common/helpers/stick_from_buttons.cpp
@@ -10,25 +10,27 @@
namespace InputCommon {
-class Stick final : public Input::InputDevice {
+class Stick final : public Common::Input::InputDevice {
public:
- using Button = std::unique_ptr<Input::InputDevice>;
+ using Button = std::unique_ptr<Common::Input::InputDevice>;
Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_,
float modifier_scale_, float modifier_angle_)
: up(std::move(up_)), down(std::move(down_)), left(std::move(left_)),
right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_),
modifier_angle(modifier_angle_) {
- Input::InputCallback button_up_callback{
- [this](Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }};
- Input::InputCallback button_down_callback{
- [this](Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }};
- Input::InputCallback button_left_callback{
- [this](Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }};
- Input::InputCallback button_right_callback{
- [this](Input::CallbackStatus callback_) { UpdateRightButtonStatus(callback_); }};
- Input::InputCallback button_modifier_callback{
- [this](Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }};
+ Common::Input::InputCallback button_up_callback{
+ [this](Common::Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }};
+ Common::Input::InputCallback button_down_callback{
+ [this](Common::Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }};
+ Common::Input::InputCallback button_left_callback{
+ [this](Common::Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }};
+ Common::Input::InputCallback button_right_callback{
+ [this](Common::Input::CallbackStatus callback_) {
+ UpdateRightButtonStatus(callback_);
+ }};
+ Common::Input::InputCallback button_modifier_callback{
+ [this](Common::Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }};
up->SetCallback(button_up_callback);
down->SetCallback(button_down_callback);
left->SetCallback(button_left_callback);
@@ -129,27 +131,27 @@ public:
}
}
- void UpdateUpButtonStatus(Input::CallbackStatus button_callback) {
+ void UpdateUpButtonStatus(Common::Input::CallbackStatus button_callback) {
up_status = button_callback.button_status.value;
UpdateStatus();
}
- void UpdateDownButtonStatus(Input::CallbackStatus button_callback) {
+ void UpdateDownButtonStatus(Common::Input::CallbackStatus button_callback) {
down_status = button_callback.button_status.value;
UpdateStatus();
}
- void UpdateLeftButtonStatus(Input::CallbackStatus button_callback) {
+ void UpdateLeftButtonStatus(Common::Input::CallbackStatus button_callback) {
left_status = button_callback.button_status.value;
UpdateStatus();
}
- void UpdateRightButtonStatus(Input::CallbackStatus button_callback) {
+ void UpdateRightButtonStatus(Common::Input::CallbackStatus button_callback) {
right_status = button_callback.button_status.value;
UpdateStatus();
}
- void UpdateModButtonStatus(Input::CallbackStatus button_callback) {
+ void UpdateModButtonStatus(Common::Input::CallbackStatus button_callback) {
modifier_status = button_callback.button_status.value;
UpdateStatus();
}
@@ -193,8 +195,8 @@ public:
}
last_update = now;
- Input::CallbackStatus status{
- .type = Input::InputType::Stick,
+ Common::Input::CallbackStatus status{
+ .type = Common::Input::InputType::Stick,
.stick_status = GetStatus(),
};
TriggerOnChange(status);
@@ -209,15 +211,15 @@ public:
}
void SoftUpdate() override {
- Input::CallbackStatus status{
- .type = Input::InputType::Stick,
+ Common::Input::CallbackStatus status{
+ .type = Common::Input::InputType::Stick,
.stick_status = GetStatus(),
};
TriggerOnChange(status);
}
- Input::StickStatus GetStatus() const {
- Input::StickStatus status{};
+ Common::Input::StickStatus GetStatus() const {
+ Common::Input::StickStatus status{};
status.x.properties = properties;
status.y.properties = properties;
if (Settings::values.emulate_analog_keyboard) {
@@ -263,19 +265,23 @@ private:
bool left_status;
bool right_status;
bool modifier_status;
- const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
+ const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
std::chrono::time_point<std::chrono::steady_clock> last_update;
};
-std::unique_ptr<Input::InputDevice> StickFromButton::Create(const Common::ParamPackage& params) {
+std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create(
+ const Common::ParamPackage& params) {
const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
- auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine));
- auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine));
- auto left = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("left", null_engine));
- auto right =
- Input::CreateDeviceFromString<Input::InputDevice>(params.Get("right", null_engine));
- auto modifier =
- Input::CreateDeviceFromString<Input::InputDevice>(params.Get("modifier", null_engine));
+ auto up = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("up", null_engine));
+ auto down = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("down", null_engine));
+ auto left = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("left", null_engine));
+ auto right = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("right", null_engine));
+ auto modifier = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("modifier", null_engine));
auto modifier_scale = params.Get("modifier_scale", 0.5f);
auto modifier_angle = params.Get("modifier_angle", 5.5f);
return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left),
diff --git a/src/input_common/helpers/stick_from_buttons.h b/src/input_common/helpers/stick_from_buttons.h
index 82dff5ca8..437ace4f7 100644
--- a/src/input_common/helpers/stick_from_buttons.h
+++ b/src/input_common/helpers/stick_from_buttons.h
@@ -12,7 +12,7 @@ namespace InputCommon {
* An analog device factory that takes direction button devices and combines them into a analog
* device.
*/
-class StickFromButton final : public Input::Factory<Input::InputDevice> {
+class StickFromButton final : public Common::Input::Factory<Common::Input::InputDevice> {
public:
/**
* Creates an analog device from direction button devices
@@ -24,7 +24,7 @@ public:
* - "modifier": a serialized ParamPackage for creating a button device as the modifier
* - "modifier_scale": a float for the multiplier the modifier gives to the position
*/
- std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override;
+ std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override;
};
} // namespace InputCommon
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index bb2bad5b1..fee41cae3 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -9,22 +9,22 @@
namespace InputCommon {
-class TouchFromButtonDevice final : public Input::InputDevice {
+class TouchFromButtonDevice final : public Common::Input::InputDevice {
public:
- using Button = std::unique_ptr<Input::InputDevice>;
+ using Button = std::unique_ptr<Common::Input::InputDevice>;
TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_)
: button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) {
- Input::InputCallback button_up_callback{
- [this](Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }};
+ Common::Input::InputCallback button_up_callback{
+ [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }};
button->SetCallback(button_up_callback);
button->ForceUpdate();
}
- Input::TouchStatus GetStatus(bool pressed) const {
- const Input::ButtonStatus button_status{
+ Common::Input::TouchStatus GetStatus(bool pressed) const {
+ const Common::Input::ButtonStatus button_status{
.value = pressed,
};
- Input::TouchStatus status{
+ Common::Input::TouchStatus status{
.pressed = button_status,
.x = {},
.y = {},
@@ -42,9 +42,9 @@ public:
return status;
}
- void UpdateButtonStatus(Input::CallbackStatus button_callback) {
- const Input::CallbackStatus status{
- .type = Input::InputType::Touch,
+ void UpdateButtonStatus(Common::Input::CallbackStatus button_callback) {
+ const Common::Input::CallbackStatus status{
+ .type = Common::Input::InputType::Touch,
.touch_status = GetStatus(button_callback.button_status.value),
};
TriggerOnChange(status);
@@ -55,13 +55,14 @@ private:
const u32 touch_id;
const float x;
const float y;
- const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
+ const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
};
-std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) {
+std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create(
+ const Common::ParamPackage& params) {
const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
- auto button =
- Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine));
+ auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
+ params.Get("button", null_engine));
const auto touch_id = params.Get("touch_id", 0);
const float x = params.Get("x", 0.0f) / 1280.0f;
const float y = params.Get("y", 0.0f) / 720.0f;
diff --git a/src/input_common/helpers/touch_from_buttons.h b/src/input_common/helpers/touch_from_buttons.h
index 21b353728..628f18215 100644
--- a/src/input_common/helpers/touch_from_buttons.h
+++ b/src/input_common/helpers/touch_from_buttons.h
@@ -11,12 +11,12 @@ namespace InputCommon {
/**
* A touch device factory that takes a list of button devices and combines them into a touch device.
*/
-class TouchFromButton final : public Input::Factory<Input::InputDevice> {
+class TouchFromButton final : public Common::Input::Factory<Common::Input::InputDevice> {
public:
/**
* Creates a touch device from a list of button devices
*/
- std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override;
+ std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override;
};
} // namespace InputCommon