[PR #46] [CLOSED] gameinput: StopCallback and UnregisterCallback take the current-callback token #99

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/46
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9769


📝 Commits (1)

  • 84dde3f gameinput: StopCallback and UnregisterCallback take the current-callback token

📊 Changes

3 files changed (+56 additions, -0 deletions)

View changed files

📝 runtime/shims/gameinput.cpp (+16 -0)
📝 runtime/shims/gameinput_abi.h (+3 -0)
📝 runtime/test/gameinput_test.cpp (+37 -0)

📄 Description

Carried over from old PR 9769 by Joaco9020 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9769, 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.
Joaco9020: 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: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115375665 (from @Maraco91's finding: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115359105)

Depends on: none. Overlaps: #9264 and #5109 also edit UnregisterCallback / the delivery path in runtime/shims/gameinput.cpp; this change adds two lines at the top of StopCallback and UnregisterCallback and a guard in call(), so whichever lands second needs a small rebase.

What and why

GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE (0xFFFFFFFFFFFFFFFF) names the callback that is running on the calling thread. The host's GameInput (0.2309, Windows 11, measured in the finding) treats it that way: inside a callback UnregisterCallback(CURRENT, 0) removes that callback and returns true, and StopCallback(CURRENT) stops it; outside a callback the token names nothing and UnregisterCallback returns false. The shim compared the constant with the registered tokens, matched none, and the callback kept firing, also after a title had freed its context.

  • gameinput_abi.h: kCurrentCallbackToken.
  • gameinput.cpp: call() records the running callback's token in a thread_local, restored on return (so a callback that drives another delivery keeps its own); StopCallback and UnregisterCallback resolve the constant through it, and with no running callback do nothing / return false.
  • gameinput_test.cpp: a reading callback on the virtual Xbox pad that cancels itself with the constant on its first call must run once for four button changes, once with UnregisterCallback (which must return true, after which the real token is gone) and once with StopCallback (the callback stays registered); the constant outside a callback returns false.

Tested

Windows 11, MSVC 19.44 (VS 2022 Build Tools), SDL3 fetched with -DLEONIDA_SDL3_FETCH=ON, on main 5d74c2723:

  • gameinput_test: 348 checks, 0 failures (7 new).
  • Negative control: the new test against the old gameinput.cpp (only the header constant added): 348 checks, 3 failures, exactly the three new behaviour checks.
  • gameinput_probe and gta6rt build with the change.

No game files, no controller (SDL virtual pads only). Whether the retail title passes the constant is not measured.

AI-assisted: yes (Claude).

🤖 Generated with Claude Code


🔄 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/46 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9769` --- ### 📝 Commits (1) - [`84dde3f`](https://github.com/ubiquitarianism/leonida/commit/84dde3f1c4cee4d06cfbe8e6d32c0d472c70fb20) gameinput: StopCallback and UnregisterCallback take the current-callback token ### 📊 Changes **3 files changed** (+56 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/gameinput.cpp` (+16 -0) 📝 `runtime/shims/gameinput_abi.h` (+3 -0) 📝 `runtime/test/gameinput_test.cpp` (+37 -0) </details> ### 📄 Description > Carried over from **old PR 9769** by `Joaco9020` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9769`, 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. > `Joaco9020`: 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: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115375665 (from `@Maraco91`'s finding: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7115359105) Depends on: none. Overlaps: `#9264` and `#5109` also edit `UnregisterCallback` / the delivery path in `runtime/shims/gameinput.cpp`; this change adds two lines at the top of `StopCallback` and `UnregisterCallback` and a guard in `call()`, so whichever lands second needs a small rebase. ### What and why `GAMEINPUT_CURRENT_CALLBACK_TOKEN_VALUE` (`0xFFFFFFFFFFFFFFFF`) names the callback that is running on the calling thread. The host's GameInput (0.2309, Windows 11, measured in the finding) treats it that way: inside a callback `UnregisterCallback(CURRENT, 0)` removes that callback and returns true, and `StopCallback(CURRENT)` stops it; outside a callback the token names nothing and `UnregisterCallback` returns false. The shim compared the constant with the registered tokens, matched none, and the callback kept firing, also after a title had freed its context. - `gameinput_abi.h`: `kCurrentCallbackToken`. - `gameinput.cpp`: `call()` records the running callback's token in a `thread_local`, restored on return (so a callback that drives another delivery keeps its own); `StopCallback` and `UnregisterCallback` resolve the constant through it, and with no running callback do nothing / return false. - `gameinput_test.cpp`: a reading callback on the virtual Xbox pad that cancels itself with the constant on its first call must run once for four button changes, once with `UnregisterCallback` (which must return true, after which the real token is gone) and once with `StopCallback` (the callback stays registered); the constant outside a callback returns false. ### Tested Windows 11, MSVC 19.44 (VS 2022 Build Tools), SDL3 fetched with `-DLEONIDA_SDL3_FETCH=ON`, on `main` `5d74c2723`: - `gameinput_test`: **348 checks, 0 failures** (7 new). - **Negative control**: the new test against the old `gameinput.cpp` (only the header constant added): 348 checks, **3 failures**, exactly the three new behaviour checks. - `gameinput_probe` and `gta6rt` build with the change. No game files, no controller (SDL virtual pads only). Whether the retail title passes the constant is not measured. AI-assisted: yes (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:16:47 +01:00
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#99
No description provided.