From e9fe0d3d5b81bcaffbbc00c132705adc03142c61 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 20 Mar 2024 22:40:01 -0500 Subject: NumericSetting: Stop values from binding to numbered input names. --- .../ControlReference/ControlReference.h | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.h') diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index f12e354bb3..984ab2cd0f 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -9,6 +9,12 @@ #include "InputCommon/ControlReference/ExpressionParser.h" #include "InputCommon/ControllerInterface/CoreDevice.h" +namespace ControllerEmu +{ +template +T ControlStateCast(ControlState value); +} + // ControlReference // // These are what you create to actually use the inputs, InputReference or OutputReference. @@ -31,7 +37,10 @@ public: virtual bool IsInput() const = 0; template - T GetState(); + T GetState() + { + return ControllerEmu::ControlStateCast(State()); + } int BoundCount() const; ciface::ExpressionParser::ParseStatus GetParseStatus() const; @@ -51,24 +60,27 @@ protected: ciface::ExpressionParser::ParseStatus::EmptyExpression; }; +namespace ControllerEmu +{ template <> -inline bool ControlReference::GetState() +inline bool ControlStateCast(ControlState value) { // Round to nearest of 0 or 1. - return std::lround(State()) > 0; + return std::lround(value) > 0; } template <> -inline int ControlReference::GetState() +inline int ControlStateCast(ControlState value) { - return std::lround(State()); + return std::lround(value); } template <> -inline ControlState ControlReference::GetState() +inline ControlState ControlStateCast(ControlState value) { - return State(); + return value; } +} // namespace ControllerEmu // // InputReference -- cgit v1.2.3