Skip to content

fix(linux): restore PlayStation gamepad hotplug in Steam - #85

Merged
ReenigneArcher merged 10 commits into
masterfrom
fix/linux/playstation-pads
Aug 16, 2026
Merged

fix(linux): restore PlayStation gamepad hotplug in Steam#85
ReenigneArcher merged 10 commits into
masterfrom
fix/linux/playstation-pads

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Aug 15, 2026

Copy link
Copy Markdown
Member

Description

Expose DS4 and DualSense UHID devices with Sony's native identity while preserving their requested bus, descriptors, and report framing. Start the event reader before registration and wait for UHID_START before reporting successful creation.

Restore nonblocking UHID operation so Steam detects DS4 controllers created at runtime, and add regression coverage for lifecycle synchronization, identity, DS4 USB framing, and open flags.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Linux UHID now rewrites requested PlayStation USB profiles (DualShock 4 and DualSense) to their Bluetooth transport variants so Steam's hidraw access rules can match virtual devices correctly. The backend preserves caller-provided identity/capability metadata while swapping bus and report framing fields, returns the effective profile from gamepad creation, and leaves non-PlayStation or already-Bluetooth requests unchanged. Added test hooks and unit coverage for the profile translation behavior, and documented the Linux-only transport adjustment.
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.87097% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.04%. Comparing base (abfd0ee) to head (d127651).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/linux/uhid_backend.cpp 83.87% 4 Missing and 6 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #85      +/-   ##
==========================================
+ Coverage   75.03%   75.04%   +0.01%     
==========================================
  Files          34       34              
  Lines        8050     8083      +33     
  Branches     3012     3029      +17     
==========================================
+ Hits         6040     6066      +26     
+ Misses       1671     1473     -198     
- Partials      339      544     +205     
Flag Coverage Δ
FreeBSD 51.65% <ø> (ø)
Linux-Clang 57.23% <80.00%> (+0.08%) ⬆️
Linux-GCC 67.93% <81.35%> (+0.05%) ⬆️
Windows-MSVC 88.08% <ø> (ø)
Windows-MinGW-UCRT64 64.80% <ø> (ø)
macOS 51.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/linux/uhid_backend.cpp 80.95% <83.87%> (-0.05%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abfd0ee...d127651. Read the comment docs.

@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/playstation-pads branch from 8e5426a to de59e55 Compare August 16, 2026 00:40
@ReenigneArcher ReenigneArcher changed the title fix(Linux): map UHID PlayStation USB to Bluetooth fix(Linux): force Sony name for UHID PlayStation Aug 16, 2026
Switch Linux UHID PlayStation handling from transport/profile rewriting to identity-only naming. DualShock 4 and DualSense now always emit `Wireless Controller` in UHID create events so Steam HID detection stays compatible, while keeping the requested USB/Bluetooth descriptor and report framing unchanged. Tests and fixtures were updated to capture/create-name assertions, and the old effective-profile remap helper/tests were removed.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/playstation-pads branch from de59e55 to def6ff0 Compare August 16, 2026 01:11
Keep the caller-requested DualShock 4 name and USB framing on the Linux UHID backend while still using Sony's native product name for DualSense Steam HID discovery. The tests and platform support docs were updated to assert the DualShock 4 create event and input reports stay on the expected USB path instead of being silently presented as Bluetooth.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/playstation-pads branch from f1138b3 to 5802929 Compare August 16, 2026 02:06
Start the UHID reader before sending UHID_CREATE2 and block create() until UHID_START arrives (with timeout and reader-exit failure paths). This keeps control-channel handling active during registration and avoids exposing a gamepad as ready before the kernel HID device has started. Tests and Linux test hooks were updated to script/read UHID_START and assert that create waits for start, and platform docs now describe the new startup behavior.
Comment thread src/platform/linux/uhid_backend.cpp Fixed
Comment thread src/platform/linux/uhid_backend.cpp Fixed
@ReenigneArcher ReenigneArcher changed the title fix(Linux): force Sony name for UHID PlayStation fix(linux): restore PlayStation gamepad hotplug in Steam Aug 16, 2026
Keep SDL Linux consumer coverage on the evdev path for UHID PlayStation profiles, allowing CI to discover native-named controllers without depending on unavailable hidraw hotplug support.

Refactor UHID startup and reader handling and group fixture observations to clear the PR Sonar code smells and duplicated test setup.
Make the event reader const and scope the startup lock through an if initializer, preserving the existing synchronization while clearing the two remaining PR Sonar findings.
Match libvirtualhid UHID devices by their sysfs physical path so SDL HIDAPI can open controllers exposed with Sony's native product name. Restore PS4 and PS5 HIDAPI consumer coverage and grant the same scoped access to their input event nodes.
Document the backend-owned physical path that remains stable when libvirtualhid is linked directly into a host, and recommend it for native-named hidraw and input event nodes.
@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher marked this pull request as ready for review August 16, 2026 15:29
@ReenigneArcher
ReenigneArcher merged commit 7902b76 into master Aug 16, 2026
32 checks passed
@ReenigneArcher
ReenigneArcher deleted the fix/linux/playstation-pads branch August 16, 2026 15:55
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.

Linux: DualShock 4 and DualSense virtual gamepads do not register in Steam

2 participants