summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 {
1173} 1173}
1174 1174
1175AnalogSticks EmulatedController::GetSticks() const { 1175AnalogSticks EmulatedController::GetSticks() const {
1176 std::scoped_lock lock{mutex}; 1176 std::unique_lock lock{mutex};
1177
1177 if (is_configuring) { 1178 if (is_configuring) {
1178 return {}; 1179 return {};
1179 } 1180 }
1181
1180 // Some drivers like stick from buttons need constant refreshing 1182 // Some drivers like stick from buttons need constant refreshing
1181 for (auto& device : stick_devices) { 1183 for (auto& device : stick_devices) {
1182 if (!device) { 1184 if (!device) {
1183 continue; 1185 continue;
1184 } 1186 }
1187 lock.unlock();
1185 device->SoftUpdate(); 1188 device->SoftUpdate();
1189 lock.lock();
1186 } 1190 }
1191
1187 return controller.analog_stick_state; 1192 return controller.analog_stick_state;
1188} 1193}
1189 1194
@@ -1196,15 +1201,20 @@ NpadGcTriggerState EmulatedController::GetTriggers() const {
1196} 1201}
1197 1202
1198MotionState EmulatedController::GetMotions() const { 1203MotionState EmulatedController::GetMotions() const {
1199 std::scoped_lock lock{mutex}; 1204 std::unique_lock lock{mutex};
1205
1206 // Some drivers like mouse motion need constant refreshing
1200 if (force_update_motion) { 1207 if (force_update_motion) {
1201 for (auto& device : motion_devices) { 1208 for (auto& device : motion_devices) {
1202 if (!device) { 1209 if (!device) {
1203 continue; 1210 continue;
1204 } 1211 }
1212 lock.unlock();
1205 device->ForceUpdate(); 1213 device->ForceUpdate();
1214 lock.lock();
1206 } 1215 }
1207 } 1216 }
1217
1208 return controller.motion_state; 1218 return controller.motion_state;
1209} 1219}
1210 1220