diff options
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 29 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 5 | ||||
| -rw-r--r-- | src/core/hid/input_converter.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 2 |
5 files changed, 20 insertions, 22 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 | ||
| 1619 | MotionState EmulatedController::GetMotions() const { | 1618 | MotionState 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 | ||
| 1699 | void EmulatedController::TurboButtonUpdate() { | 1685 | void 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 | ||
| 1703 | NpadButton EmulatedController::GetTurboButtonMask() const { | 1702 | NpadButton EmulatedController::GetTurboButtonMask() const { |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 6e01f4e12..fa4ad7fae 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -415,8 +415,8 @@ public: | |||
| 415 | */ | 415 | */ |
| 416 | void DeleteCallback(int key); | 416 | void DeleteCallback(int key); |
| 417 | 417 | ||
| 418 | /// Swaps the state of the turbo buttons | 418 | /// Swaps the state of the turbo buttons and updates motion input |
| 419 | void TurboButtonUpdate(); | 419 | void StatusUpdate(); |
| 420 | 420 | ||
| 421 | private: | 421 | private: |
| 422 | /// creates input devices from params | 422 | /// creates input devices from params |
| @@ -528,7 +528,6 @@ private: | |||
| 528 | bool is_configuring{false}; | 528 | bool is_configuring{false}; |
| 529 | bool system_buttons_enabled{true}; | 529 | bool system_buttons_enabled{true}; |
| 530 | f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; | 530 | f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; |
| 531 | bool force_update_motion{false}; | ||
| 532 | u32 turbo_button_state{0}; | 531 | u32 turbo_button_state{0}; |
| 533 | 532 | ||
| 534 | // Temporary values to avoid doing changes while the controller is in configuring mode | 533 | // Temporary values to avoid doing changes while the controller is in configuring mode |
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 53b00b1f9..4ccb1c596 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -86,7 +86,7 @@ Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatu | |||
| 86 | .range = 1.0f, | 86 | .range = 1.0f, |
| 87 | .offset = 0.0f, | 87 | .offset = 0.0f, |
| 88 | }; | 88 | }; |
| 89 | status.delta_timestamp = 5000; | 89 | status.delta_timestamp = 1000; |
| 90 | status.force_update = true; | 90 | status.force_update = true; |
| 91 | status.accel.x = { | 91 | status.accel.x = { |
| 92 | .value = 0.0f, | 92 | .value = 0.0f, |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 8abf71608..ef4aec4ea 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -423,8 +423,8 @@ void Controller_NPad::RequestPadStateUpdate(Core::HID::NpadIdType npad_id) { | |||
| 423 | return; | 423 | return; |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | // This function is unique to yuzu for the turbo buttons to work properly | 426 | // This function is unique to yuzu for the turbo buttons and motion to work properly |
| 427 | controller.device->TurboButtonUpdate(); | 427 | controller.device->StatusUpdate(); |
| 428 | 428 | ||
| 429 | auto& pad_entry = controller.npad_pad_state; | 429 | auto& pad_entry = controller.npad_pad_state; |
| 430 | auto& trigger_entry = controller.npad_trigger_state; | 430 | auto& trigger_entry = controller.npad_trigger_state; |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 5c2c4a463..380a01542 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -667,7 +667,7 @@ public: | |||
| 667 | .raw_value = input_engine->GetAxis(identifier, axis_z), | 667 | .raw_value = input_engine->GetAxis(identifier, axis_z), |
| 668 | .properties = properties_z, | 668 | .properties = properties_z, |
| 669 | }; | 669 | }; |
| 670 | status.delta_timestamp = 5000; | 670 | status.delta_timestamp = 1000; |
| 671 | status.force_update = true; | 671 | status.force_update = true; |
| 672 | return status; | 672 | return status; |
| 673 | } | 673 | } |