mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-27 06:48:33 +00:00
InputCommon: Eliminate some duplicated button threshold logic.
This commit is contained in:
parent
2e2540317e
commit
f07457b6cc
17 changed files with 50 additions and 45 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue