startup_stubs: fix GameInput single-kind history step-back and init race #1574

Merged
tedin7 merged 2 commits from upstream-pr/1581 into main 2026-11-24 15:07:48 +00:00
tedin7 commented 2026-11-24 14:35:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:35:01Z.


Summary

  • src/startup_stubs/gameinput.cpp: Fix find_in_ring() / find_history() so a single-kind GetPreviousReading() call steps past the reference reading's own sequence number even when a different input kind advanced order after that kind last changed. Previously, GetCurrentReading(kind_gamepad) after a keyboard-only change received the newer order, causing GetPreviousReading(ref, kind_gamepad) to return the same gamepad reading again (or succeed instead of returning reading_not_found from the first gamepad state).
  • src/startup_stubs/gameinput.cpp: Make build() thread-safe using C++11 static local initialization so concurrent GameInputCreate() calls cannot observe partially initialized vtables.
  • tests/startup_gameinput_history.cpp & CMakeLists.txt: Add startup_gameinput_history covering single-kind GetPreviousReading() after cross-kind changes, boundary reading_not_found, cross-kind GetPreviousReading(), and concurrent GameInputCreate().

Verification

  • git diff --check origin/main...HEAD
  • python -B tests/bidi_controls_check.py
  • Windows Server 2025 Debug & Release (/O2) CTest (startup_gameinput_history, startup_gameinput_keys, startup_stubs)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584199353 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1581). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T14:35:01Z. --- ## Summary - **`src/startup_stubs/gameinput.cpp`**: Fix `find_in_ring()` / `find_history()` so a single-kind `GetPreviousReading()` call steps past the reference reading's own sequence number even when a different input kind advanced `order` after that kind last changed. Previously, `GetCurrentReading(kind_gamepad)` after a keyboard-only change received the newer `order`, causing `GetPreviousReading(ref, kind_gamepad)` to return the same gamepad reading again (or succeed instead of returning `reading_not_found` from the first gamepad state). - **`src/startup_stubs/gameinput.cpp`**: Make `build()` thread-safe using C++11 static local initialization so concurrent `GameInputCreate()` calls cannot observe partially initialized vtables. - **`tests/startup_gameinput_history.cpp` & `CMakeLists.txt`**: Add `startup_gameinput_history` covering single-kind `GetPreviousReading()` after cross-kind changes, boundary `reading_not_found`, cross-kind `GetPreviousReading()`, and concurrent `GameInputCreate()`. ## Verification - `git diff --check origin/main...HEAD` - `python -B tests/bidi_controls_check.py` - Windows Server 2025 Debug & Release (`/O2`) CTest (`startup_gameinput_history`, `startup_gameinput_keys`, `startup_stubs`) AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 15:02:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T14:41:50Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:47:04.127262Z d76813a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134799205 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1581#issuecomment-7134799205). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T14:41:50Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"d76813a7cf2396f7ca98427ab7d8721ae0554291","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T14:47:04.127262Z">2026-11-24T14:47:04.127262Z</relative-time> | `d76813a` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
R0Y00 commented 2026-11-24 15:02:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:01:39Z.


The new source-built combined-reference control failed on d76813a7: after a keyboard-only change, requesting the previous gamepad reading skipped the closest gamepad event. 3329b4cd applies the step-back rule only when both the requested filter and the reference are the same single kind. The combined control, existing single-kind/concurrent cases, and both timestamp CTests pass on Windows Release (3/3).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135337803 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1581#issuecomment-7135337803). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T15:01:39Z. --- The new source-built combined-reference control failed on d76813a7: after a keyboard-only change, requesting the previous gamepad reading skipped the closest gamepad event. 3329b4cd applies the step-back rule only when both the requested filter and the reference are the same single kind. The combined control, existing single-kind/concurrent cases, and both timestamp CTests pass on Windows Release (3/3).
upstream-sync closed this pull request 2026-11-24 16:03:08 +00:00
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
R0Y00/Xbox2Windows!1574
No description provided.