gameinput: preserve controller transitions between polls #233

Closed
Andretuta wants to merge 1 commit from upstream-pr/233 into main
Andretuta commented 2026-11-24 02:50:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:50:27Z.


Carried over from old PR 9966 by tedin7 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9966, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
tedin7: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

@ItsNotRexed: an exe PR, as you asked.

What

The GameInput shim now keeps button and axis changes that happen between two polls. Each poll drains SDL's gamepad button and axis events; for each connected pad, events with the same SDL timestamp form one sample. Intermediate samples go into the reading history and to reading/Guide callbacks, and the final reading still comes from the current pad snapshot (so motion and raw HID state are unchanged). GameInput timestamps still record when the shim polled. docs/gameinput.md describes the behaviour and drops the old "a change shorter than one poll is not seen" caveat.

Why

The shim read the pad's state once per poll, so a short press (a button tapped and released, or a trigger pulled and let go) between two polls never reached the history or a callback and the title missed the input.

Tested

Built locally with clang-cl 19 + lld-link against the xwin SDK and SDL3 3.4.20 (static), run under Wine: gameinput_test.exe.

  • With the change: 366 checks, 0 failures.
  • Negative control (same test, gameinput.cpp from origin/main): 366 checks, 2 failures (both new checks: "history delivers both the short A/trigger press and its release", "two callbacks fire and the current reading stays released").
  • New test: test_buffered_gamepad_input, 42 lines in runtime/test/gameinput_test.cpp. It presses A and the left trigger on a virtual pad, releases them before the next shim poll, and checks the history holds both the press and the release, two callbacks fire, and the current reading is the released one.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465155972 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/233). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:50:27Z. --- > Carried over from **old PR 9966** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9966`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `tedin7`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): `@ItsNotRexed`: an exe PR, as you asked. ## What The GameInput shim now keeps button and axis changes that happen between two polls. Each poll drains SDL's gamepad button and axis events; for each connected pad, events with the same SDL timestamp form one sample. Intermediate samples go into the reading history and to reading/Guide callbacks, and the final reading still comes from the current pad snapshot (so motion and raw HID state are unchanged). GameInput timestamps still record when the shim polled. `docs/gameinput.md` describes the behaviour and drops the old "a change shorter than one poll is not seen" caveat. ## Why The shim read the pad's state once per poll, so a short press (a button tapped and released, or a trigger pulled and let go) between two polls never reached the history or a callback and the title missed the input. ## Tested Built locally with clang-cl 19 + lld-link against the xwin SDK and SDL3 3.4.20 (static), run under Wine: `gameinput_test.exe`. - With the change: `366 checks, 0 failures`. - Negative control (same test, `gameinput.cpp` from origin/main): `366 checks, 2 failures` (both new checks: "history delivers both the short A/trigger press and its release", "two callbacks fire and the current reading stays released"). - New test: `test_buffered_gamepad_input`, 42 lines in `runtime/test/gameinput_test.cpp`. It presses A and the left trigger on a virtual pad, releases them before the next shim poll, and checks the history holds both the press and the release, two callbacks fire, and the current reading is the released one.
MoonEyes commented 2026-11-28 07:08:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T07:08:34Z.


Thanks a lot for this, @Andretuta. We checked and this pull request is a draft that #1831 states it supersedes (same three files); the kept one is #1831. To keep the queue clear and avoid reviewing the same change twice, I am closing this one in favour of #1831. If you think this is a mistake, please reopen it and let us know.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235743352 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/233#issuecomment-7235743352). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T07:08:34Z. --- Thanks a lot for this, @Andretuta. We checked and this pull request is a draft that #1831 states it supersedes (same three files); the kept one is #1831. To keep the queue clear and avoid reviewing the same change twice, I am closing this one in favour of #1831. If you think this is a mistake, please reopen it and let us know. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

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!233
No description provided.