diff options
author | german77 <juangerman-13@hotmail.com> | 2021-05-30 06:35:46 +0200 |
---|---|---|
committer | german77 <german77@github.com> | 2021-05-30 07:13:51 +0200 |
commit | a323bc5af8b758dfb7baeb90641ad71f0dba9163 (patch) | |
tree | b4a8d5ebf77afe40ad67d200aabc72de0b79b786 /src/core | |
parent | Merge pull request #6379 from degasus/update_dynarmic (diff) | |
download | yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.gz yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.bz2 yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.lz yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.xz yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.zst yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.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. |