HLE GameInput supports IUnknown queries #1329

Closed
github-bot wants to merge 1 commit from gh-pr/1329/head into gh-pr/1329/base
Owner

@⁠BaggyALPHA on GitHub · 2026-11-24 17:29 UTC · original
BaggyALPHA:fix/gameinput-iunknown → main · +71 −6 · 1 files · 1 commits · closed without merging

Addresses item 20 (VIC-BT-020) in #1242. The input, device and reading vtables now answer QueryInterface(IID_IUnknown) with their identity pointer. A successful reading query takes a counted reference. Unsupported interface IDs still return E_NOINTERFACE and clear the output, and null arguments return E_POINTER.

The synthetic regression invokes slot zero on all three objects. It verifies identity, cleared outputs on failure, and the reading's lifetime through the final release. The test failed against the existing implementation and passes with the fix. The HLE package passed 96 tests on Windows, and Clippy with all targets and features and the asset-policy hook passed.

AI-assisted (Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-24 17:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329) `BaggyALPHA:fix/gameinput-iunknown` → `main` · +71 −6 · 1 files · 1 commits · closed without merging Addresses item 20 (VIC-BT-020) in #1242. The input, device and reading vtables now answer `QueryInterface(IID_IUnknown)` with their identity pointer. A successful reading query takes a counted reference. Unsupported interface IDs still return `E_NOINTERFACE` and clear the output, and null arguments return `E_POINTER`. The synthetic regression invokes slot zero on all three objects. It verifies identity, cleared outputs on failure, and the reading's lifetime through the final release. The test failed against the existing implementation and passes with the fix. The HLE package passed 96 tests on Windows, and Clippy with all targets and features and the asset-policy hook passed. AI-assisted (Codex).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:46 +00:00
github-bot closed this pull request 2026-11-26 04:27:46 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 21:09 UTC · original

Tested on Windows 11 with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-hle passed failed ignored
main 95 0 0
main + this PR 96 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • Minor: cargo fmt --check would rewrap one block this PR adds (gameinput.rs). main isn't rustfmt-clean either, so take it or leave it.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

**@⁠acetonahard-code** on GitHub · 2026-11-24 21:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7144543281) Tested on Windows 11 with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 95 | 0 | 0 | | `main` + this PR | 96 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. - Minor: `cargo fmt --check` would rewrap one block this PR adds (`gameinput.rs`). `main` isn't rustfmt-clean either, so take it or leave it. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:18 UTC · original

Duplicate check: this overlaps #1641 (GameInput QueryInterface). #1641 accepts both IID_IUnknown and each object's own IGameInput/IGameInputDevice/IGameInputReading IID, with a hardware-verified test. This one covers the IUnknown identity path only. Suggest keeping one — #1641 is the more complete fix for VIC-BT-020 — and closing this to avoid two PRs for the same slot.

**@⁠Calvix2k** on GitHub · 2026-11-24 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7146076362) Duplicate check: this overlaps #1641 (GameInput QueryInterface). #1641 accepts both `IID_IUnknown` and each object's own `IGameInput`/`IGameInputDevice`/`IGameInputReading` IID, with a hardware-verified test. This one covers the IUnknown identity path only. Suggest keeping one — #1641 is the more complete fix for VIC-BT-020 — and closing this to avoid two PRs for the same slot.
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-24 22:42 UTC · original

Agreed that VIC-BT-020 should land through one PR. #1641 is the broader implementation. Its device IID still exposes a v0 table with 21 of the SDK's 22 slots, so I verified the missing release entry and two typed boolean stubs in a local Windows test. All eight GameInput tests passed with the correction. I posted the details on #1641.

I'll keep this PR open while that device-table follow-up is pending so the IUnknown fix remains available for review.

AI-assisted (Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-24 22:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7146548918) Agreed that VIC-BT-020 should land through one PR. #1641 is the broader implementation. Its device IID still exposes a v0 table with 21 of the SDK's 22 slots, so I verified the missing release entry and two typed boolean stubs in a local Windows test. All eight GameInput tests passed with the correction. I posted the details on [#1641](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1641). I'll keep this PR open while that device-table follow-up is pending so the IUnknown fix remains available for review. AI-assisted (Codex).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:36 UTC · original · edited 2026-11-25 20:19 UTC

Automated triage for the maintainers.

Merge candidate. The head (c52be85) has not changed since the last review and still merges cleanly. Slot 0 of the input, device and reading vtables in crates/victory-hle/src/modules/gameinput.rs now goes through query_iunknown. It answers IID_IUnknown with the object itself plus an AddRef, returns E_NOINTERFACE with *out cleared for any other IID, and returns E_POINTER for null arguments. That is the standard COM contract, and it uses no constants beyond the well-known IUnknown IID.

Reply to the author: thanks for the summary. Whether #1942's interface IIDs and slot layout are acceptable under the asset policy is a call for the maintainer, not for triage. If #1942 is accepted, this PR becomes redundant. Until then it remains the narrower fix that depends on none of those constants, so the verdict stays.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7150935098) · edited 2026-11-25 20:19 UTC <!-- victory-triage v1 head=c52be85ed9f72b89d56e50a4a5828a35da020fdf verdict=merge-candidate at=2026-11-25T03:22:20Z --> Automated triage for the maintainers. **Merge candidate.** The head (`c52be85`) has not changed since the last review and still merges cleanly. Slot 0 of the input, device and reading vtables in `crates/victory-hle/src/modules/gameinput.rs` now goes through `query_iunknown`. It answers `IID_IUnknown` with the object itself plus an AddRef, returns `E_NOINTERFACE` with `*out` cleared for any other IID, and returns `E_POINTER` for null arguments. That is the standard COM contract, and it uses no constants beyond the well-known IUnknown IID. Reply to the author: thanks for the summary. Whether #1942's interface IIDs and slot layout are acceptable under the asset policy is a call for the maintainer, not for triage. If #1942 is accepted, this PR becomes redundant. Until then it remains the narrower fix that depends on none of those constants, so the verdict stays. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 02:46 UTC · original

Quick update for maintainers reviewing the overlap: #1641 was re-landed as #1942. That PR is open, its CI is green, and it includes the 22-slot device-table correction discussed above. Both PRs change GameInput COM slot 0, so they should be considered together when choosing what lands.

AI-assisted (OpenAI Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 02:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7151170786) Quick update for maintainers reviewing the overlap: #1641 was re-landed as #1942. That PR is open, its CI is green, and it includes the 22-slot device-table correction discussed above. Both PRs change GameInput COM slot 0, so they should be considered together when choosing what lands. AI-assisted (OpenAI Codex).
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 02:47 UTC · original

For whoever picks one of these: #1942 (re-land of #1641) is a superset of this change. Same slot-0 query_iunknown treatment of the input, device and reading vtables, plus two things this one does not have:

  • own-interface-IID queries (IGameInput, IGameInputDevice, IGameInputReading ids from the public GameInput.h) as well as IID_IUnknown;
  • the 22-slot device-table correction from @⁠BaggyALPHA (device-table slots 0x38/0xa0/0xa8), which is what the overlap thread was about.

#1942 is open, mergeable and green; #1329 is green too. Landing either is fine by me — if #1329 goes first, #1942 can drop its IID_IUnknown part and keep the rest; if #1942 goes first, this one is redundant. I verified both trees' GameInput tests locally (10 tests, all pass) and cargo xtask policy on #1942.

**@⁠Calvix2k** on GitHub · 2026-11-25 02:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7151190230) For whoever picks one of these: **#1942** (re-land of #1641) is a superset of this change. Same slot-0 `query_iunknown` treatment of the input, device and reading vtables, plus two things this one does not have: - own-interface-IID queries (`IGameInput`, `IGameInputDevice`, `IGameInputReading` ids from the public GameInput.h) as well as `IID_IUnknown`; - the 22-slot device-table correction from @⁠BaggyALPHA (device-table slots 0x38/0xa0/0xa8), which is what the overlap thread was about. #1942 is open, mergeable and green; #1329 is green too. Landing either is fine by me — if #1329 goes first, #1942 can drop its `IID_IUnknown` part and keep the rest; if #1942 goes first, this one is redundant. I verified both trees' GameInput tests locally (10 tests, all pass) and `cargo xtask policy` on #1942.
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 15:18 UTC · original

For whoever triages this next: the open question in the triage note above — whether #1942's interface constants meet the asset policy, the ground its predecessor #1641 was closed on — now has the evidence laid out on #1942: GameInput's header ships publicly for PC via NuGet (not only through the Xbox GDK), and main already carries both interface ids the title asks for and documented slot offsets for them, modules/xpackage.rs being the clearest case.

If that settles it in #1942's favour, this PR is redundant and I will close it — #1942 is the superset, it covers both #1753-style IID queries and the 22-slot device table, and one fix landing beats two PRs sitting. I am leaving it open only as the fallback that depends on none of those constants, in case the policy call goes the other way.

(Corrected the triage link in this comment: it first pointed at a comment on #2033.)

AI-assisted (Claude Code).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 15:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7166641363) For whoever triages this next: the open question in the [triage note](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1329) above — whether #1942's interface constants meet the asset policy, the ground its predecessor #1641 was closed on — now has the evidence laid out [on #1942](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1942): GameInput's header ships publicly for PC via NuGet (not only through the Xbox GDK), and `main` already carries both interface ids the title asks for and documented slot offsets for them, `modules/xpackage.rs` being the clearest case. If that settles it in #1942's favour, this PR is redundant and I will close it — #1942 is the superset, it covers both #1753-style IID queries and the 22-slot device table, and one fix landing beats two PRs sitting. I am leaving it open only as the fallback that depends on none of those constants, in case the policy call goes the other way. (Corrected the triage link in this comment: it first pointed at a comment on #2033.) AI-assisted (Claude Code).
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 22:15 UTC · original

Closing this in favour of #1942, which covers the same calls plus a case this one gets wrong.

Both add QueryInterface at slot 0 of the GameInput COM objects and both AddRef before handing the pointer back. The difference is which IIDs are answered. This PR answers IID_IUnknown alone:

if unsafe { *iid } != IID_IUNKNOWN {
    return fail(out, E_NOINTERFACE);
}

so an object asked for the interface it already implements answers E_NOINTERFACE. COM requires that query to succeed, so this is incomplete whether or not the title makes it. #1942 answers IID_IUnknown and the object's own IID for IGameInput, IGameInputDevice and IGameInputReading, and it reuses the Guid type already in xgameruntime rather than a bare [u8; 16].

That makes this a subset of #1942 with a wrong answer on the own-IID case, so there is no reason for a reviewer to read both. #1942 is the one to take.

For comparison if anyone needs it: this is +71/-6, #1942 is +157/-18, both in the one file, with the same hunk sites.

AI-assisted (Claude Code); the comparison is from the two patches as they stand now.

**@⁠BaggyALPHA** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1329#issuecomment-7176131685) Closing this in favour of #1942, which covers the same calls plus a case this one gets wrong. Both add `QueryInterface` at slot 0 of the GameInput COM objects and both AddRef before handing the pointer back. The difference is which IIDs are answered. This PR answers `IID_IUnknown` alone: ```rust if unsafe { *iid } != IID_IUNKNOWN { return fail(out, E_NOINTERFACE); } ``` so an object asked for the interface it already implements answers `E_NOINTERFACE`. COM requires that query to succeed, so this is incomplete whether or not the title makes it. #1942 answers `IID_IUnknown` *and* the object's own IID for `IGameInput`, `IGameInputDevice` and `IGameInputReading`, and it reuses the `Guid` type already in `xgameruntime` rather than a bare `[u8; 16]`. That makes this a subset of #1942 with a wrong answer on the own-IID case, so there is no reason for a reviewer to read both. #1942 is the one to take. For comparison if anyone needs it: this is +71/-6, #1942 is +157/-18, both in the one file, with the same hunk sites. AI-assisted (Claude Code); the comparison is from the two patches as they stand now.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1329
No description provided.