aboutsummaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-05-07 19:06:10 -0400
committerGitHub <noreply@github.com>2023-05-07 19:06:10 -0400
commit11e88239ec9d77d6ca5e87205c3023bf500e652f (patch)
tree0a9d3093c5729001ae0937db07b6a847feb6da13 /src/core/hid/emulated_controller.cpp
parent2a3464e8b9bc8d0707b5a78c46507d7b5a453a7c (diff)
parent62acd50c0bffadae6a6ca45c80c47b63e4d681d9 (diff)
Merge pull request #10195 from german77/mutex
core: hid: Update motion on a better place
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index ecab858933..c7f0af71ff 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -979,7 +979,6 @@ void EmulatedController::SetMotion(const Common::Input::CallbackStatus& callback
emulated.SetUserGyroThreshold(raw_status.gyro.x.properties.threshold);
emulated.UpdateRotation(raw_status.delta_timestamp);
emulated.UpdateOrientation(raw_status.delta_timestamp);
- force_update_motion = raw_status.force_update;
auto& motion = controller.motion_state[index];
motion.accel = emulated.GetAcceleration();
@@ -1618,19 +1617,6 @@ NpadGcTriggerState EmulatedController::GetTriggers() const {
MotionState EmulatedController::GetMotions() const {
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;
}
@@ -1696,8 +1682,21 @@ void EmulatedController::DeleteCallback(int key) {
callback_list.erase(iterator);
}
-void EmulatedController::TurboButtonUpdate() {
+void EmulatedController::StatusUpdate() {
turbo_button_state = (turbo_button_state + 1) % (TURBO_BUTTON_DELAY * 2);
+
+ // Some drivers like key motion need constant refreshing
+ for (std::size_t index = 0; index < motion_devices.size(); ++index) {
+ const auto& raw_status = controller.motion_values[index].raw_status;
+ auto& device = motion_devices[index];
+ if (!raw_status.force_update) {
+ continue;
+ }
+ if (!device) {
+ continue;
+ }
+ device->ForceUpdate();
+ }
}
NpadButton EmulatedController::GetTurboButtonMask() const {