diff options
author | Mai M <mathew1800@gmail.com> | 2021-06-23 04:17:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 04:17:57 +0200 |
commit | 4ec7d79174e5383941767ace57888168c5f6b017 (patch) | |
tree | 600aaebf4bdae84d6c3941b8b70789dee46f9ab3 /src | |
parent | Merge pull request #6493 from Morph1984/fs-nodiscard (diff) | |
parent | npad: Fix data race when updating devices (diff) | |
download | yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar.gz yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar.bz2 yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar.lz yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar.xz yuzu-4ec7d79174e5383941767ace57888168c5f6b017.tar.zst yuzu-4ec7d79174e5383941767ace57888168c5f6b017.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 7acad3798..1eb02aee2 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -314,6 +314,8 @@ void Controller_NPad::OnInit() { void Controller_NPad::OnLoadInputDevices() { const auto& players = Settings::values.players.GetValue(); + + std::lock_guard lock{mutex}; for (std::size_t i = 0; i < players.size(); ++i) { std::transform(players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, players[i].buttons.begin() + Settings::NativeButton::BUTTON_HID_END, @@ -348,6 +350,8 @@ void Controller_NPad::OnRelease() { } void Controller_NPad::RequestPadStateUpdate(u32 npad_id) { + std::lock_guard lock{mutex}; + const auto controller_idx = NPadIdToIndex(npad_id); const auto controller_type = connected_controllers[controller_idx].type; if (!connected_controllers[controller_idx].is_connected) { diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index c050c9a44..1409d82a2 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -6,6 +6,8 @@ #include <array> #include <atomic> +#include <mutex> + #include "common/bit_field.h" #include "common/common_types.h" #include "common/quaternion.h" @@ -563,6 +565,8 @@ private: using MotionArray = std::array< std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>, 10>; + + std::mutex mutex; ButtonArray buttons; StickArray sticks; VibrationArray vibrations; |