diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-09-19 23:06:49 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-09-20 00:10:03 +0200 |
commit | 8992a62da4d48b440500d2017594667108633171 (patch) | |
tree | 49b57c2ea7e9e7aebde534e844d3aa779f20c862 /src/core/hid | |
parent | Merge pull request #11542 from t895/touch-offset-fix (diff) | |
download | yuzu-8992a62da4d48b440500d2017594667108633171.tar yuzu-8992a62da4d48b440500d2017594667108633171.tar.gz yuzu-8992a62da4d48b440500d2017594667108633171.tar.bz2 yuzu-8992a62da4d48b440500d2017594667108633171.tar.lz yuzu-8992a62da4d48b440500d2017594667108633171.tar.xz yuzu-8992a62da4d48b440500d2017594667108633171.tar.zst yuzu-8992a62da4d48b440500d2017594667108633171.zip |
Diffstat (limited to 'src/core/hid')
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 11 | ||||
-rw-r--r-- | src/core/hid/emulated_controller.h | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 94bd656fe..2af3f06fc 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -542,6 +542,7 @@ void EmulatedController::UnloadInput() { } void EmulatedController::EnableConfiguration() { + std::scoped_lock lock{connect_mutex, npad_mutex}; is_configuring = true; tmp_is_connected = is_connected; tmp_npad_type = npad_type; @@ -1556,7 +1557,7 @@ void EmulatedController::Connect(bool use_temporary_value) { auto trigger_guard = SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); }); - std::scoped_lock lock{mutex}; + std::scoped_lock lock{connect_mutex, mutex}; if (is_configuring) { tmp_is_connected = true; return; @@ -1572,7 +1573,7 @@ void EmulatedController::Connect(bool use_temporary_value) { void EmulatedController::Disconnect() { auto trigger_guard = SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); }); - std::scoped_lock lock{mutex}; + std::scoped_lock lock{connect_mutex, mutex}; if (is_configuring) { tmp_is_connected = false; return; @@ -1586,7 +1587,7 @@ void EmulatedController::Disconnect() { } bool EmulatedController::IsConnected(bool get_temporary_value) const { - std::scoped_lock lock{mutex}; + std::scoped_lock lock{connect_mutex}; if (get_temporary_value && is_configuring) { return tmp_is_connected; } @@ -1599,7 +1600,7 @@ NpadIdType EmulatedController::GetNpadIdType() const { } NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const { - std::scoped_lock lock{mutex}; + std::scoped_lock lock{npad_mutex}; if (get_temporary_value && is_configuring) { return tmp_npad_type; } @@ -1609,7 +1610,7 @@ NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) c void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { auto trigger_guard = SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); }); - std::scoped_lock lock{mutex}; + std::scoped_lock lock{mutex, npad_mutex}; if (is_configuring) { if (tmp_npad_type == npad_type_) { diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 88d77db8d..d4500583e 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -603,6 +603,8 @@ private: mutable std::mutex mutex; mutable std::mutex callback_mutex; + mutable std::mutex npad_mutex; + mutable std::mutex connect_mutex; std::unordered_map<int, ControllerUpdateCallback> callback_list; int last_callback_key = 0; |