summaryrefslogtreecommitdiffstats
path: root/src/core/hid/motion_input.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-02-12 09:19:22 +0100
committerGitHub <noreply@github.com>2023-02-12 09:19:22 +0100
commit8b74047b1b4eac10c6152a18920d0a8e1861fecd (patch)
tree74a64e8a680771cede461bb0945fa4242deae2ed /src/core/hid/motion_input.cpp
parentMerge pull request #9746 from ameerj/ogl-msaa-texcache (diff)
parentcore: hid: Use gyro thresholds modes set by the game (diff)
downloadyuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.gz
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.bz2
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.lz
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.xz
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.zst
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.zip
Diffstat (limited to '')
-rw-r--r--src/core/hid/motion_input.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp
index b1f658e62..eef6edf4b 100644
--- a/src/core/hid/motion_input.cpp
+++ b/src/core/hid/motion_input.cpp
@@ -9,7 +9,7 @@ namespace Core::HID {
MotionInput::MotionInput() {
// Initialize PID constants with default values
SetPID(0.3f, 0.005f, 0.0f);
- SetGyroThreshold(0.007f);
+ SetGyroThreshold(ThresholdStandard);
}
void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) {
@@ -26,11 +26,11 @@ void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) {
gyro = gyroscope - gyro_bias;
// Auto adjust drift to minimize drift
- if (!IsMoving(0.1f)) {
+ if (!IsMoving(IsAtRestRelaxed)) {
gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f);
}
- if (gyro.Length() < gyro_threshold) {
+ if (gyro.Length() < gyro_threshold * user_gyro_threshold) {
gyro = {};
} else {
only_accelerometer = false;
@@ -49,6 +49,10 @@ void MotionInput::SetGyroThreshold(f32 threshold) {
gyro_threshold = threshold;
}
+void MotionInput::SetUserGyroThreshold(f32 threshold) {
+ user_gyro_threshold = threshold / ThresholdStandard;
+}
+
void MotionInput::EnableReset(bool reset) {
reset_enabled = reset;
}
@@ -208,7 +212,7 @@ void MotionInput::ResetOrientation() {
if (!reset_enabled || only_accelerometer) {
return;
}
- if (!IsMoving(0.5f) && accel.z <= -0.9f) {
+ if (!IsMoving(IsAtRestRelaxed) && accel.z <= -0.9f) {
++reset_counter;
if (reset_counter > 900) {
quat.w = 0;