Page MenuHomeFreeBSD

hid: add Sony PS5 DualSense controller driver
Needs ReviewPublic

Authored by chris.longros_gmail.com on Fri, Apr 10, 5:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 21, 7:43 AM
Unknown Object (File)
Tue, Apr 21, 3:42 AM
Unknown Object (File)
Mon, Apr 20, 2:08 AM
Unknown Object (File)
Sun, Apr 19, 5:53 AM
Unknown Object (File)
Sun, Apr 19, 3:39 AM
Unknown Object (File)
Sat, Apr 18, 1:28 PM
Unknown Object (File)
Sat, Apr 18, 5:25 AM
Unknown Object (File)
Sat, Apr 18, 5:23 AM
Subscribers

Details

Reviewers
wulf
Summary

Add a driver for the Sony PS5 DualSense controller (054c:0ce6)
providing gamepad input via evdev, lightbar RGB LED control, and
player indicator LEDs through sysctl.

Signed-off-by: Christos Longros <chris.longros@gmail.com>

Test Plan

Tested on FreeBSD 16.0-CURRENT with a PS5 DualSense controller over USB.

  • Lightbar LED control: sysctl dev.ps5dualsense.0.led_state=1 (on), =0 (off) — verified lightbar toggles sysctl dev.ps5dualsense.0.led_color_r/g/b — set each channel individually, verified red, green, and blue on the controller lightbar.
  • Player indicator LEDs
  • Detach/reattach

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 72130
Build 69013: arc lint + arc unit

Event Timeline

chris.longros_gmail.com added a reviewer: wulf.
chris.longros_gmail.com edited the test plan for this revision. (Show Details)
sys/dev/hid/ps5dualsense.c
30

you can delete this line.

sys/dev/hid/ps5dualsense.c
134

Add Output report of 64 bytes total to HID report descriptor. It is used to properly size of USB buffers.

232

should be PS5DS_MAP_ABS(). It does not return to central position being released at least on PS4

233

Ditto

234

should be PS5DS_MAP_FLT(). It does return to central position being released at least on PS4

235

Ditto

236

For PS4 it is processed by hgame_hat_switch_cb() rather than directly mapped to ABS_HAT0X

250

This event belongs to touchpad device rather than game controller

251

May be it should be KEY_MUTE? It is better to consult with Linux driver to find out which device should produce which event after the button is pressed.

430

That is a race with sysctl handlers. Move this line in front of SYSCTL_ADD_PROCs or protect it with sx lock

chris.longros_gmail.com marked 2 inline comments as done.

Looks mostly good.
There are some missing parts. TODO:

  1. Add manpage. You may take share/man/man4/ps4dshock.4 as starting point. Do not forget to add missing touchpad and accelerometer support to BUGS section.
  2. Add ps5dualsense.c to sys/conf/files and sys/conf/NOTES
  3. Add ps5dualsense subdir to sys/modules/hid/Makefile
sys/dev/hid/ps5dualsense.c
129

Not a bug, but Usage (0x23) is better here as it matches hardware report descriptor.

IMO it would be good to rename driver from ps5dualsense to ps5dsense to be inline with ps4dshock. That is up to you.

sys/dev/hid/ps5dualsense.c
129

I have just glanced at https://controllers.fandom.com/wiki/Sony_DualSense#HID_Report_0x02_Output_USB and found out that Report 1 (input) size is 63 bytes and Report 2 (output) is 47 bytes not including leading ReportID byte. IMO both ps5ds_rdesc[] and PS5DS_OUTPUT_REPORT_USB_SIZE should be corrected to match this values.

Looks mostly good.
There are some missing parts. TODO:

  1. Add manpage. You may take share/man/man4/ps4dshock.4 as starting point. Do not forget to add missing touchpad and accelerometer support to BUGS section.
  2. Add ps5dualsense.c to sys/conf/files and sys/conf/NOTES
  3. Add ps5dualsense subdir to sys/modules/hid/Makefile

Thanks for the feedback. I will work on these and push a diff over the next days.