Skip to content

HLE GameInput supports IUnknown queries - #1329

Closed
BaggyALPHA wants to merge 1 commit into
Marvisak:mainfrom
BaggyALPHA:fix/gameinput-iunknown
Closed

BaggyALPHA wants to merge 1 commit into
Marvisak:mainfrom
BaggyALPHA:fix/gameinput-iunknown

Conversation

@BaggyALPHA

Copy link
Copy Markdown
Contributor

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-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
@acetonahard-code

Copy link
Copy Markdown

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.

@Calvix2k

Copy link
Copy Markdown
Contributor

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.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
@BaggyALPHA

Copy link
Copy Markdown
Contributor Author

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).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@BaggyALPHA

Copy link
Copy Markdown
Contributor Author

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).

@Calvix2k

Copy link
Copy Markdown
Contributor

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.

@BaggyALPHA

BaggyALPHA commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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).

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@BaggyALPHA

Copy link
Copy Markdown
Contributor Author

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 BaggyALPHA closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants