HLE: gamepads from SDL3 (SDL3.dll), with trigger rumble #130

Open
github-bot wants to merge 2 commits from github-bot/gh-130 into main AGit
Owner

@⁠DaviTostes on GitHub · 2026-11-24 21:43 UTC · original
DaviTostes:sdl3-gamepad-clean → main · +351 −45 · 1 files · 2 commits · open

What

Adds an SDL3 gamepad backend to the HLE gameinput module. SDL3.dll is loaded at run time with LoadLibraryW, so a build or a machine without it keeps the XInput path exactly as it is; VICTORY_INPUT=sdl3|xinput forces one.

Why

On the reporting machine (Linux, Wine 11.22 + vkd3d-proton 3.2, RX 9060 XT) XInput enumerates nothing for a GameSir G7 Pro — no device shows up at all — and where XInput does work it has no trigger motors, while the title sends four levels in slot 0x50. With SDL3 the pad is enumerated and all four motors are driven (SDL_RumbleGamepad for the body, SDL_RumbleGamepadTriggers for the triggers).

How it behaves

  • reads the first PADS gamepads SDL lists, and rescans once a second for hotplug; an unchanged list opens nothing again.
  • buttons, sticks and triggers map to the existing PadState; SDL's Y axis grows down and XInput's/ the console's grows up, so Y is negated.
  • keys() keeps the fork's shared keys() (this port was written against upstream main and the one conflict here was that refactor).
  • no new build dependency: SDL3.dll is optional. Without it nothing is logged unless VICTORY_INPUT=sdl3, in which case the module warns and falls back to XInput.
  • trigger motors are armed 60 s ahead on every call; a level of zero stops them at once.

Tested

Linux, Wine 11.22, RADV (RX 9060 XT), this fork's main + #20 + upstream #454:

INFO victory_hle::modules::gameinput::host: gamepads from SDL3
INFO victory_hle::modules::gameinput: input device device=4 connected=true
INFO victory_hle::modules::gameinput: input device callback kind=0x40000 enumeration=2 devices=1

Buttons, both sticks and the d-pad respond in the account picker and the menus; menus stay at 30-31 fps with the pad connected (the backend costs nothing measurable in the frame line). SDL3.dll came from Proton Experimental's wine-mono and from a Chromium bundle; both load.

Limits

  • Sensors, glyph profiles and the pad's audio are not here — the module's comment says they build on this path later.
  • One backend per run: if SDL3 starts, every pad comes from it.
  • Not tested on Windows with a physical pad (only that the same DLL next to the exe loads); the code path is the same.
**@⁠DaviTostes** on GitHub · 2026-11-24 21:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/130) `DaviTostes:sdl3-gamepad-clean` → `main` · +351 −45 · 1 files · 2 commits · open ## What Adds an SDL3 gamepad backend to the HLE `gameinput` module. `SDL3.dll` is loaded at run time with `LoadLibraryW`, so a build or a machine without it keeps the XInput path exactly as it is; `VICTORY_INPUT=sdl3|xinput` forces one. ## Why On the reporting machine (Linux, Wine 11.22 + vkd3d-proton 3.2, RX 9060 XT) XInput enumerates nothing for a GameSir G7 Pro — no device shows up at all — and where XInput does work it has no trigger motors, while the title sends four levels in slot `0x50`. With SDL3 the pad is enumerated and all four motors are driven (`SDL_RumbleGamepad` for the body, `SDL_RumbleGamepadTriggers` for the triggers). ## How it behaves - reads the first `PADS` gamepads SDL lists, and rescans once a second for hotplug; an unchanged list opens nothing again. - buttons, sticks and triggers map to the existing `PadState`; SDL's Y axis grows down and XInput's/ the console's grows up, so Y is negated. - `keys()` keeps the fork's shared `keys()` (this port was written against upstream `main` and the one conflict here was that refactor). - no new build dependency: `SDL3.dll` is optional. Without it nothing is logged unless `VICTORY_INPUT=sdl3`, in which case the module warns and falls back to XInput. - trigger motors are armed 60 s ahead on every call; a level of zero stops them at once. ## Tested Linux, Wine 11.22, RADV (RX 9060 XT), this fork's `main` + #20 + upstream #454: ``` INFO victory_hle::modules::gameinput::host: gamepads from SDL3 INFO victory_hle::modules::gameinput: input device device=4 connected=true INFO victory_hle::modules::gameinput: input device callback kind=0x40000 enumeration=2 devices=1 ``` Buttons, both sticks and the d-pad respond in the account picker and the menus; menus stay at 30-31 fps with the pad connected (the backend costs nothing measurable in the frame line). `SDL3.dll` came from Proton Experimental's wine-mono and from a Chromium bundle; both load. ## Limits - Sensors, glyph profiles and the pad's audio are not here — the module's comment says they build on this path later. - One backend per run: if SDL3 starts, every pad comes from it. - Not tested on Windows with a physical pad (only that the same DLL next to the exe loads); the code path is the same.
XInput sees neither the pad on this machine (GameSir G7 Pro) nor trigger
motors. The SDL3 backend loads SDL3.dll at run time, so the runtime still
starts without it, and reads buttons, sticks, triggers and rumble from
the pad; the title-memory and key paths are unchanged. VICTORY_INPUT
forces sdl3 or xinput.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:41 +00:00
Author
Owner

@⁠ericomeehan on GitHub · 2026-11-24 22:33 UTC · original

One line to change: the new // shortcut: no characters (code point 0); … comment in gameinput.rs (around the keyboard reading's ..Default::default()) names the title in full. 4e17478 removed the name from the tree, so "the title reads scan codes and virtual keys only" keeps it consistent.

Written with an AI assistant (Claude).

**@⁠ericomeehan** on GitHub · 2026-11-24 22:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/130#issuecomment-7146383546) One line to change: the new `// shortcut: no characters (code point 0); …` comment in `gameinput.rs` (around the keyboard reading's `..Default::default()`) names the title in full. 4e17478 removed the name from the tree, so "the title reads scan codes and virtual keys only" keeps it consistent. Written with an AI assistant (Claude).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-25 01:01 UTC · original

Fixed in 8b96867: the comment now says "the title reads scan codes and virtual keys only" (the merged text had the name wrapped across two lines, so my earlier sweep missed that copy). grep -rn "Grand Theft" crates/ is clean.

**@⁠DaviTostes** on GitHub · 2026-11-25 01:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/130#issuecomment-7149129877) Fixed in 8b96867: the comment now says "the title reads scan codes and virtual keys only" (the merged text had the name wrapped across two lines, so my earlier sweep missed that copy). `grep -rn "Grand Theft" crates/` is clean.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 05:13 UTC · original

Build check only: this PR merges cleanly on main c96b4f2 and the integration build of eight PRs (#115 #66 #36 #144 #147 #141 #139 #130) compiles (diagnostics profile). In the game, that combo was run alone 3 times (900 s, VICTORY_RELAY=2, scripted input): one run to the end (median 4.95 fps, about 4.9k draws per frame, against 4.84-5.04 fps on main), one title breakpoint 0x80000003 at about 157 s after a failed dstorage request (the pattern is explained on #115), one device removed (0x887A0005) at about 160 s that did not repeat in the two other runs. Nothing is proven for this PR alone: it was not run on its own, cargo test was not run on the combo, and nothing was checked on the title side of its change. Not verified.

**@⁠Revens2** on GitHub · 2026-11-25 05:13 UTC · [original](https://github.com/fxceless/victory-fork/pull/130#issuecomment-7153565548) Build check only: this PR merges cleanly on main c96b4f2 and the integration build of eight PRs (#115 #66 #36 #144 #147 #141 #139 #130) compiles (diagnostics profile). In the game, that combo was run alone 3 times (900 s, `VICTORY_RELAY=2`, scripted input): one run to the end (median 4.95 fps, about 4.9k draws per frame, against 4.84-5.04 fps on main), one title breakpoint `0x80000003` at about 157 s after a failed dstorage request (the pattern is explained on #115), one device removed (`0x887A0005`) at about 160 s that did not repeat in the two other runs. Nothing is proven for this PR alone: it was not run on its own, `cargo test` was not run on the combo, and nothing was checked on the title side of its change. Not verified.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:40 UTC · original

Build and symbol check on Windows 11 (no physical pad on this machine, so no pad reading was tested):

  • #130 head 8b96867 merged with main a26859f (no conflict): cargo build --profile diag -p victory --features diagnostics --locked builds; cargo test -p victory-hle gameinput gives 7 passed, 0 failed.
  • All 11 functions the PR loads with GetProcAddress (SDL_Init, SDL_GetGamepads, SDL_OpenGamepad, SDL_CloseGamepad, SDL_UpdateGamepads, SDL_GetGamepadButton, SDL_GetGamepadAxis, SDL_RumbleGamepad, SDL_RumbleGamepadTriggers, SDL_free, SDL_Quit) are present in the export table of the official SDL3.dll 3.4.20 (win32-x64, libsdl-org release): checked by reading the PE exports.
  • In-game run with that DLL next to the exe and VICTORY_INPUT=sdl3 is queued (about 25 min, keyboard stand-in script, no pad): result to follow, with the log lines of the backend choice.

Not verified: any real pad (axes, trigger scaling, the inverted Y, rumble, hotplug) on Windows.

Written with an AI assistant (Claude).

**@⁠Revens2** on GitHub · 2026-11-25 07:40 UTC · [original](https://github.com/fxceless/victory-fork/pull/130#issuecomment-7156124535) Build and symbol check on Windows 11 (no physical pad on this machine, so no pad reading was tested): - #130 head `8b96867` merged with main `a26859f` (no conflict): `cargo build --profile diag -p victory --features diagnostics --locked` builds; `cargo test -p victory-hle gameinput` gives 7 passed, 0 failed. - All 11 functions the PR loads with `GetProcAddress` (`SDL_Init`, `SDL_GetGamepads`, `SDL_OpenGamepad`, `SDL_CloseGamepad`, `SDL_UpdateGamepads`, `SDL_GetGamepadButton`, `SDL_GetGamepadAxis`, `SDL_RumbleGamepad`, `SDL_RumbleGamepadTriggers`, `SDL_free`, `SDL_Quit`) are present in the export table of the official `SDL3.dll` 3.4.20 (win32-x64, libsdl-org release): checked by reading the PE exports. - In-game run with that DLL next to the exe and `VICTORY_INPUT=sdl3` is queued (about 25 min, keyboard stand-in script, no pad): result to follow, with the log lines of the backend choice. Not verified: any real pad (axes, trigger scaling, the inverted Y, rumble, hotplug) on Windows. Written with an AI assistant (Claude).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/130/head:github-bot/gh-130'
git switch 'github-bot/gh-130'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-130'
git switch 'github-bot/gh-130'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-130'
git switch 'github-bot/gh-130'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-130'
git switch 'main'
git merge --squash 'github-bot/gh-130'
git switch 'main'
git merge --ff-only 'github-bot/gh-130'
git switch 'main'
git merge 'github-bot/gh-130'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.