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/Cursor.cpp | |
| 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/Cursor.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 043ef37356..7359a4e66d 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -82,15 +82,28 @@ ControlState Cursor::GetGateRadiusAtAngle(double ang) const Cursor::StateData Cursor::GetState(const bool adjusted) { - if (!adjusted) - { - const auto raw_input = GetReshapableState(false); + const ReshapeData input = GetReshapableState(adjusted); + const StateData state = adjusted ? UpdateState(input) : StateData{input.x, input.y}; + return state; +} - return {raw_input.x, raw_input.y}; - } +Cursor::StateData Cursor::GetState(const bool adjusted, + const ControllerEmu::InputOverrideFunction& override_func) +{ + StateData state = GetState(adjusted); + if (!override_func) + return state; + + if (const std::optional<ControlState> x_override = override_func(name, X_INPUT_OVERRIDE, state.x)) + state.x = *x_override; + if (const std::optional<ControlState> y_override = override_func(name, Y_INPUT_OVERRIDE, state.y)) + state.y = *y_override; - const auto input = GetReshapableState(true); + return state; +} +Cursor::StateData Cursor::UpdateState(Cursor::ReshapeData input) +{ // TODO: Using system time is ugly. // Kill this after state is moved into wiimote rather than this class. const auto now = Clock::now(); |
