GameInput: enforce statusFilter in RegisterDeviceCallback (#1489) #1593

Open
hajduzsolt wants to merge 1 commit from upstream-pr/1603 into main
hajduzsolt commented 2026-11-24 18:08:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T18:08:34Z.


Enforces statusFilter in IGameInput::RegisterDeviceCallback so callbacks only fire when (filter & STATUS) != 0. Part of #1489.

What is in it

  • crates/xcl/src/hle/gameinput.rs: check filter & STATUS != 0 in register_device_callback before invoking or spawning the enumeration callback.
  • crates/xcl/src/hle/gameinput.rs: add unit test register_device_callback_enforces_status_filter verifying filter == 0 and non-matching status bits do not invoke the callback while matching bits invoke it with STATUS.

Tested

  • Hardware & toolchain: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 7 9800X3D, Windows 11 10.0.26300.9974, rustc 1.98.1 (48a229cea 2026-09-01), debug (cargo test).
  • cargo test -p xcl --lib hle::gameinput::tests -- --test-threads=2: 10 passed, 0 failed, 0 ignored.
  • cargo test --workspace -- --test-threads=2: 777 passed, 0 failed, 41 ignored (xcl --lib: 728 passed, 0 failed, 21 ignored; integration/e2e suites: 49 passed, 0 failed, 20 ignored).
  • SKIPPED runtime tests: SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 49 48 14
device removals: 0
crashes: 0
peak commit: 20195 MB

PR:

xcl-smoke v1
commit: 67da08e9c2478e3e6ed2e7935602febc31da03b9
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14833 MB

Not tested

  • Hotplug device-status transitions (XCL exposes a single permanently connected virtual gamepad).

AI use

  • Antigravity (Gemini 4 Hydrogen, high): added statusFilter check in register_device_callback, wrote unit test, ran the workspace test suite, and drafted commit and PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5477703542 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T18:08:34Z. --- Enforces statusFilter in IGameInput::RegisterDeviceCallback so callbacks only fire when (filter & STATUS) != 0. Part of #1489. **What is in it** - crates/xcl/src/hle/gameinput.rs: check `filter & STATUS != 0` in `register_device_callback` before invoking or spawning the enumeration callback. - crates/xcl/src/hle/gameinput.rs: add unit test `register_device_callback_enforces_status_filter` verifying `filter == 0` and non-matching status bits do not invoke the callback while matching bits invoke it with `STATUS`. **Tested** - Hardware & toolchain: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 7 9800X3D, Windows 11 10.0.26300.9974, `rustc 1.98.1` (48a229cea 2026-09-01), debug (`cargo test`). - `cargo test -p xcl --lib hle::gameinput::tests -- --test-threads=2`: 10 passed, 0 failed, 0 ignored. - `cargo test --workspace -- --test-threads=2`: 777 passed, 0 failed, 41 ignored (`xcl --lib`: 728 passed, 0 failed, 21 ignored; integration/e2e suites: 49 passed, 0 failed, 20 ignored). - SKIPPED runtime tests: `SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`. **Regression run** main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1594 (PresentX 1594) presents per 2 s (last 3): 49 48 14 device removals: 0 crashes: 0 peak commit: 20195 MB ``` PR: ``` xcl-smoke v1 commit: 67da08e9c2478e3e6ed2e7935602febc31da03b9 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1678 (PresentX 1678) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14833 MB ``` **Not tested** - Hotplug device-status transitions (XCL exposes a single permanently connected virtual gamepad). **AI use** - Antigravity (Gemini 4 Hydrogen, high): added statusFilter check in `register_device_callback`, wrote unit test, ran the workspace test suite, and drafted commit and PR description.
DavidM1911 commented 2026-11-24 21:09:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:22:00Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7143435338 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7143435338). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:22:00Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
throny commented 2026-11-25 19:08:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T18:10:51Z.


Two contributors checked independently and found that #1784 solves the same problem (for #1488) in a different way: #1607, group D92. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7170551190 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7170551190). Originally posted by [throny](https://github.com/throny) on 2026-11-25T18:10:51Z. --- <!-- xcl-1607-hint:D92 --> Two contributors checked independently and found that #1784 solves the same problem (for #1488) in a different way: #1607, group D92. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
upstream-sync closed this pull request 2026-11-25 23:07:25 +00:00
CalvyPZ commented 2026-11-25 23:09:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:42:30Z.


This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.

<!-- greyfinch-sync:ivall/xcl:comment:7176693032 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7176693032). Originally posted by [CalvyPZ](https://github.com/CalvyPZ) on 2026-11-25T22:42:30Z. --- This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
upstream-sync reopened this pull request 2026-11-26 00:04:24 +00:00
github-actions[bot] commented 2026-11-29 20:44:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:29Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262320706 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7262320706). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:29Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Grimkaaah commented 2026-11-30 12:05:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Grimkaaah on 2026-11-30T12:05:22Z.


I compared this with #1784 (same call, same issue) and with the same mechanism in my project. I checked both against the public GameInput.h (v0) and the GameInputDeviceStatus page on learn.microsoft.com.

What I checked:

  • The v0 header passes the callback both currentStatus and previousStatus (GameInputDeviceCallback). The status page says titles "can register to receive a callback when any of these states change". So the filter chooses which status changes fire the callback: (currentStatus ^ previousStatus) & statusFilter != 0. The callback gets both masks whole. My project uses this rule.
  • In the initial enumeration, previousStatus is NoStatus (0), so the rule becomes STATUS & filter != 0, and the callback gets the full STATUS. That is what this PR does (gameinput.rs:821). A filter of 0, or one of bits the pad doesn't have, gives no callback. That also matches the rule.
  • #1784 gates the same way but passes STATUS & filter as currentStatus. A title that registers for Connected only is then told that input is not enabled. Two merge-checks on #1784 already raised this. Of the two PRs, this one has the right semantics, so I'd keep this one and close #1784. The filter in #1784's log line could be added here if wanted.

Small gaps, no blocker:

  1. Only the blocking enumeration is tested. Please add a test with async enumeration (enumeration = 1) and with a filter of 0x80 (Wireless). That bit is inside GameInputDeviceAnyStatus (0x00FFFFFF in v0) but not in STATUS. That would cover the async branch and a realistic bit that doesn't match. 0x8000_0000 is outside AnyStatus.
  2. For later: if XCL ever reports status changes (a pad unplugged, the Wireless bit), keep the previous status per device and use the same (current ^ previous) & filter rule there. Then enumeration and changes behave the same. Today the status never changes, so there's nothing to do now.

Not checked: we haven't built or run this PR. I only read the async path. No title or controller was tested.

AI use: Claude Code (Claude Opus 5.5) reviewed this by comparing it with the same mechanism in my project, Victory Grimkaaah.

<!-- greyfinch-sync:ivall/xcl:comment:7277928649 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7277928649). Originally posted by [Grimkaaah](https://github.com/Grimkaaah) on 2026-11-30T12:05:22Z. --- I compared this with #1784 (same call, same issue) and with the same mechanism in my project. I checked both against the public GameInput.h (v0) and the GameInputDeviceStatus page on learn.microsoft.com. What I checked: - The v0 header passes the callback both `currentStatus` and `previousStatus` (`GameInputDeviceCallback`). The status page says titles "can register to receive a callback when any of these states change". So the filter chooses which status changes fire the callback: `(currentStatus ^ previousStatus) & statusFilter != 0`. The callback gets both masks whole. My project uses this rule. - In the initial enumeration, `previousStatus` is NoStatus (0), so the rule becomes `STATUS & filter != 0`, and the callback gets the full `STATUS`. That is what this PR does (gameinput.rs:821). A filter of 0, or one of bits the pad doesn't have, gives no callback. That also matches the rule. - #1784 gates the same way but passes `STATUS & filter` as `currentStatus`. A title that registers for Connected only is then told that input is not enabled. Two merge-checks on #1784 already raised this. Of the two PRs, this one has the right semantics, so I'd keep this one and close #1784. The filter in #1784's log line could be added here if wanted. Small gaps, no blocker: 1. Only the blocking enumeration is tested. Please add a test with async enumeration (`enumeration = 1`) and with a filter of `0x80` (Wireless). That bit is inside `GameInputDeviceAnyStatus` (0x00FFFFFF in v0) but not in `STATUS`. That would cover the async branch and a realistic bit that doesn't match. `0x8000_0000` is outside AnyStatus. 2. For later: if XCL ever reports status changes (a pad unplugged, the Wireless bit), keep the previous status per device and use the same `(current ^ previous) & filter` rule there. Then enumeration and changes behave the same. Today the status never changes, so there's nothing to do now. Not checked: we haven't built or run this PR. I only read the async path. No title or controller was tested. AI use: Claude Code (Claude Opus 5.5) reviewed this by comparing it with the same mechanism in my project, Victory Grimkaaah.
Foniass commented 2026-12-01 06:14:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:14:53Z.


Triage (#1607) – head 67da08e

#1784 solves the same issue in the same function (register_device_callback in gameinput.rs): both skip the callback when the status filter names none of the gamepad's statuses. They differ in what the callback gets: this PR passes the device's full status, #1784 passes STATUS & filter. GameInput documents currentStatus as the device's status, which matches this PR. Neither change is on main yet.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302657653 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1603#issuecomment-7302657653). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:14:53Z. --- **Triage (#1607)** – head 67da08e #1784 solves the same issue in the same function (`register_device_callback` in `gameinput.rs`): both skip the callback when the status filter names none of the gamepad's statuses. They differ in what the callback gets: this PR passes the device's full status, #1784 passes `STATUS & filter`. GameInput documents `currentStatus` as the device's status, which matches this PR. Neither change is on main yet. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1603:upstream-pr/1603'
git switch 'upstream-pr/1603'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1603'
git switch 'upstream-pr/1603'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1603'
git switch 'upstream-pr/1603'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1603'
git switch 'main'
git merge --squash 'upstream-pr/1603'
git switch 'main'
git merge --ff-only 'upstream-pr/1603'
git switch 'main'
git merge 'upstream-pr/1603'
git push origin 'main'
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
xcl-dev/xcl!1593
No description provided.