Repository navigation
gameinput: a NaN LEONIDA_MOUSE_SENSITIVITY or LEONIDA_DS_TRIGGER_GAIN keeps the default instead of disabling mouse aim or the trigger effects - #8495
Open
MartinIndra02 wants to merge 1 commit into
Conversation
read_config read LEONIDA_MOUSE_SENSITIVITY and LEONIDA_DS_TRIGGER_GAIN with atof and std::clamp. NaN compares false, so "nan" passed the clamp unchanged, and every product with it was NaN as well. With MSVC, lround(NaN) is 0: a NaN sensitivity stopped the mouse from moving the keyboard pad's right stick, and a NaN gain turned the DualSense trigger effects off. Both now go through read_float, which logs a value that is not a number and keeps the default. Numbers, infinities included, are clamped as before. gameinput_test sets "nan", "-nan" and "NAN(ind)" and checks both defaults, and that the mouse moves the stick as far as it does at the default sensitivity. docs/gameinput.md notes it in the two table rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
abnalstlll-byte
approved these changes
Nov 23, 2026
abnalstlll-byte
left a comment
Contributor
There was a problem hiding this comment.
Audited full diff (\c9ccbd64) on Windows 11 (\docs/gameinput.md,
untime/shims/gameinput.cpp,
untime/test/gameinput_test.cpp; \compileall\ & \git diff --check\ clean).
Guarding
ead_float\ with \std::isnan(v)\ before \std::clamp\ cleanly logs non-numeric inputs and preserves default values, preventing MSVC \lround(NaN)\ stick zeroing and trigger gain collapse. Synthetic regression tests cover
an, -nan, and \NAN(ind). No game files. AI-assisted review (Gemini).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: #8344 (comment) (symptom corrected in #8344 (comment))
Depends on: none
What and why
read_config(runtime/shims/gameinput.cpp:155) readLEONIDA_MOUSE_SENSITIVITYandLEONIDA_DS_TRIGGER_GAINasstd::clamp(static_cast<float>(std::atof(text)), lo, hi). NaN compares false against both bounds, sonan(also-nanandnan(ind)) passed the clamp unchanged. Every product with it was then NaN, and with MSVC,std::lround(NaN)is 0 (I measured this). The results:LEONIDA_MOUSE_SENSITIVITY=nan:update_keyboard_padaddedlround(pixels * 1024 * NaN)= 0, so the mouse never moved the keyboard pad's right stick.LEONIDA_DS_TRIGGER_GAIN=nan:ds_effectcomputed a level of 0, so the DualSense trigger effects were always off.Both variables now go through a small
read_floathelper (gameinput.cpp:144). A value that is not a number is logged ([rt] gameinput: LEONIDA_MOUSE_SENSITIVITY=nan is not a number, using 1) and the default is kept, asread_configalready does for unknownLEONIDA_DS_TRIGGERS,LEONIDA_KEYBOARD_PADandLEONIDA_PROMPTSvalues. Numbers, infinities included, are clamped to the same ranges as before.docs/gameinput.mdsays so in the two table rows.This doesn't touch
SetHapticMotorState(#8310), force feedback (#7777, #7815, #7385), keyboard and mouse devices (#8283), or the readings and callbacks.Tested
Windows 11 x64, MSVC 19.44.35220, NVIDIA GeForce RTX 3080 (driver 621.24 / 32.0.16.2124). RelWithDebInfo, Ninja,
-DLEONIDA_SDL3_FETCH=ON. Synthetic tests only.gameinput_test: the new check setsnan,-nanandNAN(ind)for both variables. It expects both defaults (1), and that a 10-count mouse move gives the stick the default sensitivity's distance (10240/32767).348 checks, 6 failures. Each value failskeyboard pad: a NaN mouse sensitivity or trigger gain keeps the default 1andkeyboard pad: with a NaN sensitivity the mouse moves the stick as with the default.348 checks, 0 failures(the whole executable, rebased on currentmain).python -I scripts/check_no_game_data.py runtime/shims/gameinput.cpp runtime/test/gameinput_test.cpp docs/gameinput.mdandgit diff --check: clean.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code