Repository navigation
Input: QueryInterface, a dispatcher, device methods, trigger rumble - #1958
Open
RaghavVijayanand wants to merge 4 commits into
Open
RaghavVijayanand wants to merge 4 commits into
RaghavVijayanand wants to merge 4 commits into
Conversation
The input object, its devices and its readings answered every QueryInterface with E_NOINTERFACE and a warning that it was not implemented. Each now answers IUnknown and its own interface (IGameInput, IGameInputDevice, IGameInputReading; ids from the GDK's GameInput.h, API v0) with itself and a new reference, as COM does; other ids get null and E_NOINTERFACE, a null out pointer E_POINTER and a null id E_INVALIDARG. Readings are counted, so a query's reference is the title's to release; the input object and devices live as long as the process and their counts stay nominal. A test queries each object for each interface id and a foreign one, checks the pointers handed back, that failures clear the out pointer, and that a reading's count grows by one per answer and not on a refusal. It fails when the id check is skipped or the reference is not taken.
CreateDispatcher failed with E_NOTIMPL. It now hands out a counted IGameInputDispatcher. As documented, holding one switches GameInput to manual dispatch and releasing the last switches back: while one lives, our poll thread stops polling the host, and Dispatch polls it on the title's thread, running the device callbacks that brings there. One poll is all the work there is, so Dispatch returns false (none left). OpenWaitHandle returns a new handle (a duplicate, which the title closes) to an auto-reset event of ours that the poll thread sets each period while dispatch is manual. Shortcut: every period counts as work, since telling whether the host changed would take the poll Dispatch is for. Tests drive the dispatcher through its table: QueryInterface for its own id and IUnknown (and refusal of the others) with the count checked; a pad connected under manual dispatch is not seen until Dispatch, whose callbacks run on the calling thread; releasing the last reference returns to automatic polling; wait handles are distinct, signalled by the period only in manual mode, auto-reset, and survive the title closing one. Each fails when the mode switch, the poll in Dispatch, the release bookkeeping, the signal or the interface id is broken.
Every IGameInputDevice method after GetDeviceStatus but SetRumbleState returned E_NOTIMPL from one stub, whatever its signature. For the methods that return bool that read as true (E_NOTIMPL's low byte is 1): a title asking whether a force feedback motor is on, or for exclusive raw access, was told yes. GetBatteryState left the title's struct unwritten, and the methods with an out pointer left it as it was. The table was also one slot short: API v0 ends with ReleaseExclusiveRawDeviceAccess at 0xa8. Each slot now has its v0 signature (GameInput.h of the GDK) and answers as a device with no battery report, no force feedback or haptic motors (as its info says), no input synchronization and no raw reports: battery status unknown with zero rates (shortcut: XInput's coarse levels give no capacities; v0 documents battery state as unimplemented), force feedback effects and haptic states E_INVALIDARG for a motor it does not have, false for the booleans, E_NOTIMPL with cleared out pointers (and zero bytes written) for raw reports and I/O controls, and no effect for gain, synchronization, PowerOff and releasing access (shortcut: PowerOff leaves the host pad on). CreateAggregateDevice keeps E_NOTIMPL, now as the documented answer rather than a gap: the GDK lists it as introduced but unimplemented in v0, removed in v1 and implemented with another signature only from v3. A test calls every device slot on a pad and on the keyboard with poisoned outputs and checks each answer, and the aggregate refusal. It fails when the feature read is given the create signature, a boolean answers true, the battery is left unwritten or its status is wrong, or the I/O control's byte count is not cleared.
SetRumbleState took the low and high frequency motors to XInput and dropped the trigger levels: XInput has no trigger motors. Grand Theft Auto VI sends trigger levels too. Our pads also told the title they had only the two big motors; they now report all four, as a console pad. The title's four levels are clamped to 0..1 (NaN is 0) and handed to a router over two host backends. The big motors still go to XInput as before. When a trigger level is set, Windows.Gaming.Input (Gamepad.Vibration) also gets all four levels, with the motors at the same values, so XInput's state is not undone. Once triggers have been set, the next state goes there too so they stop. A state with no trigger levels leaves that API alone. Without WinRT (the factory fails) the API is marked unavailable once and the motors work as before. An empty slot or a pad the API lacks gets the motors only. Shortcut: XInput slots and Windows.Gaming.Input pads are matched by order (the nth connected slot is that API's nth pad), since neither says which of the other's pads is which. That is right with one pad; with several, another pad's triggers may answer. Not tried on a physical pad: none is attached here. The `windows` dependency (no longer optional) also enables Gaming_Input. Cargo.lock is unchanged because the crate was already locked. Tests check through a fake host: levels clamped and scaled (0.5 to 32767, out of range and NaN), motors to XInput only, triggers to the trigger API at the pad's rank with all four levels, one stop and then silence, a missing trigger pad and an empty slot still driving the motors, the reported motors, and SetRumbleState through the device table reaching the host. A further test calls the real trigger API for a pad it lacks. Each test fails when the clamp, the rank, the stop bookkeeping, the empty-slot check, the motor call, the reported motors or the host call is broken.
Owner
|
Automated triage for the maintainers. Needs work: needs the maintainer's decision. The behaviour looks reasonable:
CI passes. It breaks repo rule 2, though. The comments in Generated by Claude Code |
RaghavVijayanand
force-pushed
the
hle/input-gaps
branch
from
November 25, 2026 02:23
ae92447 to
e104ae7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GameInput gaps and trigger rumble (README: "Input … Needs: Trigger rumble"). Four commits, each building and passing tests.
GameInput.h.Dispatchpolls on the title's thread.OpenWaitHandlehands out an auto-reset event that the poll thread signals while dispatch is manual.Not done, on purpose:
CreateAggregateDevicestays E_NOTIMPL. The GDK documents it as "introduced but unimplemented" in v0, the API version implemented here.Shortcuts, documented in the code:
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.
Cargo.lockis unchanged: upstream had already madewindowsnon-optional, so the rebase only addsGaming_Inputto its features. Upstream's device walking andVICTORY_KEYSmerge are kept, and manualDispatchuses 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 twostride_tests::a_heap_buffer_read_*tests, andsynthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with-D warnings, with and without--all-features.