InputCommon: Eliminate some duplicated button threshold logic.
This commit is contained in:
1 parent
2e2540317e
commit
f07457b6cc
17 files changed
+50
-45
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user