From a323bc5af8b758dfb7baeb90641ad71f0dba9163 Mon Sep 17 00:00:00 2001 From: german77 Date: Sat, 29 May 2021 23:35:46 -0500 Subject: input_common: Analog button, use time based position instead of frequent updates --- src/core/frontend/input.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core') diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 0c5d2b3b0..7a047803e 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h @@ -27,6 +27,10 @@ struct AnalogProperties { float range; float threshold; }; +template +struct InputCallback { + std::function on_change; +}; /// An abstract class template for an input device (a button, an analog input, etc.). template @@ -50,6 +54,17 @@ public: [[maybe_unused]] f32 freq_high) const { return {}; } + void SetCallback(InputCallback callback_) { + callback = std::move(callback_); + } + void TriggerOnChange() { + if (callback.on_change) { + callback.on_change(GetStatus()); + } + } + +private: + InputCallback callback; }; /// An abstract class template for a factory that can create input devices. -- cgit v1.2.3