mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-11 16:49:28 +02:00
InputCommon: Eliminate some duplicated button threshold logic.
This commit is contained in:
@ -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