diff options
author | bunnei <bunneidev@gmail.com> | 2021-06-04 06:06:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-04 06:06:38 +0200 |
commit | 1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89 (patch) | |
tree | 3fe737a16829382e361c4810745fada8dcbfed33 /src/core | |
parent | [game_list] Correct light theme loading (#6408) (diff) | |
parent | input_common: Analog button, use time based position instead of frequent updates (diff) | |
download | yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.gz yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.bz2 yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.lz yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.xz yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.zst yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/frontend/input.h | 15 |
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 { float range; float threshold; }; +template <typename StatusType> +struct InputCallback { + std::function<void(StatusType)> on_change; +}; /// An abstract class template for an input device (a button, an analog input, etc.). template <typename StatusType> @@ -50,6 +54,17 @@ public: [[maybe_unused]] f32 freq_high) const { return {}; } + void SetCallback(InputCallback<StatusType> callback_) { + callback = std::move(callback_); + } + void TriggerOnChange() { + if (callback.on_change) { + callback.on_change(GetStatus()); + } + } + +private: + InputCallback<StatusType> callback; }; /// An abstract class template for a factory that can create input devices. |