summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControlReference/ControlReference.h
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2024-03-20 22:40:01 -0500
committerJordan Woyak <jordan.woyak@gmail.com>2024-04-12 15:54:18 -0500
commite9fe0d3d5b81bcaffbbc00c132705adc03142c61 (patch)
treedb94b4b0466a8f52dcbf0f69918eceb4791e3f36 /Source/Core/InputCommon/ControlReference/ControlReference.h
parent5039072ae9a97d7bf6f6711225a2368c71350f13 (diff)
NumericSetting: Stop values from binding to numbered input names.
Diffstat (limited to 'Source/Core/InputCommon/ControlReference/ControlReference.h')
-rw-r--r--Source/Core/InputCommon/ControlReference/ControlReference.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/Source/Core/InputCommon/ControlReference/ControlReference.h b/Source/Core/InputCommon/ControlReference/ControlReference.h
index f12e354bb3..984ab2cd0f 100644
--- a/Source/Core/InputCommon/ControlReference/ControlReference.h
+++ b/Source/Core/InputCommon/ControlReference/ControlReference.h
@@ -9,6 +9,12 @@
#include "InputCommon/ControlReference/ExpressionParser.h"
#include "InputCommon/ControllerInterface/CoreDevice.h"
+namespace ControllerEmu
+{
+template <typename T>
+T ControlStateCast(ControlState value);
+}
+
// ControlReference
//
// These are what you create to actually use the inputs, InputReference or OutputReference.
@@ -31,7 +37,10 @@ public:
virtual bool IsInput() const = 0;
template <typename T>
- T GetState();
+ T GetState()
+ {
+ return ControllerEmu::ControlStateCast<T>(State());
+ }
int BoundCount() const;
ciface::ExpressionParser::ParseStatus GetParseStatus() const;
@@ -51,24 +60,27 @@ protected:
ciface::ExpressionParser::ParseStatus::EmptyExpression;
};
+namespace ControllerEmu
+{
template <>
-inline bool ControlReference::GetState<bool>()
+inline bool ControlStateCast<bool>(ControlState value)
{
// Round to nearest of 0 or 1.
- return std::lround(State()) > 0;
+ return std::lround(value) > 0;
}
template <>
-inline int ControlReference::GetState<int>()
+inline int ControlStateCast<int>(ControlState value)
{
- return std::lround(State());
+ return std::lround(value);
}
template <>
-inline ControlState ControlReference::GetState<ControlState>()
+inline ControlState ControlStateCast<ControlState>(ControlState value)
{
- return State();
+ return value;
}
+} // namespace ControllerEmu
//
// InputReference