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

Closed
Andretuta wants to merge 4 commits from upstream-pr/39 into main
Andretuta commented 2026-11-24 02:05:23 +00:00 (Migrated from github.com)

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


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464693694 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/39). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:05:23Z. --- > 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).**
olegon85 commented 2026-11-24 08:30:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by olegon85 on 2026-11-24T08:30:57Z.


Tested 12734e9b on Windows 11 (10.0.26100), VS 2022 BuildTools MSVC, cmake -DLEONIDA_SDL3_FETCH=ON, RelWithDebInfo: pass.

  • gameinput_test.exe: 350 checks, 0 failures, including every check this PR adds (pre-sample Motion queries with and without a device filter, the GetNext/GetPrevious history-walk controls, and the raw-report before-first-report pair).
  • Negative control: rebuilt the same test with shims/gameinput.cpp at the merge-base 561b65a8 — exactly the seven new checks fail (the five Motion-filter walks plus the two pre-first-query cases) and nothing else, so the tests pin precisely this bug.
  • Code read: reading_matches() is applied on every reading-selection path — the history walk in find_reading, the device-filtered latest pick, the no-device latest loop, and the final guard that turns an advertised-but-empty best into READING_NOT_FOUND; GameInputKindUnknown keeps its match-anything meaning. The docs changes (motion and raw-report paragraphs) describe exactly the tested behavior. Built clean under /W4 /permissive- /utf-8.

No findings. AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7126228555 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/39#issuecomment-7126228555). Originally posted by [olegon85](https://github.com/olegon85) on 2026-11-24T08:30:57Z. --- Tested `12734e9b` on Windows 11 (10.0.26100), VS 2022 BuildTools MSVC, `cmake -DLEONIDA_SDL3_FETCH=ON`, RelWithDebInfo: **pass**. - `gameinput_test.exe`: **350 checks, 0 failures**, including every check this PR adds (pre-sample Motion queries with and without a device filter, the GetNext/GetPrevious history-walk controls, and the raw-report before-first-report pair). - Negative control: rebuilt the same test with `shims/gameinput.cpp` at the merge-base `561b65a8` — exactly the seven new checks fail (the five Motion-filter walks plus the two pre-first-query cases) and nothing else, so the tests pin precisely this bug. - Code read: `reading_matches()` is applied on every reading-selection path — the history walk in `find_reading`, the device-filtered latest pick, the no-device latest loop, and the final guard that turns an advertised-but-empty best into READING_NOT_FOUND; `GameInputKindUnknown` keeps its match-anything meaning. The docs changes (motion and raw-report paragraphs) describe exactly the tested behavior. Built clean under `/W4 /permissive- /utf-8`. No findings. AI-assisted review.
MoonEyes commented 2026-11-30 17:44:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T17:44:46Z.


Maintainer review: this still appears to address behavior not present in current main, so I do not consider it obsolete. It is not ready to merge: the PR remains a draft and all current CI checks were cancelled. Please confirm the current claim/dependency, update/merge main into the branch as required by the repo guide, rerun focused and full validation, and mark ready for review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7286781482 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/39#issuecomment-7286781482). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T17:44:46Z. --- Maintainer review: this still appears to address behavior not present in current main, so I do not consider it obsolete. It is not ready to merge: the PR remains a draft and all current CI checks were cancelled. Please confirm the current claim/dependency, update/merge main into the branch as required by the repo guide, rerun focused and full validation, and mark ready for review.
aslan2142 commented 2026-12-01 12:04:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:04:46Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310619806 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/39#issuecomment-7310619806). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:04:46Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 17:19:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:19:46Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319124644 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/39#issuecomment-7319124644). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T17:19:46Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

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