diff options
| author | Tilka <tilkax@gmail.com> | 2020-02-10 00:05:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-10 00:05:10 +0000 |
| commit | db65b9a766fd443eac48ced8e7693ef23b39e83e (patch) | |
| tree | e428c2563bb014968679e59c447ce3eb62a7b830 /Source/Core/InputCommon/ControlReference | |
| parent | e00459f68fd53b6a4d30800ce0548e459b141e5e (diff) | |
| parent | f07457b6ccb0ef6773b08c0e494df28a29c1b3e6 (diff) | |
Merge pull request #8616 from jordan-woyak/threshold-cleanup
InputCommon: Eliminate some duplicated button threshold logic.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference')
| -rw-r--r-- | Source/Core/InputCommon/ControlReference/ControlReference.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index 80c4a65d51..de289ba265 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -4,10 +4,10 @@ #pragma once +#include <cmath> #include <memory> #include "InputCommon/ControlReference/ExpressionParser.h" -#include "InputCommon/ControlReference/FunctionExpression.h" #include "InputCommon/ControllerInterface/Device.h" // ControlReference @@ -52,11 +52,18 @@ protected: template <> inline bool ControlReference::GetState<bool>() { - return State() > ciface::ExpressionParser::CONDITION_THRESHOLD; + // Round to nearest of 0 or 1. + return std::lround(State()) > 0; } -template <typename T> -T ControlReference::GetState() +template <> +inline int ControlReference::GetState<int>() +{ + return std::lround(State()); +} + +template <> +inline ControlState ControlReference::GetState<ControlState>() { return State(); } |
