diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2019-10-18 14:54:02 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2020-02-08 14:01:55 -0600 |
| commit | e8152b700f76da97d346b93662ef8492bc93190c (patch) | |
| tree | 919fd82b5383987bc39fcafc9a152ea8225072de /Source/Core/InputCommon/ControlReference | |
| parent | 6a857df219f32a6b29683f54100e4cd92edd18e3 (diff) | |
InputCommon: Allow controller settings specified with input expresions.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference')
3 files changed, 18 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h index 539c7f4927..80c4a65d51 100644 --- a/Source/Core/InputCommon/ControlReference/ControlReference.h +++ b/Source/Core/InputCommon/ControlReference/ControlReference.h @@ -7,6 +7,7 @@ #include <memory> #include "InputCommon/ControlReference/ExpressionParser.h" +#include "InputCommon/ControlReference/FunctionExpression.h" #include "InputCommon/ControllerInterface/Device.h" // ControlReference @@ -30,6 +31,9 @@ public: virtual ControlState State(const ControlState state = 0) = 0; virtual bool IsInput() const = 0; + template <typename T> + T GetState(); + int BoundCount() const; ciface::ExpressionParser::ParseStatus GetParseStatus() const; void UpdateReference(ciface::ExpressionParser::ControlEnvironment& env); @@ -45,6 +49,18 @@ protected: ciface::ExpressionParser::ParseStatus m_parse_status; }; +template <> +inline bool ControlReference::GetState<bool>() +{ + return State() > ciface::ExpressionParser::CONDITION_THRESHOLD; +} + +template <typename T> +T ControlReference::GetState() +{ + return State(); +} + // // InputReference // diff --git a/Source/Core/InputCommon/ControlReference/FunctionExpression.cpp b/Source/Core/InputCommon/ControlReference/FunctionExpression.cpp index 75f78526e6..4d8e2866db 100644 --- a/Source/Core/InputCommon/ControlReference/FunctionExpression.cpp +++ b/Source/Core/InputCommon/ControlReference/FunctionExpression.cpp @@ -10,8 +10,6 @@ namespace ciface::ExpressionParser { -constexpr ControlState CONDITION_THRESHOLD = 0.5; - using Clock = std::chrono::steady_clock; using FSec = std::chrono::duration<ControlState>; diff --git a/Source/Core/InputCommon/ControlReference/FunctionExpression.h b/Source/Core/InputCommon/ControlReference/FunctionExpression.h index e247d9a623..3b29baa9ae 100644 --- a/Source/Core/InputCommon/ControlReference/FunctionExpression.h +++ b/Source/Core/InputCommon/ControlReference/FunctionExpression.h @@ -15,6 +15,8 @@ namespace ciface::ExpressionParser { +constexpr ControlState CONDITION_THRESHOLD = 0.5; + class FunctionExpression : public Expression { public: |
