Input: generic HID pads (no-name USB pads), and victory pads to see their buttons #588

Open
github-bot wants to merge 1 commit from github-bot/gh-588 into main AGit
Owner

@⁠JuanF007 on GitHub · 2026-11-28 01:22 UTC · original
JuanF007:feat/generic-hid-pads → main · +1269 −17 · 6 files · 1 commits · open

Summary

Generic HID gamepads (DirectInput pads) were not recognised at all: input came only from XInput and from Sony's pads read over HID. A no-name USB pad such as a DragonRise "PC Controller" (0079:0126) did nothing in game. This PR adds a reader for any HID joystick or gamepad that XInput does not list and that is not one of Sony's pads, plus a victory pads command to see what such a pad sends.

What changes

  • crates/victory-hle/src/modules/gameinput/generic.rs (new): the generic HID pad reader, built like the PlayStation one: a scan thread every 2 s, and a reader thread per pad.
    • Reports are parsed by Windows' HID parser (HidP_GetUsageValue / HidP_GetUsages), from the usages the pad's descriptor gives:

      Usage Console pad
      X, Y left stick
      Z, Rz (else Rx, Ry) right stick
      Rx, Ry beside Z and Rz, or Z alone (DirectInput's combined axis) triggers
      Hat switch (8-way or 4-way, any logical minimum; out of range = centre) D-pad
      Generic Desktop Start, Select, D-pad buttons Menu, View, D-pad
      Button page, by number per layout (below)
    • Signed ranges are sign-extended, and an unsigned maximum given as negative (255 in 8 bits as -1) is read as unsigned.

    • Button layout. No standard says which number is which button, so the layout goes by vendor. The default is the PlayStation look-alike one most no-name pads have: 3,2,4,1,5,6,7,8,9,10,11,12, in the order A,B,X,Y,LB,RB,LT,RT,View,Menu,LS,RS. Logitech (046D) and Nintendo (057E) get their usual numbering.

    • VICTORY_PAD_BUTTONS in victory-settings.txt sets another layout: 12 numbers, or 16 with D-pad buttons, in VIscosity's order.

    • Not taken as pads:

      • XInput's own devices (IG_ in the path) and Sony's pads (the PlayStation reader's).
      • Multi-axis controllers (0x08), which 3D mice are.
      • An axis that should rest at its centre but is far from it in its first report, such as a throttle or a pedal. It is not read for that connection.
    • A pad whose device is gone is forgotten at the next scan. A Bluetooth pad switched off can leave its read waiting forever, and would otherwise hold its last buttons down.

    • Generic pads do not rumble, since they have no common way to.

  • gameinput.rs:
    • Generic pads take the slots XInput leaves, as Sony's pads do. By default that is only while XInput lists none, and in every free slot with VICTORY_DUALSENSE=1.
    • VICTORY_GENERIC_PADS=0 turns generic pads off. VICTORY_DUALSENSE=0 now turns off only the PlayStation pads.
    • Generic pad ids carry bit 63, so rumble never reaches the PlayStation reader with one of them.
  • playstation.rs: hid_paths is shared with the generic reader. No behaviour change.
  • victory pads (main.rs, play.rs): lists the XInput slots in use and the generic pads found. It then shows live the button numbers, axes and hat each generic pad sends, and the console buttons they make. It reads the pad settings from victory-settings.txt as a start would.
  • README: a "Pads" entry under "In the game".

The axis assignment and the VICTORY_PAD_BUTTONS order follow FrancescoGelosoEterea/VIscosity, commit d8db7a0 (gameinput/hid.rs, GPL-3.0). The code itself is new.

How a player uses it

  1. Plug the pad in and play. Most no-name pads need nothing else.
  2. If the buttons come out wrong, run victory.exe pads in a command prompt and press each button.
  3. Add VICTORY_PAD_BUTTONS=<numbers> to %LOCALAPPDATA%\victory\victory-settings.txt.

Testing

  • cargo test -p victory-hle --lib: 192 passed. The new tests cover sticks, triggers, hat ranges, signed and unsigned ranges, layouts and their parsing, Desktop buttons, axes that rest away from the centre, and the monitor line.
  • Hardware: a DragonRise "PC Controller" (0079:0126, USB) with victory pads. Every face button, L1/R1/L2/R2, Select/Start, L3/R3, the hat (it returns to centre on release) and both sticks read right with the default layout. No axis was wrongly taken as off-centre.
  • cargo xtask policy --staged: ok.
  • Clippy: the touched files add no clippy warnings. cargo clippy --workspace --all-targets -- -D warnings already fails on main with the pinned 1.98.1 toolchain, on code this PR does not touch (victory-gpu, victory-formats, victory-loader, other victory-hle modules).
  • Not tested: a full play session of the title. The game reads the same generic::pads() that victory pads shows. The Logitech and Nintendo layouts and pads with several report ids were not tested on hardware either.

Known limits

  • A flight stick or wheel whose throttle rests mid-range when it connects is read as a stick. With no XInput pad connected, it can move the camera. VICTORY_GENERIC_PADS=0 turns generic pads off.
  • A pad seen over both USB and Bluetooth is two pads. With the default single merged pad this does not show.
**@⁠JuanF007** on GitHub · 2026-11-28 01:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/588) `JuanF007:feat/generic-hid-pads` → `main` · +1269 −17 · 6 files · 1 commits · open ## Summary Generic HID gamepads (DirectInput pads) were not recognised at all: input came only from XInput and from Sony's pads read over HID. A no-name USB pad such as a DragonRise "PC Controller" (0079:0126) did nothing in game. This PR adds a reader for any HID joystick or gamepad that XInput does not list and that is not one of Sony's pads, plus a `victory pads` command to see what such a pad sends. ## What changes - **`crates/victory-hle/src/modules/gameinput/generic.rs`** (new): the generic HID pad reader, built like the PlayStation one: a scan thread every 2 s, and a reader thread per pad. - Reports are parsed by Windows' HID parser (`HidP_GetUsageValue` / `HidP_GetUsages`), from the usages the pad's descriptor gives: | Usage | Console pad | |---|---| | X, Y | left stick | | Z, Rz (else Rx, Ry) | right stick | | Rx, Ry beside Z and Rz, or Z alone (DirectInput's combined axis) | triggers | | Hat switch (8-way or 4-way, any logical minimum; out of range = centre) | D-pad | | Generic Desktop Start, Select, D-pad buttons | Menu, View, D-pad | | Button page, by number | per layout (below) | - Signed ranges are sign-extended, and an unsigned maximum given as negative (255 in 8 bits as -1) is read as unsigned. - **Button layout.** No standard says which number is which button, so the layout goes by vendor. The default is the PlayStation look-alike one most no-name pads have: `3,2,4,1,5,6,7,8,9,10,11,12`, in the order A,B,X,Y,LB,RB,LT,RT,View,Menu,LS,RS. Logitech (046D) and Nintendo (057E) get their usual numbering. - `VICTORY_PAD_BUTTONS` in `victory-settings.txt` sets another layout: 12 numbers, or 16 with D-pad buttons, in VIscosity's order. - **Not taken as pads:** - XInput's own devices (`IG_` in the path) and Sony's pads (the PlayStation reader's). - Multi-axis controllers (0x08), which 3D mice are. - An axis that should rest at its centre but is far from it in its first report, such as a throttle or a pedal. It is not read for that connection. - **A pad whose device is gone is forgotten at the next scan.** A Bluetooth pad switched off can leave its read waiting forever, and would otherwise hold its last buttons down. - Generic pads do not rumble, since they have no common way to. - **`gameinput.rs`**: - Generic pads take the slots XInput leaves, as Sony's pads do. By default that is only while XInput lists none, and in every free slot with `VICTORY_DUALSENSE=1`. - `VICTORY_GENERIC_PADS=0` turns generic pads off. `VICTORY_DUALSENSE=0` now turns off only the PlayStation pads. - Generic pad ids carry bit 63, so rumble never reaches the PlayStation reader with one of them. - **`playstation.rs`**: `hid_paths` is shared with the generic reader. No behaviour change. - **`victory pads`** (`main.rs`, `play.rs`): lists the XInput slots in use and the generic pads found. It then shows live the button numbers, axes and hat each generic pad sends, and the console buttons they make. It reads the pad settings from `victory-settings.txt` as a start would. - **README**: a "Pads" entry under "In the game". The axis assignment and the `VICTORY_PAD_BUTTONS` order follow FrancescoGelosoEterea/VIscosity, commit d8db7a0 (`gameinput/hid.rs`, GPL-3.0). The code itself is new. ## How a player uses it 1. Plug the pad in and play. Most no-name pads need nothing else. 2. If the buttons come out wrong, run `victory.exe pads` in a command prompt and press each button. 3. Add `VICTORY_PAD_BUTTONS=<numbers>` to `%LOCALAPPDATA%\victory\victory-settings.txt`. ## Testing - `cargo test -p victory-hle --lib`: 192 passed. The new tests cover sticks, triggers, hat ranges, signed and unsigned ranges, layouts and their parsing, Desktop buttons, axes that rest away from the centre, and the monitor line. - **Hardware:** a DragonRise "PC Controller" (0079:0126, USB) with `victory pads`. Every face button, L1/R1/L2/R2, Select/Start, L3/R3, the hat (it returns to centre on release) and both sticks read right with the default layout. No axis was wrongly taken as off-centre. - `cargo xtask policy --staged`: ok. - **Clippy:** the touched files add no clippy warnings. `cargo clippy --workspace --all-targets -- -D warnings` already fails on `main` with the pinned 1.98.1 toolchain, on code this PR does not touch (victory-gpu, victory-formats, victory-loader, other victory-hle modules). - **Not tested:** a full play session of the title. The game reads the same `generic::pads()` that `victory pads` shows. The Logitech and Nintendo layouts and pads with several report ids were not tested on hardware either. ## Known limits - A flight stick or wheel whose throttle rests mid-range when it connects is read as a stick. With no XInput pad connected, it can move the camera. `VICTORY_GENERIC_PADS=0` turns generic pads off. - A pad seen over both USB and Bluetooth is two pads. With the default single merged pad this does not show.
- Any HID joystick or gamepad that XInput does not list and that is not
  one of Sony's pads is now read (`gameinput/generic.rs`): the no-name
  USB pads sold as "PC Controller" or "USB Gamepad" (DragonRise and
  alike), Logitech's in DirectInput mode, the Switch Pro Controller over
  Bluetooth. Before, such a pad was not seen at all.
- Reports are read through Windows' HID parser, by the usages the pad's
  descriptor gives: X and Y the left stick, Z and Rz (else Rx and Ry) the
  right one, Rx and Ry beside Z and Rz (or Z alone) the triggers, the hat
  switch the D-pad, Start, Select and D-pad buttons of the Generic Desktop
  page too. Signed ranges and unsigned maxima given as negative read right.
- Buttons by number, in the PlayStation look-alike layout most no-name
  pads have (Logitech's and Nintendo's usual one by vendor);
  `VICTORY_PAD_BUTTONS` in victory-settings.txt sets another (12 numbers,
  or 16 with D-pad buttons, in VIscosity's order).
- They take the slots XInput leaves, as Sony's pads do (by default only
  while XInput lists none). `VICTORY_GENERIC_PADS=0` turns them off;
  `VICTORY_DUALSENSE=0` now turns off only the PlayStation pads. They do
  not rumble.
- Not taken as pads: XInput's own devices (`IG_`), Sony's pads, 3D mice
  (multi-axis controllers). An axis that should rest at its centre but is
  far from it in its first report (a throttle, a pedal) is not read for
  that connection. A pad whose device is gone is forgotten at the next
  scan, so a Bluetooth pad switched off holds nothing down.
- `victory pads` lists the pads and shows, live, the button numbers, axes
  and hat each generic pad sends and the console buttons they make.

Tested with a DragonRise "PC Controller" (0079:0126, USB): every button,
the hat and both sticks, with the default layout.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 01:24:15 +00:00
This pull request can be merged automatically.
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/588/head:github-bot/gh-588'
git switch 'github-bot/gh-588'

Merge

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