From 93e3e691f9a3a9913b56ebe71b4bd34fd21ce5c9 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Fri, 12 Mar 2021 00:01:18 +0200 Subject: Expose Control Expression variables to mappings UI -add a way to reset their value (from the mappings UI) -fix "memory leak" where they would never be cleaned, one would be created every time you wrote a character after a "$" -fix ability to create variables with an empty string by just writing "$" (+added error for it) -Add $ operator to the UI operators list, to expose this functionality even more --- .../InputCommon/ControllerEmu/ControllerEmu.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp') diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp index a9c5844b48..498586a9f2 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp @@ -44,6 +44,8 @@ void EmulatedController::UpdateReferences(const ControllerInterface& devi) ciface::ExpressionParser::ControlEnvironment env(devi, GetDefaultDevice(), m_expression_vars); UpdateReferences(env); + + env.CleanUnusedVariables(); } void EmulatedController::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) @@ -75,7 +77,27 @@ void EmulatedController::UpdateSingleControlReference(const ControllerInterface& ControlReference* ref) { ciface::ExpressionParser::ControlEnvironment env(devi, GetDefaultDevice(), m_expression_vars); + ref->UpdateReference(env); + + env.CleanUnusedVariables(); +} + +const ciface::ExpressionParser::ControlEnvironment::VariableContainer& +EmulatedController::GetExpressionVariables() const +{ + return m_expression_vars; +} + +void EmulatedController::ResetExpressionVariables() +{ + for (auto& var : m_expression_vars) + { + if (var.second) + { + *var.second = 0; + } + } } bool EmulatedController::IsDefaultDeviceConnected() const -- cgit v1.2.3