From c6c32daf40ae1c720f0a2897c538bb1117371ea5 Mon Sep 17 00:00:00 2001 From: german77 Date: Sun, 24 Oct 2021 20:28:54 -0500 Subject: input_common: Add manual update options to input devices --- src/input_common/helpers/stick_from_buttons.cpp | 16 ++++++++++++++++ src/input_common/helpers/touch_from_buttons.cpp | 1 + 2 files changed, 17 insertions(+) (limited to 'src/input_common/helpers') diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 38f150746..9101f11ce 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp @@ -200,6 +200,22 @@ public: TriggerOnChange(status); } + void ForceUpdate() override{ + up->ForceUpdate(); + down->ForceUpdate(); + left->ForceUpdate(); + right->ForceUpdate(); + modifier->ForceUpdate(); + } + + void SoftUpdate() override { + Input::CallbackStatus status{ + .type = Input::InputType::Stick, + .stick_status = GetStatus(), + }; + TriggerOnChange(status); + } + Input::StickStatus GetStatus() const { Input::StickStatus status{}; status.x.properties = properties; diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index 2abfaf841..bb2bad5b1 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp @@ -17,6 +17,7 @@ public: Input::InputCallback button_up_callback{ [this](Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; button->SetCallback(button_up_callback); + button->ForceUpdate(); } Input::TouchStatus GetStatus(bool pressed) const { -- cgit v1.2.3