[PR #233] gameinput: preserve controller transitions between polls #286

Open
opened 2026-11-26 20:17:23 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/233
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9966


📝 Commits (1)

  • db3851a gameinput: preserve controller transitions between polls

📊 Changes

3 files changed (+173 additions, -80 deletions)

View changed files

📝 docs/gameinput.md (+7 -5)
📝 runtime/shims/gameinput.cpp (+124 -75)
📝 runtime/test/gameinput_test.cpp (+42 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/233 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9966` --- ### 📝 Commits (1) - [`db3851a`](https://github.com/ubiquitarianism/leonida/commit/db3851a22c49fb6e45e33305643ce524806a4bdd) gameinput: preserve controller transitions between polls ### 📊 Changes **3 files changed** (+173 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `docs/gameinput.md` (+7 -5) 📝 `runtime/shims/gameinput.cpp` (+124 -75) 📝 `runtime/test/gameinput_test.cpp` (+42 -0) </details> ### 📄 Description > 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#286
No description provided.