Skip to content

Added PlayStation device provider implementation (DS4/DS5 Lightbars)#454

Open
logicallysynced wants to merge 2 commits into
DarthAffe:Developmentfrom
logicallysynced:feature/playstation-provider
Open

Added PlayStation device provider implementation (DS4/DS5 Lightbars)#454
logicallysynced wants to merge 2 commits into
DarthAffe:Developmentfrom
logicallysynced:feature/playstation-provider

Conversation

@logicallysynced
Copy link
Copy Markdown
Contributor

@logicallysynced logicallysynced commented May 8, 2026

Summary

New RGB.NET.Devices.PlayStation provider for Sony's PlayStation controllers — DualShock 4 (PS4), DualSense, and DualSense Edge (PS5). Both USB and Bluetooth transports.

Speaks raw HID via the existing HidSharp dependency through RGB.NET.HID — no Sony driver, no DS4Windows, no SignalRGB, no HidHide, no DualSenseX.

Hot-plug aware: subscribes to DeviceList.Local.Changed, debounced reconcile (1500ms) to handle PnP bursts cleanly, plus a per-frame liveness pre-check to close the race between unplug and the next 30Hz trigger tick.

Output report layouts mirror Linux's hid-playstation driver. CRC-32/zlib (with Sony's 0xA2 output-report seed byte) is implemented in PlayStationCrc32 for the BT report variants.

Supported devices

Controller USB PID BT Notes
DualShock 4 v1 0x05C4 yes "JDM-001/011"
DualShock 4 v2 0x09CC yes "JDM-040/050/055"
DualShock 4 Wireless Adapter 0x0BA0 yes Sony's official BT bridge
DualSense 0x0CE6 yes "CFI-ZCT1"
DualSense Edge 0x0DF2 yes "CFI-ZCP1"

LEDs exposed

  • DS4: Custom1 (lightbar)
  • DS5 / Edge: Custom1 (lightbar) + Custom2..Custom6 (5 monochrome player indicator LEDs)
  • Custom1 is the lightbar on both controller families so a host-side mapping carries sensible meaning across DS4 and DS5
  • DualSense player indicators are monochrome — any non-black colour lights them at full brightness; black turns them off

The DualSense mic-mute LED is intentionally not exposed. The mic-mute button mutes the microphone in hardware regardless of host activity, so taking control of the LED would suppress visual feedback for an action that still happens. The provider does not set the MIC_MUTE_LED_CONTROL_ENABLE bit in valid_flag1, so the firmware retains its default LED-tracks-mute-state behaviour.

Coexistence / known limitations

  • Sony HID gamepads accept shared output writes by default, so this provider coexists with Steam Input and a game's native lighting integration. Last-writer-wins; at 30Hz the provider overrides intermittent setters.
  • DS4Windows / reWASD with "Exclusive Mode" enabled hold the HID handle exclusive — TryOpen fails and the controller is skipped with a Trace.WriteLine diagnostic.
  • HidHide hiding the controller from non-allow-listed apps means the device never appears in HidSharp enumeration.
  • Lighting only — no rumble, no adaptive triggers, no audio routing. Output report fields for those subsystems are zeroed and their valid_flag bits are clear so games / Steam Input continue to drive them normally.
  • Identity is derived from a hash of the device path. Switching the same controller between USB and BT produces a different DeviceName.

Full design notes + protocol references in RGB.NET.Devices.PlayStation/README.md.

Test plan

  • Builds clean against net10.0, net9.0, net8.0 (full solution dotnet build — 0 errors, 0 new warnings)
  • Verified DualShock 4 v2 (USB + BT) on Windows 11 — lightbar accepts arbitrary RGB
  • Verified DualSense (USB + BT) on Windows 11 — lightbar + 5 player indicators
  • Verified hot-plug (connect/disconnect/swap-transport) doesn't throw, AddDevice / RemoveDevice fire correctly
  • Verified mic-mute button still mutes + lights its LED with the provider running
  • DualSense Edge — same protocol as DualSense, expected to work, not yet verified on real hardware
  • macOS / Linux — HidSharp targets both but BT report formats and PnP semantics have only been verified on Windows

🤖 Generated with Claude Code

…lSense Edge)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@logicallysynced logicallysynced changed the title Added PlayStation-Device-Implementations Added PlayStation device provider implementation May 8, 2026
@logicallysynced logicallysynced changed the title Added PlayStation device provider implementation Added PlayStation device provider implementation (DS4/DS5 Lightbars) May 8, 2026
@logicallysynced
Copy link
Copy Markdown
Contributor Author

I have recently worked with Claude Code to implement this into Chromatics.

I thought I would share the outcome with everyone here in case there was additional interest.

@Aytackydln
Copy link
Copy Markdown
Contributor

This is great! LED update works while keeping game's adaptive trigger and vibration functions, whereas OpenRGB breaks them.

Hotplug support works great.

Only problem I had is while using USB connection, LED color only updates once. That may be an incompatibility I have with Steam interfering

@logicallysynced
Copy link
Copy Markdown
Contributor Author

logicallysynced commented May 9, 2026

Interesting, was this with a DS5? I only have a DS4 to test with and didn’t have any issues with USB, but can revisit with Claude 😅

Does BT work fine?

…teFile

Field reports against the USB transport showed lightbar updating once and
then freezing. Root cause: HidSharp's HidStream opens its handle with
FILE_FLAG_OVERLAPPED and runs an asynchronous WriteFile + GetOverlappedResult
dance. The PlayStation HID minidriver returns failure on the second and
subsequent overlapped writes, which HidSharp surfaces as IOException — the
queue's catch handler then suspends the queue.

Reintroduced HidRawWriter (synchronous Win32 WriteFile on a separate kernel
handle, BOOL return — never throws). On Windows, both DS4 and DS5 queues
prefer the raw writer; on non-Windows the queues fall back to HidStream.Write
since HidSharp's macOS/Linux paths don't share the overlapped Windows code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@logicallysynced
Copy link
Copy Markdown
Contributor Author

Made some changes with Claude, let me know if the experience is any better when you get a chance.

@Aytackydln
Copy link
Copy Markdown
Contributor

USB now also works with DualSense (PS5)
BT was working correctly already.

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.

2 participants