summaryrefslogtreecommitdiffstats
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-04-08 00:08:01 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2022-04-08 00:08:01 +0200
commitbbaa08d7f05816960204cbf0b1569972f0928199 (patch)
tree96ada42ea08419da38796dbb9c6c0e1cdbe171c4 /src/core/hid/emulated_controller.cpp
parentcore: hid: Replace lock_guard with scoped_lock (diff)
downloadyuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar.gz
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar.bz2
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar.lz
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar.xz
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.tar.zst
yuzu-bbaa08d7f05816960204cbf0b1569972f0928199.zip
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index d3b13dbbd..c3f21066c 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -1173,17 +1173,22 @@ DebugPadButton EmulatedController::GetDebugPadButtons() const {
}
AnalogSticks EmulatedController::GetSticks() const {
- std::scoped_lock lock{mutex};
+ std::unique_lock lock{mutex};
+
if (is_configuring) {
return {};
}
+
// Some drivers like stick from buttons need constant refreshing
for (auto& device : stick_devices) {
if (!device) {
continue;
}
+ lock.unlock();
device->SoftUpdate();
+ lock.lock();
}
+
return controller.analog_stick_state;
}
@@ -1196,15 +1201,20 @@ NpadGcTriggerState EmulatedController::GetTriggers() const {
}
MotionState EmulatedController::GetMotions() const {
- std::scoped_lock lock{mutex};
+ std::unique_lock lock{mutex};
+
+ // Some drivers like mouse motion need constant refreshing
if (force_update_motion) {
for (auto& device : motion_devices) {
if (!device) {
continue;
}
+ lock.unlock();
device->ForceUpdate();
+ lock.lock();
}
}
+
return controller.motion_state;
}