summaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
authorGravatar german772023-05-07 16:38:41 -0600
committerGravatar german772023-05-07 17:01:57 -0600
commitcf023aa8ec93193d4827b3034c9e7d35a0edfc2a (patch)
tree66c90375ec6d8a8f1bae96e8c6fc9194b8407756 /src/core/hid/emulated_controller.cpp
parentMerge pull request #10097 from german77/nfp_full (diff)
downloadyuzu-cf023aa8ec93193d4827b3034c9e7d35a0edfc2a.tar.gz
yuzu-cf023aa8ec93193d4827b3034c9e7d35a0edfc2a.tar.xz
yuzu-cf023aa8ec93193d4827b3034c9e7d35a0edfc2a.zip
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 ecab85893..c7f0af71f 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
979 emulated.SetUserGyroThreshold(raw_status.gyro.x.properties.threshold); 979 emulated.SetUserGyroThreshold(raw_status.gyro.x.properties.threshold);
980 emulated.UpdateRotation(raw_status.delta_timestamp); 980 emulated.UpdateRotation(raw_status.delta_timestamp);
981 emulated.UpdateOrientation(raw_status.delta_timestamp); 981 emulated.UpdateOrientation(raw_status.delta_timestamp);
982 force_update_motion = raw_status.force_update;
983 982
984 auto& motion = controller.motion_state[index]; 983 auto& motion = controller.motion_state[index];
985 motion.accel = emulated.GetAcceleration(); 984 motion.accel = emulated.GetAcceleration();
@@ -1618,19 +1617,6 @@ NpadGcTriggerState EmulatedController::GetTriggers() const {
1618 1617
1619MotionState EmulatedController::GetMotions() const { 1618MotionState EmulatedController::GetMotions() const {
1620 std::unique_lock lock{mutex}; 1619 std::unique_lock lock{mutex};
1621
1622 // Some drivers like mouse motion need constant refreshing
1623 if (force_update_motion) {
1624 for (auto& device : motion_devices) {
1625 if (!device) {
1626 continue;
1627 }
1628 lock.unlock();
1629 device->ForceUpdate();
1630 lock.lock();
1631 }
1632 }
1633
1634 return controller.motion_state; 1620 return controller.motion_state;
1635} 1621}
1636 1622
@@ -1696,8 +1682,21 @@ void EmulatedController::DeleteCallback(int key) {
1696 callback_list.erase(iterator); 1682 callback_list.erase(iterator);
1697} 1683}
1698 1684
1699void EmulatedController::TurboButtonUpdate() { 1685void EmulatedController::StatusUpdate() {
1700 turbo_button_state = (turbo_button_state + 1) % (TURBO_BUTTON_DELAY * 2); 1686 turbo_button_state = (turbo_button_state + 1) % (TURBO_BUTTON_DELAY * 2);
1687
1688 // Some drivers like key motion need constant refreshing
1689 for (std::size_t index = 0; index < motion_devices.size(); ++index) {
1690 const auto& raw_status = controller.motion_values[index].raw_status;
1691 auto& device = motion_devices[index];
1692 if (!raw_status.force_update) {
1693 continue;
1694 }
1695 if (!device) {
1696 continue;
1697 }
1698 device->ForceUpdate();
1699 }
1701} 1700}
1702 1701
1703NpadButton EmulatedController::GetTurboButtonMask() const { 1702NpadButton EmulatedController::GetTurboButtonMask() const {