summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-05-08 01:06:10 +0200
committerGitHub <noreply@github.com>2023-05-08 01:06:10 +0200
commit8f605b542cf8cc1145364095d7af5b9af5c109c4 (patch)
tree0a9d3093c5729001ae0937db07b6a847feb6da13
parentMerge pull request #10155 from FernandoS27/reactive-flushing-new (diff)
parentcore: hid: Update motion on a better place (diff)
downloadyuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar.gz
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar.bz2
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar.lz
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar.xz
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.tar.zst
yuzu-8f605b542cf8cc1145364095d7af5b9af5c109c4.zip
-rw-r--r--src/core/hid/emulated_controller.cpp29
-rw-r--r--src/core/hid/emulated_controller.h5
-rw-r--r--src/core/hid/input_converter.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp4
-rw-r--r--src/input_common/input_poller.cpp2
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
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 {
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:
*/
void DeleteCallback(int key);
- /// Swaps the state of the turbo buttons
- void TurboButtonUpdate();
+ /// Swaps the state of the turbo buttons and updates motion input
+ void StatusUpdate();
private:
/// creates input devices from params
@@ -528,7 +528,6 @@ private:
bool is_configuring{false};
bool system_buttons_enabled{true};
f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard};
- bool force_update_motion{false};
u32 turbo_button_state{0};
// 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
.range = 1.0f,
.offset = 0.0f,
};
- status.delta_timestamp = 5000;
+ status.delta_timestamp = 1000;
status.force_update = true;
status.accel.x = {
.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) {
return;
}
- // This function is unique to yuzu for the turbo buttons to work properly
- controller.device->TurboButtonUpdate();
+ // This function is unique to yuzu for the turbo buttons and motion to work properly
+ controller.device->StatusUpdate();
auto& pad_entry = controller.npad_pad_state;
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:
.raw_value = input_engine->GetAxis(identifier, axis_z),
.properties = properties_z,
};
- status.delta_timestamp = 5000;
+ status.delta_timestamp = 1000;
status.force_update = true;
return status;
}