mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 19:00:14 -05:00
core: hid: Fix double lock on softlock and forced updates
This commit is contained in:
parent
9c85cb354a
commit
bbaa08d7f0
1 changed files with 12 additions and 2 deletions
|
@ -1173,17 +1173,22 @@ DebugPadButton EmulatedController::GetDebugPadButtons() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalogSticks EmulatedController::GetSticks() const {
|
AnalogSticks EmulatedController::GetSticks() const {
|
||||||
std::scoped_lock lock{mutex};
|
std::unique_lock lock{mutex};
|
||||||
|
|
||||||
if (is_configuring) {
|
if (is_configuring) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some drivers like stick from buttons need constant refreshing
|
// Some drivers like stick from buttons need constant refreshing
|
||||||
for (auto& device : stick_devices) {
|
for (auto& device : stick_devices) {
|
||||||
if (!device) {
|
if (!device) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
lock.unlock();
|
||||||
device->SoftUpdate();
|
device->SoftUpdate();
|
||||||
|
lock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
return controller.analog_stick_state;
|
return controller.analog_stick_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,15 +1201,20 @@ NpadGcTriggerState EmulatedController::GetTriggers() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionState EmulatedController::GetMotions() 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) {
|
if (force_update_motion) {
|
||||||
for (auto& device : motion_devices) {
|
for (auto& device : motion_devices) {
|
||||||
if (!device) {
|
if (!device) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
lock.unlock();
|
||||||
device->ForceUpdate();
|
device->ForceUpdate();
|
||||||
|
lock.lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return controller.motion_state;
|
return controller.motion_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue