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.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;