diff options
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControllerEmu.cpp | 21 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControllerEmu.h | 10 |
2 files changed, 28 insertions, 3 deletions
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<std::recursive_mutex> 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<Attachments*>(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; diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index bf2ff666fa..2611880ee9 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -13,6 +13,7 @@ #include "Common/Common.h" #include "Common/IniFile.h" +#include "InputCommon/ControlReference/ExpressionParser.h" #include "InputCommon/ControllerInterface/Device.h" class ControllerInterface; @@ -20,6 +21,8 @@ class ControllerInterface; const char* const named_directions[] = {_trans("Up"), _trans("Down"), _trans("Left"), _trans("Right")}; +class ControlReference; + namespace ControllerEmu { class ControlGroup; @@ -43,6 +46,7 @@ public: void SetDefaultDevice(ciface::Core::DeviceQualifier devq); void UpdateReferences(const ControllerInterface& devi); + void UpdateSingleControlReference(const ControllerInterface& devi, ControlReference* ref); // This returns a lock that should be held before calling State() on any control // references and GetState(), by extension. This prevents a race condition @@ -75,6 +79,12 @@ public: return T(std::lround((zero_value - neg_1_value) * input_value + zero_value)); } +protected: + // TODO: Wiimote attachment has its own member that isn't being used.. + ciface::ExpressionParser::ControlEnvironment::VariableContainer m_expression_vars; + + void UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env); + private: ciface::Core::DeviceQualifier m_default_device; bool m_default_device_is_connected{false}; |
