diff options
| author | 2021-06-03 21:06:38 -0700 | |
|---|---|---|
| committer | 2021-06-03 21:06:38 -0700 | |
| commit | 1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89 (patch) | |
| tree | 3fe737a16829382e361c4810745fada8dcbfed33 /src/core/frontend/input.h | |
| 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.gz yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.tar.xz yuzu-1d1f6160634e1390c5cadcb0a8575e6bfaaa6b89.zip | |
Merge pull request #6389 from german77/Analog_button_fix
input_common: Analog button, use time based position
Diffstat (limited to 'src/core/frontend/input.h')
| -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. |