gameinput: preserve controller transitions between polls (OLD-9966, carries #233) #1831

Merged
potatoe0100 merged 4 commits from upstream-pr/1831 into main 2026-11-29 15:42:49 +00:00
potatoe0100 commented 2026-11-25 12:45:44 +00:00 (Migrated from github.com)

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 on main 0d80bc5df with 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.cpp conflicted in poll_once(), where main added the LEONIDA_INPUT_LOG press log. The branch moves reading publication into publish_pad_sample(); the press log moved there with it (before last_snap is 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 (so gameinput and gameinput_script are built and run, not Disabled).

  • gameinput and gameinput_script pass.
  • Full 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

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5491587755 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1831). Originally posted by [potatoe0100](https://github.com/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 on `main` `0d80bc5df` with 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.cpp` conflicted in `poll_once()`, where `main` added the `LEONIDA_INPUT_LOG` press log. The branch moves reading publication into `publish_pad_sample()`; the press log moved there with it (before `last_snap` is 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` (so `gameinput` and `gameinput_script` are built and run, not Disabled). - `gameinput` and `gameinput_script` pass. - Full `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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
OreoFR commented 2026-11-28 21:54:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:54:36Z.


Verified by OreoFR

Run 1 (nat04)

  • Base: main c1ecf04ed + PR head 9a96b8ba6 (tested at 9a96b8ba6, head is now 2f99fd2ca); green run in a merge package of 15 PRs, no new ctest failure vs main
  • Test: ctest -R "^gameinput(_script)?$"
  • Red on main: gameinput fails (2 FAIL: buffered input, short A/trigger press and release lost)
  • Green with the PR: gameinput and gameinput_script OK
  • Verdict: READY (shares files with #1559: tested in separate packages; whichever merges second needs a rebase check)

Run 2 (lot 4)

  • Base: main 09c153948 + PR head 9a96b8ba6 (tested at 9a96b8ba6, head is now 2f99fd2ca); integration package 2 of 6 (4 PRs, merged without conflict)
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests
  • Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps)
  • Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main
  • Verdict: CLEAN PACKAGE (no new failure vs main)

Run 3 (lot 4 bis)

  • Base: main 33db04a70 + PR head 9a96b8ba6 (tested at 9a96b8ba6, head is now 2f99fd2ca); integration package of 15 PRs
  • Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests; translator suite
  • Red on main: n/a (integration test; main baseline: xbox_present, and flaky xmem)
  • Green with the PR: ctest: only xbox_present fails as on main (xs_proxy_mock failed once, flaky: passes on rerun and 5/5 direct runs); Python: same failures as main, the PRs' tests pass; translator: 507 files, 6405 tests, 0 failures
  • Verdict: CLEAN PACKAGE (no new failure vs main)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246361286 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1831#issuecomment-7246361286). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:54:36Z. --- **Verified by OreoFR** **Run 1 (nat04)** - Base: main `c1ecf04ed` + PR head `9a96b8ba6` (tested at `9a96b8ba6`, head is now `2f99fd2ca`); green run in a merge package of 15 PRs, no new ctest failure vs main - Test: `ctest -R "^gameinput(_script)?$"` - Red on main: gameinput fails (2 FAIL: buffered input, short A/trigger press and release lost) - Green with the PR: gameinput and gameinput_script OK - Verdict: READY (shares files with #1559: tested in separate packages; whichever merges second needs a rebase check) **Run 2 (lot 4)** - Base: main `09c153948` + PR head `9a96b8ba6` (tested at `9a96b8ba6`, head is now `2f99fd2ca`); integration package 2 of 6 (4 PRs, merged without conflict) - Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests - Red on main: n/a (integration test; main baseline: xbox_present and d3d12_set_descriptor_heaps) - Green with the PR: ctest: only xbox_present and d3d12_set_descriptor_heaps fail, as on main - Verdict: CLEAN PACKAGE (no new failure vs main) **Run 3 (lot 4 bis)** - Base: main `33db04a70` + PR head `9a96b8ba6` (tested at `9a96b8ba6`, head is now `2f99fd2ca`); integration package of 15 PRs - Test: full runtime build; ctest -j 6 without the 28 tests that launch gta6rt; the PRs' Python tests; translator suite - Red on main: n/a (integration test; main baseline: xbox_present, and flaky xmem) - Green with the PR: ctest: only xbox_present fails as on main (xs_proxy_mock failed once, flaky: passes on rerun and 5/5 direct runs); Python: same failures as main, the PRs' tests pass; translator: 507 files, 6405 tests, 0 failures - Verdict: CLEAN PACKAGE (no new failure vs main) **All runs** - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 23:25:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:25:44Z.


Windows 11 Native Verification Report (2f99fd2cae merged onto origin/main adfb3821a2)

  • Merge Status: Clean merge onto origin/main (adfb3821a2) and clean 3-way runtime/shims/gameinput.cpp merge alongside #1790 and #1528.
  • Environment: Windows 11 (10.0.26200, x64), MSVC 19.44.35228, prebuilt SDL 3.4.20 (SDL3-static.lib), Python 3.12.10.

Diff Audit (3 files, +154/-66)

  • runtime/shims/gameinput.cpp:
    • After SDL_InitSubSystem(SDL_INIT_GAMEPAD) and SDL_SetGamepadEventsEnabled(false), re-enables SDL_EVENT_GAMEPAD_AXIS_MOTION, SDL_EVENT_GAMEPAD_BUTTON_DOWN, and SDL_EVENT_GAMEPAD_BUTTON_UP.
    • take_pad_events() flushes SDL_EVENT_JOYSTICK_AXIS_MOTION..SDL_EVENT_JOYSTICK_UPDATE_COMPLETE (0x600..0x608) and SDL_EVENT_GAMEPAD_ADDED..SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED (0x653..0x65B) before draining 0x650..0x652 with SDL_PeepEvents. Audited against SDL 3.4.20's SDL_gamepad.c and SDL_events.h: flushing 0x653..0x65B also drains SDL_EVENT_GAMEPAD_UPDATE_COMPLETE (0x65A) and SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED (0x65B), which SDL3 omits from SDL_SetGamepadEventsEnabled(false)'s SDL_gamepad_event_list, preventing unbounded accumulation toward SDL_MAX_QUEUED_EVENTS (65535).
    • replay_pad_events() groups intermediate samples per previously open pad by e.common.timestamp, publishes them to the reading history and reading/Guide callbacks, and preserves last_reading_us before replaying so the ~125 Hz idle motion_tick cadence on sensor-equipped pads remains unchanged.
  • runtime/test/gameinput_test.cpp & docs/gameinput.md: adds test_buffered_gamepad_input and documents intermediate SDL sample grouping.

Red -> Green Verification

  1. Red (origin/main adfb3821a2):
    • #1831's runtime/test/gameinput_test.cpp compiled against origin/main gameinput.cpp exited 1:
      • FAIL buffered input: history delivers both the short A/trigger press and its release
      • FAIL buffered input: two callbacks fire and the current reading stays released
  2. Green (#1831 + origin/main):
    • gameinput_test.exe (/O2 /MD /EHsc /W4 /permissive- /utf-8, SDL 3.4.20, 0 new warnings): 392 checks, 0 failures (4.20 s, rc=0), passing all three buffered input assertions.
    • Combined merge (#1790 + #1528 + #1831 + origin/main) gameinput_test.exe: 393 checks, 0 failures (4.06 s, rc=0).
    • Documentation gates: tests/test_docs_links.py, tests/test_docs_table_rows.py, and tests/test_docs_encoding.py all passed (OK, rc=0).

Verdict: PASS — ready to merge.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247424056 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1831#issuecomment-7247424056). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T23:25:44Z. --- ### Windows 11 Native Verification Report (`2f99fd2cae` merged onto `origin/main` `adfb3821a2`) - **Merge Status**: Clean merge onto `origin/main` (`adfb3821a2`) and clean 3-way `runtime/shims/gameinput.cpp` merge alongside `#1790` and `#1528`. - **Environment**: Windows 11 (`10.0.26200`, x64), MSVC `19.44.35228`, prebuilt SDL `3.4.20` (`SDL3-static.lib`), Python `3.12.10`. #### Diff Audit (`3` files, `+154/-66`) - `runtime/shims/gameinput.cpp`: - After `SDL_InitSubSystem(SDL_INIT_GAMEPAD)` and `SDL_SetGamepadEventsEnabled(false)`, re-enables `SDL_EVENT_GAMEPAD_AXIS_MOTION`, `SDL_EVENT_GAMEPAD_BUTTON_DOWN`, and `SDL_EVENT_GAMEPAD_BUTTON_UP`. - `take_pad_events()` flushes `SDL_EVENT_JOYSTICK_AXIS_MOTION..SDL_EVENT_JOYSTICK_UPDATE_COMPLETE` (`0x600..0x608`) and `SDL_EVENT_GAMEPAD_ADDED..SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED` (`0x653..0x65B`) before draining `0x650..0x652` with `SDL_PeepEvents`. Audited against SDL `3.4.20`'s `SDL_gamepad.c` and `SDL_events.h`: flushing `0x653..0x65B` also drains `SDL_EVENT_GAMEPAD_UPDATE_COMPLETE` (`0x65A`) and `SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED` (`0x65B`), which SDL3 omits from `SDL_SetGamepadEventsEnabled(false)`'s `SDL_gamepad_event_list`, preventing unbounded accumulation toward `SDL_MAX_QUEUED_EVENTS` (`65535`). - `replay_pad_events()` groups intermediate samples per previously open pad by `e.common.timestamp`, publishes them to the reading history and reading/Guide callbacks, and preserves `last_reading_us` before replaying so the ~125 Hz idle `motion_tick` cadence on sensor-equipped pads remains unchanged. - `runtime/test/gameinput_test.cpp` & `docs/gameinput.md`: adds `test_buffered_gamepad_input` and documents intermediate SDL sample grouping. #### Red -> Green Verification 1. **Red (`origin/main` `adfb3821a2`)**: - `#1831`'s `runtime/test/gameinput_test.cpp` compiled against `origin/main` `gameinput.cpp` exited `1`: - `FAIL buffered input: history delivers both the short A/trigger press and its release` - `FAIL buffered input: two callbacks fire and the current reading stays released` 2. **Green (`#1831` + `origin/main`)**: - `gameinput_test.exe` (`/O2 /MD /EHsc /W4 /permissive- /utf-8`, SDL `3.4.20`, `0` new warnings): **`392 checks, 0 failures`** (`4.20 s`, `rc=0`), passing all three `buffered input` assertions. - Combined merge (`#1790 + #1528 + #1831 + origin/main`) `gameinput_test.exe`: **`393 checks, 0 failures`** (`4.06 s`, `rc=0`). - Documentation gates: `tests/test_docs_links.py`, `tests/test_docs_table_rows.py`, and `tests/test_docs_encoding.py` all passed (`OK`, `rc=0`). **Verdict**: **PASS** — ready to merge. AI-assisted.
MoonEyes commented 2026-11-29 15:42:52 +00:00 (Migrated from github.com)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7258307436 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1831#issuecomment-7258307436). Originally posted by [MoonEyes](https://github.com/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
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1831
No description provided.