Real controller (XInput) and keyboard input for the virtual pad, rumble to the host pad #47
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!47
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/47/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@QuentinDanblon on GitHub · 2026-11-21 19:36 UTC · original
QuentinDanblon:feat/host-input→main· +680 −7 · 6 files · 104 commits · closed without mergingLibrary / area: compat-common (virtual pad, GameInput wrapper): real controller and keyboard input
Exports changed (exports.txt rows): none
Source of the behaviour: Windows SDK
Xinput.h/ learn.microsoft.com XInput docs (XINPUT_GAMEPAD layout, ranges, XINPUT_VIBRATION), GDKGameInputGamepadStateranges, the existing BTN_*/rumble layout in this crateProblem
BLOCKERS lists "Keyboard input: not started", and the README milestone "Keyboard / controller input" is not reached. The virtual pad in
gamepad.rsis fed only bypad.ps1scripts. A real XInput controller that host GameInput doesn't serve never reached the title. A pad-only title couldn't be played from the keyboard. The virtual pad'sSetRumbleStatewas dropped (ret_zeroslots, gamepad.rs:302-304).A local probe found that the host GameInput already gives the title the real keyboard and mouse (GetCurrentReading S_OK for kinds 0x10/0x30), so I didn't add an emulated keyboard device.
Change
New
pad_host.rs, feeding the existing virtual pad:xinput1_4.dllloaded dynamically, 4 ms poll on the first connected user (slots rescanned once per second when none is connected).pad.ps1batch runs, or its state isn't neutral, the scripted state is published unchanged. Otherwise host input is published. Host sources are merged (buttons OR-ed, each stick or trigger taken from the source that moves it further).install_pad_feedback.SetRumbleStatelow/high frequency goes toXInputSetStatewhen a real pad is the source. Trigger motors are stored only (no XInput equivalent).supportedRumbleMotorsnow reports 0x3.tombox.cfgconvention:TOMBOX_PAD_XINPUT/pad_xinputandTOMBOX_PAD_KEYS/pad_keys.0disables,forceignores the auto guards.TOMBOX_PAD=0still turns the whole virtual pad off.Tests
cargo test -p compat-common --lib -- pad_host gamepad: 14 pass, 8 of them new. They cover button bits, axis edges (−32768/32767/0, triggers 0/128/255), no dead zone, the key map (cancelling, diagonals), source combine, the script-wins merge, config parsing, window classes, and motor speed clamping/NaN.--test pad_host(new): creates a window, makes it foreground, injects W viaSendInput, checks left-stick Y = 1.0 and neutral after release. It skips when the process can't take the foreground (cargo here did skip). A manual run that took the foreground passed.--test gameinput_ext: 14 pass, including rumble/FF with the forwarding.backend_data,analysis/gdk,query_accum.dxil). This branch doesn't change them.Not verified
No physical controller on this machine (XInput returns 1167 on all slots). The XInput feed and rumble are covered only by the pure mapping tests. Not run in a title with a person playing: the next step is to focus a pad-only title and check the
[gamepad] host -> …lines. A title that readsWM_KEYDOWNinstead of GameInput would get both the keys and the mapped pad (pad_keys=0turns the mapping off). Mouse movement isn't mapped to the right stick, because that needs raw input and cursor capture. Clicking to focus the window also presses RT for that frame. The virtual pad still has no reading history and no RegisterReadingCallback.cargo test -p compat-commonpasses (except the local-data tests above)missingwith a note@QuentinDanblon on GitHub · 2026-11-21 22:02 UTC · original
Rebased onto
0fc7295, with the targeted tests re-run on the new base. #49 keeps the fused f16 FMA at VOP2 0x36-0x38 (gfx1013 v_fmac/fmamk/fmaak_f16) and updates the upstream ISA-sweep cases to the fused model. #36 adapts to upstream's TB_CEN_Q centroid qualifier. #48 now also includes the 4 regression scenarios from #28, credited.@QuentinDanblon on GitHub · 2026-11-22 11:36 UTC · original
Rebased onto
51f5319. Main now passes the host GameInput devices through to the title (gamepad/host.rs,host_input.rs), so what this PR still adds is:SetRumbleStateon the virtual pad, forwarded to the XInput pad feeding it.Adapted to main's hide settings: with
TOMBOX_HOST_PAD=0the XInput feed is off, and withTOMBOX_HOST_KBM=0the key mapping is off, both until a takeover (host_input::pad_hidden()/kbm_hidden()). A test run still sees only the scripted pad.Tests on this base:
cargo test -p compat-common --release --lib -- pad_host gamepad host_input: 28 pass.--test gameinput_ext: 14 pass.--test pad_host: 1 pass (it skips when the process cannot take the foreground).@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please rebase on the current gamepad.rs and strip comment lines. Note that tools/dev/pad.ps1 is regenerated on our side, so describe that change in the PR text. To resubmit:
git fetchthis repo, branch from the currentmain, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.Pull request closed