From e896835f86e52051b1998a344549dfa8ba79847a Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 30 Dec 2018 16:06:29 -0600 Subject: ExpressionParser: Renamed ControlFinder to ControlEnvironment. Added support for variables and assignment operator. ControlExpression objects now reference a matching input and output so the two can me mixed in any expression. (you can set rumble directly from inputs) --- .../InputCommon/ControllerEmu/ControllerEmu.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (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 de0579a2b2..c5ff0705a2 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp @@ -38,23 +38,38 @@ std::unique_lock EmulatedController::GetStateLock() void EmulatedController::UpdateReferences(const ControllerInterface& devi) { - const auto lock = GetStateLock(); m_default_device_is_connected = devi.HasConnectedDevice(m_default_device); + ciface::ExpressionParser::ControlEnvironment env(devi, GetDefaultDevice(), m_expression_vars); + + UpdateReferences(env); +} + +void EmulatedController::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env) +{ + const auto lock = GetStateLock(); + for (auto& ctrlGroup : groups) { for (auto& control : ctrlGroup->controls) - control->control_ref.get()->UpdateReference(devi, GetDefaultDevice()); + control->control_ref->UpdateReference(env); // Attachments: if (ctrlGroup->type == GroupType::Attachments) { for (auto& attachment : static_cast(ctrlGroup.get())->GetAttachmentList()) - attachment->UpdateReferences(devi); + attachment->UpdateReferences(env); } } } +void EmulatedController::UpdateSingleControlReference(const ControllerInterface& devi, + ControlReference* ref) +{ + ciface::ExpressionParser::ControlEnvironment env(devi, GetDefaultDevice(), m_expression_vars); + ref->UpdateReference(env); +} + bool EmulatedController::IsDefaultDeviceConnected() const { return m_default_device_is_connected; -- cgit v1.2.3