diff options
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.h')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ControlReference.h | 26 |
1 files changed, 19 insertions, 7 deletions
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 <typename T> +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 <typename T> - T GetState(); + T GetState() + { + return ControllerEmu::ControlStateCast<T>(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<bool>() +inline bool ControlStateCast<bool>(ControlState value) { // Round to nearest of 0 or 1. - return std::lround(State()) > 0; + return std::lround(value) > 0; } template <> -inline int ControlReference::GetState<int>() +inline int ControlStateCast<int>(ControlState value) { - return std::lround(State()); + return std::lround(value); } template <> -inline ControlState ControlReference::GetState<ControlState>() +inline ControlState ControlStateCast<ControlState>(ControlState value) { - return State(); + return value; } +} // namespace ControllerEmu // // InputReference |
