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

Open
github-bot wants to merge 2 commits from github-bot/gh-1095 into main AGit
Owner

@⁠sodove on GitHub · 2026-11-24 18:20 UTC · original
sodove:restore/gameinput-current-callback-9769 → main · +56 −0 · 3 files · 2 commits · open

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.
**@⁠sodove** on GitHub · 2026-11-24 18:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1095) `sodove:restore/gameinput-current-callback-9769` → `main` · +56 −0 · 3 files · 2 commits · open Claimed in the coordination issue as: OLD-9769 ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). ### 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.
GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE (all ones) names the callback that is
running on the calling thread, as the host's GameInput does (measured by
@Maraco91 on GameInput 0.2309): inside a callback, UnregisterCallback(CURRENT)
removes it and returns true and StopCallback(CURRENT) stops it; outside one the
token names nothing and UnregisterCallback returns false. The shim compared
it with registered tokens, matched none, and the callback kept firing.

call() records the running token in a thread_local, restored on return, and
both methods resolve the constant through it. gameinput_test drives a
self-cancelling reading callback through four button changes on the virtual
Xbox pad, once per method.

Finding: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115359105

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:37:56 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:41 UTC · original · approved these changes

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** on GitHub · 2026-11-24 18:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1095#pullrequestreview-6045225135) · **approved these changes** 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.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:52 UTC · original · approved these changes

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

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1095#pullrequestreview-6045383442) · **approved these changes** ### 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**
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:18 UTC · original

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

**@⁠Deedlyy** on GitHub · 2026-11-24 20:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1095#issuecomment-7143342670) **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
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 00:00 UTC · original

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)

**@⁠whoalin1** on GitHub · 2026-11-25 00:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1095#issuecomment-7148032258) 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)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1095/head:github-bot/gh-1095'
git switch 'github-bot/gh-1095'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1095'
git switch 'github-bot/gh-1095'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1095'
git switch 'github-bot/gh-1095'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1095'
git switch 'main'
git merge --squash 'github-bot/gh-1095'
git switch 'main'
git merge --ff-only 'github-bot/gh-1095'
git switch 'main'
git merge 'github-bot/gh-1095'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.