Solved Only root seems to be able to access PlayStation 4 controller

Hi, I've been trying to get my wired PlayStation 4 controller to work on FreeBSD and followed the instructions in this thread. I'm not 100% sure if I needed to do anything but load the ps4dshock module because the issue was not resolved by just following these steps. However, I do know that the controller works because if I run an SDL application as root the controller is properly detected and appears to work, whereas running the same application as an unprivileged user results in the controller not being detected by SDL. My user is in the following groups:

master wheel operator games video ( master is just my user's group)

Is there anything else I must do to be able to access the controller as a normal user?

Thanks in advance.

P.S. I'm running 13.0-RELEASE on x86_64.
 
After loading the module, kldstat on mine (FreeBSD 13.1) showed:
Code:
ps4dshock.ko
hgame.ko

When you connected/reconnected the gamepad, what shows up in CTRL-ALT-F1 or by dmesg?

/etc/devd.conf is important for dynamically setting the permission/ownership of the device in /dev/ on bootup. That thread showed it in /usr/local/etc/devd/ds4.conf. In later versions of FreeBSD, that will be in /etc/ rather than /usr/local/etc/, because in 13.1 that is in the base system. (It can likely go into base directory either, either way.) Without rebooting, you can manually set the permission and ownership of the device to test it, though that will be lost on reboot.
 
/usr/local/etc/devd is the correct directory for the new config file.
/etc/devd can get overwritten on an upgrade.

Add a file to /usr/local/etc/devd something like this, call it something like ds4.conf
You will need to look at dmesg to figure out the correct vendor and product values.

notify 100 { match "vendor" "0x04B0"; match "product" "0x0434"; action "chgrp wheel /dev/$cdev && chmod 660 /dev/$cdev"; };
 
After loading the module, kldstat on mine (FreeBSD 13.1) showed:
Code:
ps4dshock.ko
hgame.ko

When you connected/reconnected the gamepad, what shows up in CTRL-ALT-F1 or by dmesg?

/etc/devd.conf is important for dynamically setting the permission/ownership of the device in /dev/ on bootup. That thread showed it in /usr/local/etc/devd/ds4.conf. In later versions of FreeBSD, that will be in /etc/ rather than /usr/local/etc/, because in 13.1 that is in the base system. (It can likely go into base directory either, either way.) Without rebooting, you can manually set the permission and ownership of the device to test it, though that will be lost on reboot.

I also have

Code:
ps4dshock.ko
hgame.ko

This is what shows up in dmesg

Code:
ugen0.2: <Sony Computer Entertainment Wireless Controller> at usbus0
usbhid0 on uhub2
usbhid0: <Sony Computer Entertainment Wireless Controller, class 0/0, rev 2.00/1.00, addr 7> on usbus0
hidbus0: <HID bus> on usbhid0
hgame0: <Sony Computer Entertainment Wireless Controller Gamepad> on hidbus0

Not much info, but lsusb shows:

Code:
Bus /dev/usb Device /dev/ugen0.2: ID 054c:05c4 Sony Corp. DualShock 4 [CUH-ZCT1x]

which is the vendor/product ID I have in /usr/local/etc/devd/ds4.conf (a file I had already created), it looks like this (just copy pasted from the RPCS3 wiki):

Code:
# DualShock 4
notify 100 {
        match "system"          "USB";
        match "subsystem"       "INTERFACE";
        match "type"            "ATTACH";
        match "vendor" "0x054c";
        match "product" "0x05c4";
        action "chmod 0666 /dev/$cdev";
};

Do I also need to chgrp it to wheel?

EDIT: Using this as the config file:

Code:
notify 100 {
    match "vendor"    "0x054c";
    match "product"    "0x05c4";
    action "chgrp wheel /dev/$cdev && chmod 660 /dev/$cdev";
};

still does not work.


EDIT: I figured out how to get diagnostic info from devd, I've included a file which contains all the output that it spits out when I plug in my controller.

It's reading the ds4.conf file and doing exactly as I requested. Correct me if I'm wrong but I probably also need to hook into this event:

Code:
Processing event '!system=DEVFS subsystem=CDEV type=CREATE cdev=input/event8'
Pushing table
setting *=!system=DEVFS subsystem=CDEV type=CREATE cdev=input/event8
setting _=system=DEVFS subsystem=CDEV type=CREATE cdev=input/event8
setting timestamp=1653226115.774772
setting system=DEVFS
setting subsystem=CDEV
setting type=CREATE
setting cdev=input/event8

Since this is the device node that SDL tries to access the controller through. At the moment its permissions are crw------- 1 root wheel.

EDIT2: I fixed it, I think. The problem seems to be that `/dev/input` wasn't searchable, so I added a rule to devfs.rules:

Code:
add path 'input' mode 0770 group wheel
add path 'input/*' mode 0660 group wheel

i.e. make the directory executable but keep the files themselves only read-write. The controller seems to work now.

Is this a dubious solution?
 

Attachments

  • devd.txt
    28.4 KB · Views: 120
Back
Top