summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/touch_from_buttons.cpp
diff options
context:
space:
mode:
authorGravatar german772021-11-01 19:49:14 -0600
committerGravatar Narr the Reg2021-11-24 20:30:27 -0600
commit136eb9c4c2b2425c2dd45a79cf444dee7170714d (patch)
tree74a055a08126fdd33b2071baa08125177847db6e /src/input_common/helpers/touch_from_buttons.cpp
parentsecond commit lion review (diff)
downloadyuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.tar.gz
yuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.tar.xz
yuzu-136eb9c4c2b2425c2dd45a79cf444dee7170714d.zip
core/hid: Fully emulate motion from button
Diffstat (limited to 'src/input_common/helpers/touch_from_buttons.cpp')
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index 024343715..35d60bc90 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -16,10 +16,15 @@ public:
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 Common::Input::InputCallback button_up_callback{ 17 Common::Input::InputCallback button_up_callback{
18 [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; 18 [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }};
19 last_button_value = false;
19 button->SetCallback(button_up_callback); 20 button->SetCallback(button_up_callback);
20 button->ForceUpdate(); 21 button->ForceUpdate();
21 } 22 }
22 23
24 void ForceUpdate() override {
25 button->ForceUpdate();
26 }
27
23 Common::Input::TouchStatus GetStatus(bool pressed) const { 28 Common::Input::TouchStatus GetStatus(bool pressed) const {
24 const Common::Input::ButtonStatus button_status{ 29 const Common::Input::ButtonStatus button_status{
25 .value = pressed, 30 .value = pressed,
@@ -47,11 +52,15 @@ public:
47 .type = Common::Input::InputType::Touch, 52 .type = Common::Input::InputType::Touch,
48 .touch_status = GetStatus(button_callback.button_status.value), 53 .touch_status = GetStatus(button_callback.button_status.value),
49 }; 54 };
50 TriggerOnChange(status); 55 if (last_button_value != button_callback.button_status.value) {
56 last_button_value = button_callback.button_status.value;
57 TriggerOnChange(status);
58 }
51 } 59 }
52 60
53private: 61private:
54 Button button; 62 Button button;
63 bool last_button_value;
55 const int touch_id; 64 const int touch_id;
56 const float x; 65 const float x;
57 const float y; 66 const float y;