gameinput: preserve controller transitions between polls (OLD-9966, carries #233) #1831
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1831"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T12:45:44Z.
Claimed in the coordination issue as: OLD-9966 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162810670)
What and why
Carries forward
old-pr/9966(draft #233) by @tedin7, rebased onmain0d80bc5dfwith the author's commit. A press and release that both land between two polls used to be lost, because each poll only compared the latest snapshot. Pads that were already open replay their SDL button and axis events in timestamp groups, publishing one reading per group, so the title sees each transition.Rebase notes:
runtime/shims/gameinput.cppconflicted inpoll_once(), wheremainadded theLEONIDA_INPUT_LOGpress log. The branch moves reading publication intopublish_pad_sample(); the press log moved there with it (beforelast_snapis updated), so replayed transitions are logged too.Supersedes draft #233 (its branch can be deleted once this lands).
Tested
VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja with
-DLEONIDA_SDL3_FETCH=ON(sogameinputandgameinput_scriptare built and run, not Disabled).gameinputandgameinput_scriptpass.ctest -j 6: 440 of 440 passed.GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300) (no GPU-specific code here)
AI-assisted: yes (Claude Code), by a non-developer tester.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:54:36Z.
Verified by OreoFR
Run 1 (nat04)
c1ecf04ed+ PR head9a96b8ba6(tested at9a96b8ba6, head is now2f99fd2ca); green run in a merge package of 15 PRs, no new ctest failure vs mainctest -R "^gameinput(_script)?$"Run 2 (lot 4)
09c153948+ PR head9a96b8ba6(tested at9a96b8ba6, head is now2f99fd2ca); integration package 2 of 6 (4 PRs, merged without conflict)Run 3 (lot 4 bis)
33db04a70+ PR head9a96b8ba6(tested at9a96b8ba6, head is now2f99fd2ca); integration package of 15 PRsAll runs
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:25:44Z.
Windows 11 Native Verification Report (
2f99fd2caemerged ontoorigin/mainadfb3821a2)origin/main(adfb3821a2) and clean 3-wayruntime/shims/gameinput.cppmerge alongside#1790and#1528.10.0.26200, x64), MSVC19.44.35228, prebuilt SDL3.4.20(SDL3-static.lib), Python3.12.10.Diff Audit (
3files,+154/-66)runtime/shims/gameinput.cpp:SDL_InitSubSystem(SDL_INIT_GAMEPAD)andSDL_SetGamepadEventsEnabled(false), re-enablesSDL_EVENT_GAMEPAD_AXIS_MOTION,SDL_EVENT_GAMEPAD_BUTTON_DOWN, andSDL_EVENT_GAMEPAD_BUTTON_UP.take_pad_events()flushesSDL_EVENT_JOYSTICK_AXIS_MOTION..SDL_EVENT_JOYSTICK_UPDATE_COMPLETE(0x600..0x608) andSDL_EVENT_GAMEPAD_ADDED..SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED(0x653..0x65B) before draining0x650..0x652withSDL_PeepEvents. Audited against SDL3.4.20'sSDL_gamepad.candSDL_events.h: flushing0x653..0x65Balso drainsSDL_EVENT_GAMEPAD_UPDATE_COMPLETE(0x65A) andSDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED(0x65B), which SDL3 omits fromSDL_SetGamepadEventsEnabled(false)'sSDL_gamepad_event_list, preventing unbounded accumulation towardSDL_MAX_QUEUED_EVENTS(65535).replay_pad_events()groups intermediate samples per previously open pad bye.common.timestamp, publishes them to the reading history and reading/Guide callbacks, and preserveslast_reading_usbefore replaying so the ~125 Hz idlemotion_tickcadence on sensor-equipped pads remains unchanged.runtime/test/gameinput_test.cpp&docs/gameinput.md: addstest_buffered_gamepad_inputand documents intermediate SDL sample grouping.Red -> Green Verification
origin/mainadfb3821a2):#1831'sruntime/test/gameinput_test.cppcompiled againstorigin/maingameinput.cppexited1:FAIL buffered input: history delivers both the short A/trigger press and its releaseFAIL buffered input: two callbacks fire and the current reading stays released#1831+origin/main):gameinput_test.exe(/O2 /MD /EHsc /W4 /permissive- /utf-8, SDL3.4.20,0new warnings):392 checks, 0 failures(4.20 s,rc=0), passing all threebuffered inputassertions.#1790 + #1528 + #1831 + origin/main)gameinput_test.exe:393 checks, 0 failures(4.06 s,rc=0).tests/test_docs_links.py,tests/test_docs_table_rows.py, andtests/test_docs_encoding.pyall passed (OK,rc=0).Verdict: PASS — ready to merge.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T15:42:52Z.
Merged. Tested by @zmasi on head
2f99fd2ca(CPU only (Windows 11 x64, SDL 3.4.20)): red: gameinput_test vs main gameinput.cpp fails 2 buffered-input checks; green 392 checks 0 failures. The CI jobs that are red on this head were also red on main at the time of the run. Thanks @potatoe0100!AI-assisted: yes