Repository navigation
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
Open
Lenny4250gh wants to merge 2 commits into
Lenny4250gh wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
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:
ui/gamepad/hid_fallback.rs, new). When gilrs has listed no pad for 3 seconds, the DualSense and DualShock 4 are opened throughhidapi(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.rsonly starts the thread, tells it whether gilrs has a pad, and adds its pads to the list it publishes.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.rsmarks a DualShock 4 as a pad with a light bar and logs it as[DualShock 4];pad_hub.rshas comment changes only. Thedualsensefield ofPadInfokeeps 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), likeps_button.rsand 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 warningsandcargo test --workspacepass.Need help on this PR? Tag
@codesmith-botwith what you need.