mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
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
This commit is contained in:
@ -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
|
||||
|
@ -191,6 +191,11 @@ public:
|
||||
// which happens while handling a hotplug event because a control reference's State()
|
||||
// could be called before we have finished updating the reference.
|
||||
[[nodiscard]] static std::unique_lock<std::recursive_mutex> GetStateLock();
|
||||
const ciface::ExpressionParser::ControlEnvironment::VariableContainer&
|
||||
GetExpressionVariables() const;
|
||||
|
||||
// Resets the values while keeping the list.
|
||||
void ResetExpressionVariables();
|
||||
|
||||
std::vector<std::unique_ptr<ControlGroup>> groups;
|
||||
|
||||
@ -218,7 +223,8 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// TODO: Wiimote attachment has its own member that isn't being used.
|
||||
// TODO: Wiimote attachments actually end up using their parent controller value for this,
|
||||
// so theirs won't be used (and thus shouldn't even exist).
|
||||
ciface::ExpressionParser::ControlEnvironment::VariableContainer m_expression_vars;
|
||||
|
||||
void UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env);
|
||||
|
Reference in New Issue
Block a user