diff options
| author | 2021-05-29 23:35:46 -0500 | |
|---|---|---|
| committer | 2021-05-30 00:13:51 -0500 | |
| commit | a323bc5af8b758dfb7baeb90641ad71f0dba9163 (patch) | |
| tree | b4a8d5ebf77afe40ad67d200aabc72de0b79b786 /src/core | |
| parent | Merge pull request #6379 from degasus/update_dynarmic (diff) | |
| download | yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.gz yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.tar.xz yuzu-a323bc5af8b758dfb7baeb90641ad71f0dba9163.zip | |
input_common: Analog button, use time based position instead of frequent updates
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 { | |||
| 27 | float range; | 27 | float range; |
| 28 | float threshold; | 28 | float threshold; |
| 29 | }; | 29 | }; |
| 30 | template <typename StatusType> | ||
| 31 | struct 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.). |
| 32 | template <typename StatusType> | 36 | template <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 | |||
| 66 | private: | ||
| 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. |