summaryrefslogtreecommitdiff
path: root/src/core/frontend/input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend/input.h')
-rw-r--r--src/core/frontend/input.h15
1 files changed, 15 insertions, 0 deletions
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 {
27 float range; 27 float range;
28 float threshold; 28 float threshold;
29}; 29};
30template <typename StatusType>
31struct InputCallback {
32 std::function<void(StatusType)> on_change;
33};
30 34
31/// An abstract class template for an input device (a button, an analog input, etc.). 35/// An abstract class template for an input device (a button, an analog input, etc.).
32template <typename StatusType> 36template <typename StatusType>
@@ -50,6 +54,17 @@ public:
50 [[maybe_unused]] f32 freq_high) const { 54 [[maybe_unused]] f32 freq_high) const {
51 return {}; 55 return {};
52 } 56 }
57 void SetCallback(InputCallback<StatusType> callback_) {
58 callback = std::move(callback_);
59 }
60 void TriggerOnChange() {
61 if (callback.on_change) {
62 callback.on_change(GetStatus());
63 }
64 }
65
66private:
67 InputCallback<StatusType> callback;
53}; 68};
54 69
55/// An abstract class template for a factory that can create input devices. 70/// An abstract class template for a factory that can create input devices.