diff options
| author | Duck912 <350528965+Duck912@users.noreply.github.com> | 2026-11-02 18:56:59 -0500 |
|---|---|---|
| committer | Duck912 <350528965+Duck912@users.noreply.github.com> | 2026-11-02 18:56:59 -0500 |
| commit | 9acd36eb9a291e0631346f5b17d69d0e8eb26cc5 (patch) | |
| tree | 5142f9867928a2e7f07a6b6b79ca00fa5f900425 /src/input_common/drivers/sdl_driver.cpp | |
| parent | 11cebf56014a5015db28179a8acc81cad0caf641 (diff) | |
| parent | 2d81fd5072c060737c18ed4cfc46a04fb8cbb94c (diff) | |
Merge remote-tracking branch 'origin/nx2' into fe-fsr31
# Conflicts:
# src/video_core/renderer_vulkan/blit_image.cpp
# src/video_core/renderer_vulkan/blit_image.h
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index c3e9a066b3..a308554071 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -3,6 +3,7 @@ // SPDX-FileCopyrightText: 2018 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include <algorithm> #include <array> #include <numbers> #include "common/logging.h" @@ -115,7 +116,15 @@ public: } } - LOG_INFO(Input, "Controller motion capabilities: accel={} gyro={}", has_accel, has_gyro); + // EnableMotion is also called to recover a stalled sensor, so only log when the reported + // capabilities actually change instead of on every restart. + if (!motion_capabilities_logged || logged_accel != has_accel || logged_gyro != has_gyro) { + LOG_INFO(Input, "Controller motion capabilities: accel={} gyro={}", has_accel, + has_gyro); + motion_capabilities_logged = true; + logged_accel = has_accel; + logged_gyro = has_gyro; + } } bool HasMotion() const { @@ -163,16 +172,21 @@ public: // Motion data is invalid if (motion.accel_x == 0 && motion.gyro_x == 0 && motion.accel_y == 0 && motion.gyro_y == 0 && motion.accel_z == 0 && motion.gyro_z == 0) { - if (motion_error_count++ < 200) { + if (motion_error_count++ < motion_restart_threshold) { return false; } - // Try restarting the sensor + // Try restarting the sensor. Back off exponentially so a sensor that keeps reporting + // zeros (observed on the Steam Deck) isn't toggled several times a + // second for the whole session. motion_error_count = 0; + motion_restart_threshold = + std::min(motion_restart_threshold * 2, MaxMotionRestartThreshold); EnableMotion(); return false; } motion_error_count = 0; + motion_restart_threshold = InitialMotionRestartThreshold; motion.delta_timestamp = time_difference; return true; } @@ -393,7 +407,13 @@ private: mutable std::mutex mutex; u64 last_motion_update{}; + static constexpr std::size_t InitialMotionRestartThreshold = 200; + static constexpr std::size_t MaxMotionRestartThreshold = 200 * 64; std::size_t motion_error_count{}; + std::size_t motion_restart_threshold{InitialMotionRestartThreshold}; + bool motion_capabilities_logged{false}; + bool logged_accel{false}; + bool logged_gyro{false}; bool has_gyro{false}; bool has_accel{false}; bool has_vibration{false}; |
