summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/touch_from_buttons.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers/touch_from_buttons.cpp')
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp29
1 files changed, 15 insertions, 14 deletions
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 @@
9 9
10namespace InputCommon { 10namespace InputCommon {
11 11
12class TouchFromButtonDevice final : public Input::InputDevice { 12class TouchFromButtonDevice final : public Common::Input::InputDevice {
13public: 13public:
14 using Button = std::unique_ptr<Input::InputDevice>; 14 using Button = std::unique_ptr<Common::Input::InputDevice>;
15 TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) 15 TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_)
16 : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { 16 : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) {
17 Input::InputCallback button_up_callback{ 17 Common::Input::InputCallback button_up_callback{
18 [this](Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; 18 [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }};
19 button->SetCallback(button_up_callback); 19 button->SetCallback(button_up_callback);
20 button->ForceUpdate(); 20 button->ForceUpdate();
21 } 21 }
22 22
23 Input::TouchStatus GetStatus(bool pressed) const { 23 Common::Input::TouchStatus GetStatus(bool pressed) const {
24 const Input::ButtonStatus button_status{ 24 const Common::Input::ButtonStatus button_status{
25 .value = pressed, 25 .value = pressed,
26 }; 26 };
27 Input::TouchStatus status{ 27 Common::Input::TouchStatus status{
28 .pressed = button_status, 28 .pressed = button_status,
29 .x = {}, 29 .x = {},
30 .y = {}, 30 .y = {},
@@ -42,9 +42,9 @@ public:
42 return status; 42 return status;
43 } 43 }
44 44
45 void UpdateButtonStatus(Input::CallbackStatus button_callback) { 45 void UpdateButtonStatus(Common::Input::CallbackStatus button_callback) {
46 const Input::CallbackStatus status{ 46 const Common::Input::CallbackStatus status{
47 .type = Input::InputType::Touch, 47 .type = Common::Input::InputType::Touch,
48 .touch_status = GetStatus(button_callback.button_status.value), 48 .touch_status = GetStatus(button_callback.button_status.value),
49 }; 49 };
50 TriggerOnChange(status); 50 TriggerOnChange(status);
@@ -55,13 +55,14 @@ private:
55 const u32 touch_id; 55 const u32 touch_id;
56 const float x; 56 const float x;
57 const float y; 57 const float y;
58 const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; 58 const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
59}; 59};
60 60
61std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) { 61std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create(
62 const Common::ParamPackage& params) {
62 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); 63 const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
63 auto button = 64 auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
64 Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); 65 params.Get("button", null_engine));
65 const auto touch_id = params.Get("touch_id", 0); 66 const auto touch_id = params.Get("touch_id", 0);
66 const float x = params.Get("x", 0.0f) / 1280.0f; 67 const float x = params.Get("x", 0.0f) / 1280.0f;
67 const float y = params.Get("y", 0.0f) / 720.0f; 68 const float y = params.Get("y", 0.0f) / 720.0f;