Skip to content

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
ItsNotRexed:mainfrom
MartinIndra02:g-gameinput-nan-config
Open

MartinIndra02 wants to merge 1 commit into
ItsNotRexed:mainfrom
MartinIndra02:g-gameinput-nan-config

Conversation

@MartinIndra02

Copy link
Copy Markdown

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) read LEONIDA_MOUSE_SENSITIVITY and LEONIDA_DS_TRIGGER_GAIN as std::clamp(static_cast<float>(std::atof(text)), lo, hi). NaN compares false against both bounds, so nan (also -nan and nan(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_pad added lround(pixels * 1024 * NaN) = 0, so the mouse never moved the keyboard pad's right stick.
  • LEONIDA_DS_TRIGGER_GAIN=nan: ds_effect computed a level of 0, so the DualSense trigger effects were always off.

Both variables now go through a small read_float helper (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, as read_config already does for unknown LEONIDA_DS_TRIGGERS, LEONIDA_KEYBOARD_PAD and LEONIDA_PROMPTS values. Numbers, infinities included, are clamped to the same ranges as before. docs/gameinput.md says 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 sets nan, -nan and NAN(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).
    • Before the fix: 348 checks, 6 failures. Each value fails keyboard pad: a NaN mouse sensitivity or trigger gain keeps the default 1 and keyboard pad: with a NaN sensitivity the mouse moves the stick as with the default.
    • After the fix: 348 checks, 0 failures (the whole executable, rebased on current main).
  • python -I scripts/check_no_game_data.py runtime/shims/gameinput.cpp runtime/test/gameinput_test.cpp docs/gameinput.md and git diff --check: clean.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code

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 abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants