From 02ec00bd389071f6f60f931bacd192d0e1eec160 Mon Sep 17 00:00:00 2001 From: leviathan Date: Tue, 4 Aug 2026 15:16:31 -0700 Subject: improved default dead-zone on auto-calibration --- indra/llwindow/llgamecontrol.cpp | 4 ++-- indra/llwindow/llgamecontrol.h | 4 ++-- indra/newview/llpanelpreferencegamecontrol.cpp | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/indra/llwindow/llgamecontrol.cpp b/indra/llwindow/llgamecontrol.cpp index c989043f76..bb8914a2e0 100755 --- a/indra/llwindow/llgamecontrol.cpp +++ b/indra/llwindow/llgamecontrol.cpp @@ -954,7 +954,7 @@ S16 LLGameControl::Options::AxisOptions::computeModifiedValue(S16 raw_value) con void LLGameControl::Options::AxisOptions::resetToDefaults() { mMultiplier = 1; - mDeadZone = DEFAULT_DEAD_ZONE; + mDeadZone = DEFAULT_AXIS_DEAD_ZONE; mOffset = 0; } @@ -1056,7 +1056,7 @@ std::string LLGameControl::Options::AxisOptions::saveToString() const { options.push_back("invert:1"); } - if (mDeadZone != DEFAULT_DEAD_ZONE) + if (mDeadZone != DEFAULT_AXIS_DEAD_ZONE) { options.push_back(llformat("dead_zone:%u", mDeadZone)); } diff --git a/indra/llwindow/llgamecontrol.h b/indra/llwindow/llgamecontrol.h index a7e62f4fcd..2bb22836a1 100644 --- a/indra/llwindow/llgamecontrol.h +++ b/indra/llwindow/llgamecontrol.h @@ -272,7 +272,7 @@ public: // Default dead zone applied to a freshly-constructed / reset axis // is nonzero because most controllers have a bit of hysteresis or offset. - static constexpr U16 DEFAULT_DEAD_ZONE = 1024; + static constexpr U16 DEFAULT_AXIS_DEAD_ZONE = 2048; class InputChannel { @@ -314,7 +314,7 @@ public: struct AxisOptions { S32 mMultiplier = 1; - U16 mDeadZone { DEFAULT_DEAD_ZONE }; + U16 mDeadZone { DEFAULT_AXIS_DEAD_ZONE }; S16 mOffset { 0 }; void resetToDefaults(); diff --git a/indra/newview/llpanelpreferencegamecontrol.cpp b/indra/newview/llpanelpreferencegamecontrol.cpp index a16815d8c4..0c73b7a10e 100755 --- a/indra/newview/llpanelpreferencegamecontrol.cpp +++ b/indra/newview/llpanelpreferencegamecontrol.cpp @@ -1975,10 +1975,8 @@ void LLPanelPreferenceGameControl::updateAutoCalibration() continue; } - S32 offset = std::clamp(-(S32)samples[0], - -LLGameControl::MAX_AXIS_OFFSET, LLGameControl::MAX_AXIS_OFFSET); - S32 dead_zone = (S32)(2.1 * (double)offset); - dead_zone = std::clamp(dead_zone < 0 ? -dead_zone : dead_zone, 0, LLGameControl::MAX_AXIS_DEAD_ZONE); + S32 offset = std::clamp(-(S32)samples[0], -(S32)(LLGameControl::MAX_AXIS_OFFSET), (S32)(LLGameControl::MAX_AXIS_OFFSET)); + S32 dead_zone = std::clamp(2 * std::abs(offset), (S32)(LLGameControl::DEFAULT_AXIS_DEAD_ZONE), (S32)(LLGameControl::MAX_AXIS_DEAD_ZONE)); LLGameControl::Options::AxisOptions& axis_options = all_axis_options[i]; axis_options.mOffset = (S16)offset; -- cgit v1.3