Input: QueryInterface, a dispatcher, device methods, trigger rumble #1956

Open
RaghavVijayanand wants to merge 4 commits from upstream-pr/1958 into main
RaghavVijayanand commented 2026-11-25 01:45:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by RaghavVijayanand on 2026-11-25T01:45:21Z.


GameInput gaps and trigger rumble (README: "Input … Needs: Trigger rumble"). Four commits, each building and passing tests.

  • QueryInterface by interface id. The input object, devices and readings answer IUnknown and their own interface (with AddRef) and refuse everything else with E_NOINTERFACE and a cleared out pointer. A null out pointer gets E_POINTER, and a null id E_INVALIDARG. The interface ids are from the GDK's v0 GameInput.h.
  • A dispatcher for manual dispatch. This follows the GDK docs.
    • Holding a dispatcher switches to manual dispatch, and releasing the last reference switches back.
    • In manual mode the poll thread stops polling, and Dispatch polls on the title's thread.
    • OpenWaitHandle hands out an auto-reset event that the poll thread signals while dispatch is manual.
  • Device methods answer as devices without those features. The device table now uses the v0 signatures and gains its missing 22nd slot.
    • The old shared stub returned E_NOTIMPL. To the methods that return a bool, that read as true, so "is the force-feedback motor on?" and "can I get exclusive raw access?" both answered yes. It also left the battery struct and out pointers unwritten.
  • Trigger rumble through Windows.Gaming.Input. Levels are clamped to 0-1 (NaN becomes 0).
    • The big motors still go through XInput. Trigger levels also go to the matching Windows.Gaming.Input pad, with one more state sent to stop them.
    • Without a matching pad, only the motors run.
    • Pads now report all four motors.

Not done, on purpose: CreateAggregateDevice stays E_NOTIMPL. The GDK documents it as "introduced but unimplemented" in v0, the API version implemented here.

Shortcuts, documented in the code:

  • XInput slots are matched to Windows.Gaming.Input pads by order, which is right with one pad.
  • Battery status is "unknown".
  • Reading callbacks still never run, as before.

Tests: 8 new tests plus one extended, using a fake host backend for the rumble mapping and one call into the real Windows.Gaming.Input.

  • A mutation script broke each behavior one at a time (id check, AddRef, dispatch mode switching, wait-handle signalling, bool answers, battery struct, clamping, pad index, motor routing, the motor count), and every mutation made a test fail.
  • Trigger rumble has not been tried on a physical pad.
  • Cargo.lock is unchanged: upstream had already made windows non-optional, so the rebase only adds Gaming_Input to its features. Upstream's device walking and VICTORY_KEYS merge are kept, and manual Dispatch uses upstream's poll.

Rebased onto current main (940d32f). On this machine, 5 tests fail on main itself, with or without this change: descriptor::host::tests::dynamic_slots_are_held_until_released, memory::tests::lists_share_a_table_and_copies_keep_their_views, the two stride_tests::a_heap_buffer_read_* tests, and synthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with -D warnings, with and without --all-features.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5483514606 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958). Originally posted by [RaghavVijayanand](https://github.com/RaghavVijayanand) on 2026-11-25T01:45:21Z. --- GameInput gaps and trigger rumble (README: "Input … Needs: Trigger rumble"). Four commits, each building and passing tests. - **QueryInterface by interface id.** The input object, devices and readings answer IUnknown and their own interface (with AddRef) and refuse everything else with E_NOINTERFACE and a cleared out pointer. A null out pointer gets E_POINTER, and a null id E_INVALIDARG. The interface ids are from the GDK's v0 `GameInput.h`. - **A dispatcher for manual dispatch.** This follows the GDK docs. - Holding a dispatcher switches to manual dispatch, and releasing the last reference switches back. - In manual mode the poll thread stops polling, and `Dispatch` polls on the title's thread. - `OpenWaitHandle` hands out an auto-reset event that the poll thread signals while dispatch is manual. - **Device methods answer as devices without those features.** The device table now uses the v0 signatures and gains its missing 22nd slot. - The old shared stub returned E_NOTIMPL. To the methods that return a bool, that read as **true**, so "is the force-feedback motor on?" and "can I get exclusive raw access?" both answered yes. It also left the battery struct and out pointers unwritten. - **Trigger rumble through Windows.Gaming.Input.** Levels are clamped to 0-1 (NaN becomes 0). - The big motors still go through XInput. Trigger levels also go to the matching Windows.Gaming.Input pad, with one more state sent to stop them. - Without a matching pad, only the motors run. - Pads now report all four motors. Not done, on purpose: `CreateAggregateDevice` stays E_NOTIMPL. The GDK documents it as "introduced but unimplemented" in v0, the API version implemented here. Shortcuts, documented in the code: - XInput slots are matched to Windows.Gaming.Input pads by order, which is right with one pad. - Battery status is "unknown". - Reading callbacks still never run, as before. **Tests:** 8 new tests plus one extended, using a fake host backend for the rumble mapping and one call into the real Windows.Gaming.Input. - A mutation script broke each behavior one at a time (id check, AddRef, dispatch mode switching, wait-handle signalling, bool answers, battery struct, clamping, pad index, motor routing, the motor count), and every mutation made a test fail. - Trigger rumble has not been tried on a physical pad. - `Cargo.lock` is unchanged: upstream had already made `windows` non-optional, so the rebase only adds `Gaming_Input` to its features. Upstream's device walking and `VICTORY_KEYS` merge are kept, and manual `Dispatch` uses upstream's poll. **Rebased onto current main (940d32f).** On this machine, 5 tests fail on main itself, with or without this change: `descriptor::host::tests::dynamic_slots_are_held_until_released`, `memory::tests::lists_share_a_table_and_copies_keep_their_views`, the two `stride_tests::a_heap_buffer_read_*` tests, and `synthetic_tests::gathers_at_a_level_match_the_hardware`. Everything else passes, and clippy passes with `-D warnings`, with and without `--all-features`.
copilot-pull-request-reviewer[bot] commented 2026-11-25 01:45:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T01:45:35Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050345181 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958#pullrequestreview-6050345181). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T01:45:35Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
catminou4 commented 2026-11-25 02:10:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:10:44Z.

Review: COMMENTED


Static review only: victory-hle Windows-only; source review of the diff.

Input: QueryInterface, a dispatcher, device…: GameInput COM plumbing — pairs with #1942; same area, check overlap.

<!-- greyfinch-sync:Marvisak/VIctory:review:6050616103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958#pullrequestreview-6050616103). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:10:44Z. **Review:** COMMENTED --- Static review only: victory-hle Windows-only; source review of the diff. Input: QueryInterface, a dispatcher, device…: GameInput COM plumbing — pairs with #1942; same area, check overlap.
Marvisak commented 2026-11-25 03:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:19:29Z.


Automated triage for the maintainers.

Needs work: needs the maintainer's decision. The behaviour looks reasonable:

  • QueryInterface by id;
  • a dispatcher for manual dispatch;
  • device methods that answer "no" instead of an E_NOTIMPL that reads as true;
  • trigger rumble through Windows.Gaming.Input. The only Cargo change is the Gaming_Input feature of the existing windows crate.

CI passes. It breaks repo rule 2, though. The comments in gameinput.rs name the console SDK and its header ("from the GDK's GameInput.h", "the GDK documents CreateAggregateDevice"). They also use the header's identifiers, such as GameInputBatteryState and method names like IsForceFeedbackMotorPoweredOn in the DEVICE table. main uses only slot offsets and our own descriptions. Please reword those comments. Whether the interface ids copied from that header are acceptable under docs/asset-policy.md is for the maintainer to decide.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150579206 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958#issuecomment-7150579206). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:19:29Z. --- <!-- victory-triage v1 head=e104ae71d8e3005b1f1dfe33be4d5d7c23cce8da verdict=needs-work at=2026-11-25T03:21:00Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** The behaviour looks reasonable: - QueryInterface by id; - a dispatcher for manual dispatch; - device methods that answer "no" instead of an `E_NOTIMPL` that reads as `true`; - trigger rumble through Windows.Gaming.Input. The only Cargo change is the `Gaming_Input` feature of the existing `windows` crate. CI passes. It breaks repo rule 2, though. The comments in `gameinput.rs` name the console SDK and its header ("from the GDK's `GameInput.h`", "the GDK documents CreateAggregateDevice"). They also use the header's identifiers, such as `GameInputBatteryState` and method names like `IsForceFeedbackMotorPoweredOn` in the `DEVICE` table. `main` uses only slot offsets and our own descriptions. Please reword those comments. Whether the interface ids copied from that header are acceptable under `docs/asset-policy.md` is for the maintainer to decide. --- _Generated by [Claude Code](https://claude.ai/code)_
kilolimaVI commented 2026-11-26 21:57:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-26T21:57:39Z.


Comparison of the four open trigger-rumble PRs (README: "Trigger rumble"), each merged onto current main 63bcca4. Windows 11, toolchain 1.98.1; no pad here, so unit tests and CI's clippy checks only.

PR merge onto main cargo test -p victory-hle --lib -- gameinput clippy -D warnings (default / --all-features)
#1357 conflict in gameinput.rs - -
#1761 conflict in gameinput.rs - -
#1958 clean 18 passed (8 new) clean / clean
#2095 clean 10 passed (no new tests) clean / clean

#1958 and #2095 are separate implementations of the same Windows.Gaming.Input trigger path. #1958 also carries three input changes besides rumble (device methods answering as devices, a manual-dispatch dispatcher, QueryInterface by interface id) and tests for them; #2095 is rumble only, smaller, without tests. Taking one should close the other three. Both add "Gaming_Input" to victory-hle's windows features, so whichever goes second will need a one-line rebase there.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204224819 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958#issuecomment-7204224819). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-26T21:57:39Z. --- Comparison of the four open trigger-rumble PRs (README: "Trigger rumble"), each merged onto current main 63bcca4. Windows 11, toolchain 1.98.1; no pad here, so unit tests and CI's clippy checks only. | PR | merge onto main | `cargo test -p victory-hle --lib -- gameinput` | clippy `-D warnings` (default / `--all-features`) | |---|---|---|---| | #1357 | conflict in `gameinput.rs` | - | - | | #1761 | conflict in `gameinput.rs` | - | - | | #1958 | clean | 18 passed (8 new) | clean / clean | | #2095 | clean | 10 passed (no new tests) | clean / clean | #1958 and #2095 are separate implementations of the same Windows.Gaming.Input trigger path. #1958 also carries three input changes besides rumble (device methods answering as devices, a manual-dispatch dispatcher, QueryInterface by interface id) and tests for them; #2095 is rumble only, smaller, without tests. Taking one should close the other three. Both add `"Gaming_Input"` to victory-hle's `windows` features, so whichever goes second will need a one-line rebase there. AI-assisted (Claude).
kilolimaVI commented 2026-11-27 10:41:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T10:41:34Z.


Addendum to the comparison above, on the point fuzeofficial raised on #1357 (XInput slot used as the Gamepad.Gamepads index):

  • #1958 counts the connected slots before the one asked for (connected[..slot]) and uses that as the Windows.Gaming.Input index, so a gap like slot 0 leaving while slot 1 stays is handled. With several pads it still relies on both APIs listing them in the same order, which neither promises (its own // shortcut: comment says the triggers of another pad may answer).
  • #2095 only uses Windows.Gaming.Input when exactly one XInput slot is connected and the list holds exactly one pad; with several pads the triggers stay still, and no wrong pad is driven.
    With one pad both behave the same.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7216190116 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1958#issuecomment-7216190116). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T10:41:34Z. --- Addendum to the comparison above, on the point fuzeofficial raised on #1357 (XInput slot used as the `Gamepad.Gamepads` index): - #1958 counts the connected slots before the one asked for (`connected[..slot]`) and uses that as the Windows.Gaming.Input index, so a gap like slot 0 leaving while slot 1 stays is handled. With several pads it still relies on both APIs listing them in the same order, which neither promises (its own `// shortcut:` comment says the triggers of another pad may answer). - #2095 only uses Windows.Gaming.Input when exactly one XInput slot is connected and the list holds exactly one pad; with several pads the triggers stay still, and no wrong pad is driven. With one pad both behave the same. AI-assisted (Claude).
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/1958:upstream-pr/1958'
git switch 'upstream-pr/1958'

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/1958'
git switch 'upstream-pr/1958'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1958'
git switch 'upstream-pr/1958'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1958'
git switch 'main'
git merge --squash 'upstream-pr/1958'
git switch 'main'
git merge --ff-only 'upstream-pr/1958'
git switch 'main'
git merge 'upstream-pr/1958'
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
Marvisak/VIctory!1956
No description provided.