Skip to content

Controllers: read a DualSense or DualShock 4 over HID when the system lists none, and set the DualShock 4 light bar - #265

Open
Lenny4250gh wants to merge 2 commits into
anyplaynet:mainfrom
Lenny4250gh:7-controller-fix
Open

Lenny4250gh wants to merge 2 commits into
anyplaynet:mainfrom
Lenny4250gh:7-controller-fix

Conversation

@Lenny4250gh

@Lenny4250gh Lenny4250gh commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

On Windows the launcher reads pads through Windows.Gaming.Input (gilrs). A DualSense on a USB cable can be missing from that list: the Controllers page then says that no controller is connected and the pad does nothing, while it works as soon as DS4Windows runs (it hands out a virtual Xbox pad). This is the gap docs/DESIGN.md 6.9 already notes ("not verified on hardware").

Two changes, both for Sony pads:

  1. HID fallback (ui/gamepad/hid_fallback.rs, new). When gilrs has listed no pad for 3 seconds, the DualSense and DualShock 4 are opened through hidapi (shared access, read only, nothing is written) and their input reports (USB, Bluetooth and the short Bluetooth report) are turned into the same button and axis changes gilrs delivers. They go through the same rules as before: press_effect, the held directions, the Home button, Create, the live state of the Controllers page and the pad list. As soon as gilrs lists a pad, the fallback lets go, so a pad is never counted twice (Steam Input, DS4Windows). gamepad.rs only starts the thread, tells it whether gilrs has a pad, and adds its pads to the list it publishes.
  2. DualShock 4 light bar (ui/lightbar.rs). The colour from the Controllers page now also reaches a DualShock 4 (05C4, 09CC, 0BA0), USB and Bluetooth, with its own report layout. Only the colour flag is set, so a game's rumble is untouched. gamepad.rs marks a DualShock 4 as a pad with a light bar and logs it as [DualShock 4]; pad_hub.rs has comment changes only. The dualsense field of PadInfo keeps its name because other files read it.

Report layouts come from the public sources of the Linux kernel (hid-playstation.c) and SDL (SDL_hidapi_ps4.c, SDL_hidapi_ps5.c), like ps_button.rs and the light bar before.

Not verified on hardware: the HID fallback and the DualShock 4 light bar, over USB and over Bluetooth. Does not help when Steam Input or HidHide hides the pad from HID readers as well.

Checklist

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass.
  • No visible change to a screen: no new layout, no gallery scene changes (the Controllers page lists one more pad when the fallback is used).
  • No new or changed text for the player (log lines only), so no strings to translate.
  • It works for every game. Nothing exists for one title.
  • No game data anywhere.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@Lenny4250gh
Lenny4250gh requested a review from AlxcBTW October 28, 2026 23:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant