streetpea / chiaki-ng

Next-Generation of Chiaki (the open-source remote play client for PlayStation)
https://streetpea.github.io/chiaki-ng/
GNU Affero General Public License v3.0
1.05k stars 66 forks source link

[Guide] Adaptive triggers on clean archlinux (non-steam) #76

Open Gouster4 opened 1 year ago

Gouster4 commented 1 year ago

Hello. Im using chiaki4deck on ArchLinux desktop without steam. I got haptic feedback of dualsense working by default. But i cant get adaptive teiggers working.

Also, here is adaptive triggers implementation over bluetooth: https://github.com/Etaash-mathamsetty/trigger-control

Maybe chiaki4deck can make use of that code to get it working wirelessly.

Can you please make guide, or mention what packages and settings are reuiquired to get adaptive teiggers working without steam?

Thank you.

jbaiter commented 1 year ago

Have you set up your USB permissions correctly? Adaptive triggers require write-access to the hidraw devices. These are set up by default on the steam deck, but on your computer you may have to define them yourself.

to quote chatgpt since i'm too lazy to write this up myself:

To create a udev rule to allow user write access to hidraw devices, follow these steps:

  1. Open the terminal and create a new udev rules file by running the following command:

    sudo nano /etc/udev/rules.d/99-hidraw.rules
  2. Add the following rule to the file:

    KERNEL=="hidraw*", MODE="0664", GROUP="plugdev", ATTRS{idVendor}=="YOUR_VENDOR_ID", ATTRS{idProduct}=="YOUR_PRODUCT_ID"

    Replace "YOUR_VENDOR_ID" and "YOUR_PRODUCT_ID" with the respective vendor and product IDs of your HID device. You can find these IDs by running the lsusb command and identifying your device.

  3. Save the file by pressing Ctrl+O and exit nano by pressing Ctrl+X.

  4. Reload the rules by running the command:

    sudo udevadm control --reload-rules
  5. Unplug and reconnect your HID device.

Now, the user should have write access to the hidraw device specified in the udev rule. Remember to replace "YOUR_VENDOR_ID" and "YOUR_PRODUCT_ID" with the appropriate IDs for your device.

Make sure your user is in the plugdev group and adjust the vendor and product-id to match your controller.

Gouster4 commented 1 year ago

Thank you. But adaptive triggers still doesnt work. Plugdev group didnt exist, so i created one. Maybe its related to that previously missing group.

jbaiter commented 1 year ago

Please check if you have write access to at least one of the /dev/hidraw* devices:

for dev in /dev/hidraw*; do
  test -w $dev && echo '$dev is writable' || echo "$dev is not writable"
done

If you don't have write access, what are the permissions on the devices? (ls -l) If you added and activated the udev rule as outlines above and created the plugdev group, have you added your user to it? If you added the user to the group, did you log out and log in again to activate the group membership?

Gouster4 commented 1 year ago

Please check if you have write access to at least one of the /dev/hidraw* devices:

for dev in /dev/hidraw*; do
  test -w $dev && echo '$dev is writable' || echo "$dev is not writable"
done

If you don't have write access, what are the permissions on the devices? (ls -l) If you added and activated the udev rule as outlines above and created the plugdev group, have you added your user to it? If you added the user to the group, did you log out and log in again to activate the group membership?

I did rebooted pc just in case to apply changes. i dont have write access to any of them.

[home@media-server ~]$ for dev in /dev/hidraw*; do

  test -w $dev && echo '$dev is writable' || echo "$dev is not writable"

done

/dev/hidraw0 is not writable

/dev/hidraw1 is not writable

/dev/hidraw2 is not writable

/dev/hidraw3 is not writable

/dev/hidraw4 is not writable

/dev/hidraw5 is not writable

/dev/hidraw6 is not writable

/dev/hidraw7 is not writable

/dev/hidraw8 is not writable

/dev/hidraw9 is not writable

[home@media-server ~]$ ls -l /dev/hidraw*

crw------- 1 root root 240, 0 júl 31 12:50 /dev/hidraw0

crw------- 1 root root 240, 1 júl 31 12:50 /dev/hidraw1

crw------- 1 root root 240, 2 júl 31 12:50 /dev/hidraw2

crw------- 1 root root 240, 3 júl 31 12:50 /dev/hidraw3

crw------- 1 root root 240, 4 júl 31 12:50 /dev/hidraw4

crw------- 1 root root 240, 5 júl 31 12:50 /dev/hidraw5

crw------- 1 root root 240, 6 júl 31 12:50 /dev/hidraw6

crw------- 1 root root 240, 7 júl 31 12:50 /dev/hidraw7

crw------- 1 root root 240, 8 júl 31 12:50 /dev/hidraw8

crw-rw-r-- 1 root root 240, 9 júl 31 17:02 /dev/hidraw9

[home@media-server ~]$ groups home

wheel audio systemd-journal plugdev home

[home@media-server ~]$ cat /etc/udev/rules.d/99-hidraw.rules

KERNEL=="hidraw*", MODE="0664", GROUP="plugdev", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ce6"

[home@media-server ~]$ lsusb | grep Sony

Bus 013 Device 019: ID 054c:0ce6 Sony Corp. DualSense wireless controller (PS5)

[home@media-server ~]$ cat /sys/class/hidraw/hidraw9/device/uevent

DRIVER=playstation

HID_ID=0003:0000054C:00000CE6

HID_NAME=Sony Interactive Entertainment DualSense Wireless Controller

HID_PHYS=usb-0000:05:00.0-2.2.2.2.1/input3

HID_UNIQ=7c:66:ef:1a:0a:12

MODALIAS=hid:b0003g0001v0000054Cp00000CE6

[home@media-server ~]$

EDIT: KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0664", GROUP="plugdev" Seems to do the permission job. But its rule for all hidraw, and not only to DualSense

Adaptive triggers are working now.

Should i close the issue? Or we leave it open for Adaptive Triggers over bluetooth?

EDIT2: On Archlinux, package aur/rpcs3-udev does also create required udev rules for dualsense. Works for adaptive triggers. rpcs3-udev does create this file (plus dualshock udev rules that are not related to dualsense):

cat /etc/udev/rules.d/99-dualsense-controllers.rules

# PS5 DualSense controller over USB hidraw
KERNEL=="hidraw*", ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0ce6", MODE="0666", TAG+="uaccess"

# PS5 DualSense controller over bluetooth hidraw
KERNEL=="hidraw*", KERNELS=="*054C:0CE6*", MODE="0666", TAG+="uaccess"
Gouster4 commented 1 year ago

Adaptive triggers are working, but i somehow broke haptic feedback. But it has nothing to do with those udev rule, as i tried to disabling it, and just lost adaptive triggers with removed udev rule. Haptic feedback isnt working anymore (not related to udev rule). Any guess how can i get it working again?

jbaiter commented 1 year ago

Check your audio settings, haptics are sent as an audio stream over the USB Audio Device the DualSense is offering. Check if the device is muted, if the volume is too low, and if you can see the levels moving when there should be haptics on the controller (Astro's Playroom Controller Demo is good for testing)

Gouster4 commented 1 year ago

Check your audio settings, haptics are sent as an audio stream over the USB Audio Device the DualSense is offering. Check if the device is muted, if the volume is too low, and if you can see the levels moving when there should be haptics on the controller (Astro's Playroom Controller Demo is good for testing)

Thank you. Than this can be related to haptic feedback issue: usb 15-2.1.2.1: 1:1: cannot set freq 48000 to ep 0x1

Also, rumble issue can be also related to that i use pulseaudio server for audio output on another machine, and i use pipewire-pulse as client on current machine. But i guess, chiaki should access alsa directly bypassing pulseaudio for haptic, so i guess it shouldnt be an issue.

EDIT: Astro Playroom test does show following: Haptic feedback - doesnt work Adaptive triggers - does work Motion Sensor - does work Microphone - doesnt work

when haptic is sent over audio, and mic also doesnt work, seems issue is audio related. will try to temporary disable pulse client and see if it fixes the issue.

Disabled pulse client, and got same issue. Any suggestions how to fix that "cannot set freq", and diagnose audio profiles or something to get it working? Thanx.

jbaiter commented 1 year ago

Mic isn't implemented in Chiaki yet. I cannot recall ever seeing the cannot set freq error during development, it looks like it fails to set the desired sampling rate on the USB Audio Device. Can you verify that usb 15-2.1.2.1 1:1 is your DualSense Audio device?

The corresponding section in the code where the sampling rate is set is here: https://github.com/streetpea/chiaki4deck/blob/main/gui/src/streamsession.cpp#L701-L707

I tested this extensively on my Laptop with Debian and a DualSense and it always worked for me with 48KHz, but maybe things have changed with a firmware update? Can you try playing some bass-heavy audio on your laptop and route it to the DualSense audio device? Can you feel haptics? What's the sampling rate that Pipewire sets?

Gouster4 commented 1 year ago

Mic isn't implemented in Chiaki yet. I cannot recall ever seeing the cannot set freq error during development, it looks like it fails to set the desired sampling rate on the USB Audio Device. Can you verify that usb 15-2.1.2.1 1:1 is your DualSense Audio device?

The corresponding section in the code where the sampling rate is set is here: https://github.com/streetpea/chiaki4deck/blob/main/gui/src/streamsession.cpp#L701-L707

I tested this extensively on my Laptop with Debian and a DualSense and it always worked for me with 48KHz, but maybe things have changed with a firmware update? Can you try playing some bass-heavy audio on your laptop and route it to the DualSense audio device? Can you feel haptics? What's the sampling rate that Pipewire sets?

yes, this one is dualsense. and message appears only after connecting dualsense. Should be related to alsa. i will try bass heavy audio, but seems i have two problems with audio on dualsense.

1 dualsense should have at least two audio outputs, or one with at least 4 channels, while i see only stereo (two channels). Audio ouput over jack, integrated speaker and rumble. im not sure if speaker is implemented this way and should appear in dualsense, but im sure some audio output (speaker or jack) should be present.

2 When playng some audio to Dualsense output, i dont hear anything. I made sure its not muted in pavuctl and alsamixer. This can mean, that i have only rumble, and no audio routed, but can also mean that i got wrong alsa profiles, and no output is working at all.

streetpea commented 5 months ago

On the Manjaro dev vm I use there are multiple options for the controller. Maybe you can select a different option from a drop down menu in your sound settings

streetpea commented 6 days ago

@Gouster4 did you get this resolved?