diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-10-03 16:25:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-03 16:25:40 -0400 |
| commit | 052c7395fbc0789147703a4c5cc754ae28f8f8bd (patch) | |
| tree | c6e206df257937e8373aeeb012e29ea74f0d0fc7 /Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h | |
| parent | cb6d476538afe85c25d30e8679b6f15abe5d1760 (diff) | |
| parent | 51ee05cb35f401c82adf815cbb4f4c3133e7ea84 (diff) | |
Merge pull request #9624 from JosJuice/input-override
Add new "input override" system for TAS input and Android touch controls
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h index 2d02adabf1..652f64ae5f 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Buttons.h @@ -3,6 +3,7 @@ #pragma once +#include <cmath> #include <string> #include "InputCommon/ControlReference/ControlReference.h" @@ -24,5 +25,21 @@ public: for (auto& control : controls) *buttons |= *(bitmasks++) * control->GetState<bool>(); } + + template <typename C> + void GetState(C* const buttons, const C* bitmasks, + const InputOverrideFunction& override_func) const + { + if (!override_func) + return GetState(buttons, bitmasks); + + for (auto& control : controls) + { + ControlState state = control->GetState(); + if (std::optional<ControlState> state_override = override_func(name, control->name, state)) + state = *state_override; + *buttons |= *(bitmasks++) * (std::lround(state) > 0); + } + } }; } // namespace ControllerEmu |
