You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GameInput: accept zero-valued motion samples after both sensors report (RT-348) - #4967
SDL's sensor cache starts at zero. The GameInput shim used a nonzero accelerometer axis as evidence that the sensors were ready. This discarded a valid gyroscope reading at zero acceleration and exposed motion early if only the accelerometer had reported.
The shim now observes the first accelerometer and gyroscope update for each connected controller. Once every motion-capable pad has supplied both, it disables sensor events and continues polling SDL's cached values at the existing cadence. Reconnecting a pad starts it with fresh readiness even when GameInput reuses its device object.
Tested
Built the Windows x64 Release runtime with MSVC 19.44 and SDL 3.4.20. The tests used SDL virtual controllers. No physical controller, GPU or game data was involved.
With the new regression on upstream 3faac55, five checks failed. They cover the initial all-zero pair, a return to zero, a gyro-only change with zero acceleration at the normal polling cadence, an incomplete pair, and rotation after reconnect.
With the fix, all 338 GameInput checks passed. Both gameinput and active_input passed five consecutive CTest runs. All six documentation link checks passed.
A separate two-pad probe passed 31 checks, including samples arriving on different device IDs, a ready pad continuing to publish while another waits for its second sensor, and reconnecting one pad.
Verified at head 0fc46fa (clean merge vs origin/main): gameinput_test 338 checks / 0 failures; ctest gameinput 4/4 runs plus active_input; doc-link tests pass. Negative control on 3faac557 gives 337 checks / 5 failures, exactly as claimed. SDL 3.4.20 source confirms the path: SDL_UpdateGamepads -> SDL_UpdateJoysticks (SDL_gamepad.c:3412) pushes sensor events gated only by SDL_EventEnabled (SDL_joystick.c:3855), so there is no pump or GamepadEventsEnabled dependency.
Caveats:
Readiness still depends on the event queue: a title that pumps SDL (SDL_PollEvent) or disables that event type will starve it and get silent no-motion (gameinput.cpp:1341,1880,1895).
The shim consumes/disables those events process-wide, so it can affect other SDL consumers in the same process.
A pad that never delivers one sensor keeps the events on (drained per poll, minor CPU).
Environment: Windows 11, MSVC 19.44 (RelWithDebInfo, Ninja), CPU only. Built gameinput_test with -DLEONIDA_SDL3_FETCH=ON (pinned SDL3 3.4.20, hash-checked, static) — the shim's SDL virtual-joystick path, no real controller or game files needed.
PR head → 338 checks, 0 failures (full run incl. raw-HID report cases)
Negative control: same test binary against main's gameinput.cpp → 337 checks, 5 failures — the zero-valued motion samples after both sensors report are rejected on the parent, accepted on the head, exactly per RT-348
AI-assisted (Devin).
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
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 as RT-348. Related to #660.
What and why
SDL's sensor cache starts at zero. The GameInput shim used a nonzero accelerometer axis as evidence that the sensors were ready. This discarded a valid gyroscope reading at zero acceleration and exposed motion early if only the accelerometer had reported.
The shim now observes the first accelerometer and gyroscope update for each connected controller. Once every motion-capable pad has supplied both, it disables sensor events and continues polling SDL's cached values at the existing cadence. Reconnecting a pad starts it with fresh readiness even when GameInput reuses its device object.
Tested
3faac55, five checks failed. They cover the initial all-zero pair, a return to zero, a gyro-only change with zero acceleration at the normal polling cadence, an incomplete pair, and rotation after reconnect.gameinputandactive_inputpassed five consecutive CTest runs. All six documentation link checks passed.0250734; the combined GameInput executable passed all 341 checks.AI-assisted with Codex.