[PR #39] gameinput: GetNext/PreviousReading match the reading's kind (RT-370) #92

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/5076


📝 Commits (4)

  • 0697507 gameinput: GetCurrentReading matches the reading's kind
  • 15b4924 gameinput: Next/Previous readings match the requested kind
  • 3d01620 gameinput: tighten the Motion history test's allowed outcomes
  • 12734e9 gameinput: pin both history-walk directions and the device filter

📊 Changes

3 files changed (+83 additions, -9 deletions)

View changed files

📝 docs/gameinput.md (+6 -4)
📝 runtime/shims/gameinput.cpp (+20 -4)
📝 runtime/test/gameinput_test.cpp (+57 -1)

📄 Description

Carried over from old PR 5076 by ray3242 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/5076, 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.
ray3242: 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):

Claim: RT-370, https://github.com/ItsNotRexed/Leonida/issues/5032#issuecomment-7094906009 (found by tupacfan04).

Depends on: #5053

What and why

IGameInput::GetNextReading / GetPreviousReading go through find_reading in runtime/shims/gameinput.cpp, which picked the nearest reading in history by order alone. A device can advertise GameInputKindMotion or GameInputKindRawDeviceReport before its readings actually carry that kind (#5053), so a Motion/Raw query could walk onto a plain-pad reading that has no such data. #5053 fixed this for GetCurrentReading by adding reading_matches(); this PR applies the same filter to the Next/Previous history walk. No new helper — it builds on #5053's, hence the dependency.

Tests

Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo; gameinput_test.exe on synthetic virtual pads — 350 checks, 0 failures (no game files, no GPU used).

Added the history-walk checks in test_motion (and tightened test_raw_hid): both traversal directions with a Motion filter, including the device-filtered backward walk, must return only Motion readings or READING_NOT_FOUND. This is a real negative control:

  • with this fix: GetPreviousReading returns GAMEINPUT_E_READING_NOT_FOUND (no earlier reading carries Motion) → PASS.

  • without the fix (reverting only gameinput.cpp and rebuilding): returns S_OK with a reading of kind 0x01040006 — no Motion bit → FAIL.

All pre-existing history tests (Next/Previous ordering, device filters, horizon, unplug/replug, aggregates) still pass. git diff --check clean.

No GPU or driver used (synthetic virtual gamepads). AI-assisted (OpenCode).


🔄 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/39 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/5076` --- ### 📝 Commits (4) - [`0697507`](https://github.com/ubiquitarianism/leonida/commit/069750713f74403712c0e060031dc2730eeea4a5) gameinput: GetCurrentReading matches the reading's kind - [`15b4924`](https://github.com/ubiquitarianism/leonida/commit/15b492434a8a12057d93e0f0c2929c483629be06) gameinput: Next/Previous readings match the requested kind - [`3d01620`](https://github.com/ubiquitarianism/leonida/commit/3d0162062754df9e4661a7e2e2e1fde0f0705cb3) gameinput: tighten the Motion history test's allowed outcomes - [`12734e9`](https://github.com/ubiquitarianism/leonida/commit/12734e9bc718f0044ff2cd4cc059a5caa8feecbd) gameinput: pin both history-walk directions and the device filter ### 📊 Changes **3 files changed** (+83 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/gameinput.md` (+6 -4) 📝 `runtime/shims/gameinput.cpp` (+20 -4) 📝 `runtime/test/gameinput_test.cpp` (+57 -1) </details> ### 📄 Description > Carried over from **old PR 5076** by `ray3242` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/5076`, 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. > `ray3242`: 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): Claim: RT-370, https://github.com/ItsNotRexed/Leonida/issues/5032#issuecomment-7094906009 (found by `tupacfan04`). Depends on: `#5053` ### What and why `IGameInput::GetNextReading` / `GetPreviousReading` go through `find_reading` in `runtime/shims/gameinput.cpp`, which picked the nearest reading in history by order alone. A device can advertise `GameInputKindMotion` or `GameInputKindRawDeviceReport` before its readings actually carry that kind (`#5053`), so a Motion/Raw query could walk onto a plain-pad reading that has no such data. `#5053` fixed this for `GetCurrentReading` by adding `reading_matches()`; this PR applies the same filter to the Next/Previous history walk. No new helper — it builds on `#5053`'s, hence the dependency. ### Tests Windows 11, MSVC 19.44 + Ninja, RelWithDebInfo; `gameinput_test.exe` on synthetic virtual pads — **350 checks, 0 failures** (no game files, no GPU used). Added the history-walk checks in `test_motion` (and tightened `test_raw_hid`): both traversal directions with a Motion filter, including the device-filtered backward walk, must return only Motion readings or `READING_NOT_FOUND`. This is a real negative control: - **with this fix**: `GetPreviousReading` returns `GAMEINPUT_E_READING_NOT_FOUND` (no earlier reading carries Motion) → PASS. - **without the fix** (reverting only `gameinput.cpp` and rebuilding): returns `S_OK` with a reading of kind `0x01040006` — no Motion bit → FAIL. All pre-existing history tests (Next/Previous ordering, device filters, horizon, unplug/replug, aggregates) still pass. `git diff --check` clean. **No GPU or driver used** (synthetic virtual gamepads). **AI-assisted (OpenCode).** --- <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#92
No description provided.