GameInput: resolve the current token for self-stopping callbacks (OLD-9769) #1095

Merged
sodove merged 2 commits from upstream-pr/1095 into main 2026-11-28 18:14:29 +00:00
sodove commented 2026-11-24 18:20:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-24T18:20:20Z.


Claimed in the coordination issue as: OLD-9769 (claim).

What and why

Carry forward @Joaco9020's GameInput fix from draft #46 (old PR 9769). The rebased commit retains the original authorship and has the same stable patch ID as 84dde3f1c. The branch includes current main 75223235d.

A reading callback can pass GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE to stop or unregister itself. The shim previously compared that special value directly with the registered tokens, so the callback kept receiving events. The fix resolves it to the callback running on the calling thread and restores the previous token when a nested delivery returns.

Tested

Native Windows 11 build 26100.7623, MSVC 19.44, RelWithDebInfo, pinned SDL 3.4.20, synthetic virtual pad.

  • Control at 3aa975421 with just the new test and ABI constant: 3 of 371 checks failed, covering self-stop and self-unregister.
  • With the fix, all 371 checks passed. The test drives four button changes, and the callback fires once. A stopped callback can still be unregistered by its actual token. A self-unregistered callback is already gone. Three additional CTest runs also passed.
  • Built the production gta6rt executable. In a separate local merge with #1074 at 5e86f4a3, the default and long-script tests passed (371/371 and 8/8).
  • The translator semantic suite passed (6,168 tests in 470 files). git diff --check and the repository's game-data guard also passed.
  • Main advanced by one unrelated guest-scene test during verification. After integrating it I reran GameInput (371/371) and the updated guest-scene tests (6/6).

GPUs tested: n/a (GameInput and SDL virtual devices).

AI-assisted: yes, OpenAI Codex for the rebase and Windows verification. The original commit retains its co-author credit.

Checklist

  • Includes current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • Translator-contract checklist item is inapplicable to this GameInput change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5477885337 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1095). Originally posted by [sodove](https://github.com/sodove) on 2026-11-24T18:20:20Z. --- Claimed in the coordination issue as: OLD-9769 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140345943)). ### What and why Carry forward @Joaco9020's GameInput fix from draft #46 (old PR 9769). The rebased commit retains the original authorship and has the same stable patch ID as `84dde3f1c`. The branch includes current main `75223235d`. A reading callback can pass `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE` to stop or unregister itself. The shim previously compared that special value directly with the registered tokens, so the callback kept receiving events. The fix resolves it to the callback running on the calling thread and restores the previous token when a nested delivery returns. ### Tested Native Windows 11 build 26100.7623, MSVC 19.44, RelWithDebInfo, pinned SDL 3.4.20, synthetic virtual pad. - Control at `3aa975421` with just the new test and ABI constant: 3 of 371 checks failed, covering self-stop and self-unregister. - With the fix, all 371 checks passed. The test drives four button changes, and the callback fires once. A stopped callback can still be unregistered by its actual token. A self-unregistered callback is already gone. Three additional CTest runs also passed. - Built the production `gta6rt` executable. In a separate local merge with #1074 at `5e86f4a3`, the default and long-script tests passed (371/371 and 8/8). - The translator semantic suite passed (6,168 tests in 470 files). `git diff --check` and the repository's game-data guard also passed. - Main advanced by one unrelated guest-scene test during verification. After integrating it I reran GameInput (371/371) and the updated guest-scene tests (6/6). GPUs tested: n/a (GameInput and SDL virtual devices). AI-assisted: yes, OpenAI Codex for the rebase and Windows verification. The original commit retains its co-author credit. ### Checklist - [x] Includes current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. - [x] Translator-contract checklist item is inapplicable to this GameInput change.
abnalstlll-byte commented 2026-11-24 18:41:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:41:35Z.

Review: APPROVED


Audited and verified. Implements GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE resolution via RAII-scoped hread_local t_running_token in
untime/shims/gameinput.cpp, allowing self-stopping and self-unregistering callbacks during execution while safely ignoring calls from outside callbacks. Comprehensive unit tests in
untime/test/gameinput_test.cpp pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045225135 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1095#pullrequestreview-6045225135). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:41:35Z. **Review:** APPROVED --- Audited and verified. Implements GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE resolution via RAII-scoped hread_local t_running_token in untime/shims/gameinput.cpp, allowing self-stopping and self-unregistering callbacks during execution while safely ignoring calls from outside callbacks. Comprehensive unit tests in untime/test/gameinput_test.cpp pass cleanly. Approved.
abnalstlll-byte commented 2026-11-24 18:52:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:52:56Z.

Review: APPROVED


Clean-Room Audit — PR #1095 (OLD-9769 GameInput Current-Callback Token)

Clean resolution of GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE (0xFFFFFFFFFFFFFFFFull) in runtime/shims/gameinput.cpp via thread-local running token RAII guard, allowing StopCallback and UnregisterCallback inside active callbacks without deadlock. Covered in runtime/test/gameinput_test.cpp; 0 game data.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045383442 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1095#pullrequestreview-6045383442). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:52:56Z. **Review:** APPROVED --- ### Clean-Room Audit — PR #1095 (`OLD-9769` GameInput Current-Callback Token) Clean resolution of `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE` (`0xFFFFFFFFFFFFFFFFull`) in `runtime/shims/gameinput.cpp` via thread-local running token RAII guard, allowing `StopCallback` and `UnregisterCallback` inside active callbacks without deadlock. Covered in `runtime/test/gameinput_test.cpp`; 0 game data. **Verdict: APPROVED**
Deedlyy commented 2026-11-24 20:18:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:18:32Z.


Recommendation: [MERGE]

Reasoning: Carries #46's GameInput fix: GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE now resolves to the running callback, so a self-stopping/unregistering callback actually stops. Small, focused shim change with a new regression test in gameinput_test.cpp. No second-person run yet, but the change is narrow and low risk. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143342670 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1095#issuecomment-7143342670). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:18:32Z. --- **Recommendation:** [MERGE] **Reasoning:** Carries #46's GameInput fix: `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE` now resolves to the running callback, so a self-stopping/unregistering callback actually stops. Small, focused shim change with a new regression test in `gameinput_test.cpp`. No second-person run yet, but the change is narrow and low risk. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10
whoalin1 commented 2026-11-25 00:00:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T00:00:24Z.


Independent verification at head a3158989c (Windows 11, MSVC 19.44, RelWithDebInfo, pinned SDL3 3.4.20 fetched via LEONIDA_SDL3_FETCH=ON):

  • Built gameinput_test and ran it: 371 checks, 0 failures, including all seven new current token checks (self-UnregisterCallback and self-StopCallback via GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE, plus the outside-a-callback negative cases).
  • Diff review: kCurrentCallbackToken = 0xFFFFFFFFFFFFFFFF matches GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE; the thread_local running token is set/restore-scoped inside call(), so nested deliveries keep their own token; only StopCallback/UnregisterCallback accept a token, and both now resolve before lookup. Invalid-token early returns look right.
  • No real GameInput hardware needed — the test drives SDL virtual joysticks through the shim, so this fully verifies on a controller-less machine.

The only PR check is the label workflow, which shows cancelled (superseded), not a code failure.

Verdict: verified, looks correct. — AI-assisted verification (Devin)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7148032258 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1095#issuecomment-7148032258). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T00:00:24Z. --- Independent verification at head `a3158989c` (Windows 11, MSVC 19.44, RelWithDebInfo, pinned SDL3 3.4.20 fetched via `LEONIDA_SDL3_FETCH=ON`): - Built `gameinput_test` and ran it: **371 checks, 0 failures**, including all seven new `current token` checks (self-`UnregisterCallback` and self-`StopCallback` via `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE`, plus the outside-a-callback negative cases). - Diff review: `kCurrentCallbackToken = 0xFFFFFFFFFFFFFFFF` matches `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE`; the `thread_local` running token is set/restore-scoped inside `call()`, so nested deliveries keep their own token; only `StopCallback`/`UnregisterCallback` accept a token, and both now resolve before lookup. Invalid-token early returns look right. - No real GameInput hardware needed — the test drives SDL virtual joysticks through the shim, so this fully verifies on a controller-less machine. The only PR check is the `label` workflow, which shows cancelled (superseded), not a code failure. Verdict: verified, looks correct. — AI-assisted verification (Devin)
MoonEyes commented 2026-11-28 18:14:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:14:25Z.


Red/green: On main gameinput_test does not compile because kCurrentCallbackToken is missing and main does not resolve GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE, so a self-stopping callback never stops, and with the PR on top of #1559 ctest -R "^gameinput(_script)?$" passes 2/2.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243638617 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1095#issuecomment-7243638617). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:14:25Z. --- Red/green: On main gameinput_test does not compile because kCurrentCallbackToken is missing and main does not resolve GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE, so a self-stopping callback never stops, and with the PR on top of #1559 ctest -R "^gameinput(_script)?$" passes 2/2. Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
OreoFR commented 2026-11-28 21:46:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:46:43Z.


Verified by OreoFR

Run 1 (nat06)

  • Base: main c1ecf04ed + PR head a3158989c; green run in a merge package of 9 PRs, no new ctest failure vs main
  • Test: ctest -R ^gameinput$
  • Red on main: does not compile (kCurrentCallbackToken missing on main)
  • Green with the PR: gameinput and gameinput_script OK
  • Verdict: READY

Run 2 (combo #1559 + #1095)

  • Base: main 3408969a7 + #1559 5fbcc642a + #1095 a3158989c (merged in that order, no conflict)
  • Test: ctest -R "^gameinput(_script)?$"
  • Red on main: n/a (compatibility check of the two PRs together)
  • Green with the PR: gameinput and gameinput_script OK; 381 checks, 0 failures, including #1559's late-pad checks and #1095's 7 current-token checks
  • Verdict: COMPATIBLE (both merged since, at the tested heads)

All runs

  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246264865 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1095#issuecomment-7246264865). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:46:43Z. --- **Verified by OreoFR** **Run 1 (nat06)** - Base: main `c1ecf04ed` + PR head `a3158989c`; green run in a merge package of 9 PRs, no new ctest failure vs main - Test: `ctest -R ^gameinput$` - Red on main: does not compile (kCurrentCallbackToken missing on main) - Green with the PR: gameinput and gameinput_script OK - Verdict: READY **Run 2 (combo #1559 + #1095)** - Base: main `3408969a7` + #1559 `5fbcc642a` + #1095 `a3158989c` (merged in that order, no conflict) - Test: `ctest -R "^gameinput(_script)?$"` - Red on main: n/a (compatibility check of the two PRs together) - Green with the PR: gameinput and gameinput_script OK; 381 checks, 0 failures, including #1559's late-pad checks and #1095's 7 current-token checks - Verdict: COMPATIBLE (both merged since, at the tested heads) **All runs** - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
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!1095
No description provided.