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.06k stars 66 forks source link

[BUG] Haptic Feedback and Adaptive Triggers don't work correctly on Dualsense Edge #403

Open SrAntu88 opened 1 week ago

SrAntu88 commented 1 week ago

While using my Dualsense Edge to play any game, but more recently this issue is prominent on the new Astro Bot. Haptic feedback is very important in this game for some mechanics, but when playing normally, the controller just vibrates randomly. The Adaptive triggers also don't work correctly, for example, when in the main menu you are controlling the ship you can use the triggers to accelerate and should have both resistance and some feedback emulating the engines, but instead only some very small feedback is felt only when fully pressing the triggers. Everything works as intended when using a regular Dualsense controller.

Debug Log chiaki_session_2024-09-09_03-42-49-605605.log

To Reproduce Steps to reproduce the behavior:

  1. Start stream while using a Dualsense Edge controller
  2. Try moving or using any mechanic that makes use of Haptics or Adaptive triggers
  3. Both don't work like they do while playing directly on the console or using a regular Dualsense

Desktop (please complete the following information):

streetpea commented 1 week ago

@SrAntu88 I don't have a DualSense edge myself. If you are willing to run some test builds to gather the necessary information for me, I would be happy to assist with adding better support for the edge in chiaki-ng. Basically, you would just need to run some test builds I give you and give me back the logs.

jbaiter commented 1 week ago

Maybe this has something to do with the adjustable trigger stops on the Edge? Can you try playing around with the trigger stop sliders and see if that changes anything?

SpecialK has two extra fields in the HID Report in the upper 4 bits of the 40th and 41th byte that give the trigger stop values for the left and right triggers respectively:

/*41.0*/ uint8_t TriggerRightStopLocation : 4; // trigger stop can be a range from 0 to 9 (F/9.0 for Apple interface)
/*41.4*/ uint8_t TriggerRightStatus : 4;
/*42.0*/ uint8_t TriggerLeftStopLocation : 4;
/*42.4*/ uint8_t TriggerLeftStatus : 4;  // 0 feedbackNoLoad
                                         // 1 feedbackLoadApplied
                                         // 0 weaponReady
                                         // 1 weaponFiring
                                         // 2 weaponFired
                                         // 0 vibrationNotVibrating
                                         // 1 vibrationIsVibrating

Could it be that the haptic effects are scaled based on these values? Maybe we need to transmit them to the console, or do the scaling ourselves 🤔

Internally, SDL has these fields listed as part of a Uint8 rgucUnknown1[8] array that is not exposed via the controller events, unfortunately :-/ This means either patching SDL or accessing the DualSense Edge directly via hidapi to get access to the raw packets.

streetpea commented 1 week ago

For the haptics it looks like the speaker is potentially named the wrong thing would need you to run a version that prints the available speakers via sdl to determine what the name actually is for the dualsense edge audio device

@jbaiter do you have a dualsense edge?

streetpea commented 1 week ago

@jbaiter it seems to be part of the dualsense effects state … couldn’t you just set it there https://github.com/libsdl-org/SDL/blob/47283250442a15de423d3bf4368f914105c6364f/src/joystick/hidapi/SDL_hidapi_ps5.c#L133 before you send the effect here in Chiaki-ng https://github.com/streetpea/chiaki-ng/blob/c5e07f810c68c084544355efad5f2e3bff080a8b/gui/src/controllermanager.cpp#L570 or are you saying you don’t get that data from remote play?

jbaiter commented 1 week ago

My thinking was that since this is something that is set by the user, we would need to have a way to read out the setting from the controller to either send it to the console or do our own modifications to the trigger effects.

And no, I don't have a dual sense edge to experiment with:-/

streetpea commented 1 week ago

@jbaiter if it’s already set on the controller then why do we need to re-write it … or do the values change based on something else?

jbaiter commented 1 week ago

I think you misunderstood :-) There are two hardware sliders on the back of the DualSense Edge that you can use to change the "stop point" for each of the triggers. These values are part of the input report you can get from the DualSense via USB or Bluetooth.

My (purely speculative) suspicision is that since the trigger stop plays a role in quite a few effects, that these values are transmitted to the console and are used there to change the trigger effects/haptics that are sent to the controller. This might be why the effects are less intense on the Edge in OP's case.

So if this was the case, and we wanted to get the same effects as on the console, we would need to have a way to read out those stop values from the controller's input report.

streetpea commented 1 week ago

@jbaiter alright I understand now.

streetpea commented 1 week ago

@SrAntu88 is the dualsense edge attached via usb? If not, please attach via usb. If it is attached via usb please go into your sound settings and find the dualsense speaker and make sure it is configured on and to play 4 channel (quad) audio. As for your adaptive triggers make sure there is no stop point set as that will turn off the adaptive triggers. @streamingdv was able to test and confirm that adaptive triggers and haptics work fine on Windows 11 with rog ally x so if the above is done it should work.

SrAntu88 commented 1 week ago

@streetpea Yes, the controller is wired via usb. I just enabled the speaker and the haptics seem to work fine now (maybe still a bit too weak compared with the normal dualsense, but couldn't really tell without trying them side by side). But the adaptive triggers even after playing with the trigger stops still don't work correctly. They are far too weak and need to be completely pressed down to even begin to do anything. They also fire randomly when being pressed down even when there should be no resistance.

SrAntu88 commented 1 week ago

Also @streetpea I would be glad to run some test builds, no problem.

streetpea commented 1 week ago

@SrAntu88 can you test the controller using the official app on Windows?

SrAntu88 commented 1 week ago

@streetpea What app do you mean, the Playstation Accessories?

streetpea commented 1 week ago

@SrAntu88 this one https://remoteplay.dl.playstation.net/remoteplay/lang/en/

SrAntu88 commented 6 days ago

@streetpea Sorry for the delayed response. I tried the official Remote Play app and all features work as intended Haptics and Adaptive Triggers

streamingdv commented 6 days ago

@SrAntu88 which adaptive trigger effects and haptic feedback Events don't work correctly on your end? I tried Chiaki-ng on my Rog Ally X and all effects work as expected.

SrAntu88 commented 6 days ago

@streamingdv After playing around and comparing the official Remote Play and Chiaki, I find that the Adaptive triggers work almost perfecly but there's something a little bit off about them when playing on Chiaki. I can't pinpoint what the issue is, it may be the resistances are treated differently by each program (for example when pulling a bow). On Remote Play I find them more "natural" or "gradual" than on Chiaki-ng, can't really explain it but there's a subtle difference (or maybe it's placebo and I'm dumb XD).

And for the Haptic feedback, after comparing both apps, Chiaki played the effects more or less the same but at 5% the strength they do on Remote Play. They feel much weaker and some effects can't be appreciated at all because the strength of the feedback is so low.

I wish I could record something to show you but the differences wouldn't be appreciated on camera

streetpea commented 6 days ago

I pulled the latest proto files from the current version of the official remote play app and there is no separate controller type for DualSense edge, only the type for DualSense so I would be surprised if there was edge specific logic.

streetpea commented 6 days ago

@SrAntu88 Can you post a new log to make sure haptics is working correctly?

SrAntu88 commented 6 days ago

@streetpea Sure thing: chiaki_session_2024-09-10_22-24-33-811811.log

Also weird bug, when pressing the "Open" button that would take you to the Log Directory it freezes and crashes Chiaki and I have to Alt+F4

Also I recorded with my phone 2 vids to give you an example of the difference between the intensity of the haptics between Remote Play and Chiaki (turn the audio up, also don't mind the video quality I had to compress de video a ton to make it fit the 10 MB limit xd)

Chiaki-ng: https://github.com/user-attachments/assets/2ad4d711-986e-4a13-9d7f-9939f1c2a315

Remote Play app: https://github.com/user-attachments/assets/0265fafb-4d02-49ef-a678-9a7bccbbdbab

SrAntu88 commented 6 days ago

Also, If you see any XBOX 360 controller or smthing like that in the log file, I forgot I had DS4Windows opened but it's all the same issues without it, if that makes any difference.

streetpea commented 6 days ago

For the haptics audio it’s just playing the audio file that it receives from the PlayStation and we’ve only told the PlayStation that the controller is a dualsense so no alterations would occur there. In other words, we would get the same audio file as with the dualsense. I guess they could be manually increasing the strength of the audio for the edge but that seems unlikely tbh. Have you tried increasing the volume on the dualsense edge speaker @SrAntu88 ?

SrAntu88 commented 6 days ago

@streetpea it's at the max windows allows

streetpea commented 6 days ago

@streamingdv do you see the same lower haptics on your DualSense edge?

streetpea commented 6 days ago

@SrAntu88 can you download audacity for Windows (https://www.audacityteam.org/download/windows/) and record playback on your DualSense Edge speaker output by opening audacity, then ctrl + p then edit your Host and recording settings (you can leave the speaker settings at the default) to look like the following: SetRecordingDeviceDualSense Then play a particular segment and record the audio sent to your DualSense edge with audacity using ps remote play and also with chiaki-ng and compare. (Note: You should be playing the same segment for comparison)

SrAntu88 commented 6 days ago

@streetpea On the left the Remote Play app, on the right chiaki-ng image

streetpea commented 6 days ago

@SrAntu88 can you get a ratio between the 2 like maybe 5x or something? Also can you compare the regular audio of the 2 apps?

SrAntu88 commented 6 days ago

@streetpea Had to find what tool in Audacity to use to find the difference in volume, I guess it's this xd image

Also the regular audio from both apps I would say it's the exact same, no noticeable change if there is one

streetpea commented 6 days ago

@SrAntu88 can you compare the 2 apps with a regular dualsense?

streetpea commented 6 days ago

Also can you get some more comparisons, it looked like a bigger difference than 1.8x which is what those 2 decibel values correspond to

SrAntu88 commented 6 days ago

@streetpea I've just tried with the regular Dualsense and, believe it or not, it's the complete opposite. The Remote Play app now is super low and Chiaki-ng is the correct intensity.

image

streetpea commented 6 days ago

Can you also feel the difference in that case @SrAntu88?

SrAntu88 commented 6 days ago

Yea it's the same difference as before but the Remote Play app is lower instead

streetpea commented 6 days ago

@SrAntu88 can you try this build https://drive.proton.me/urls/2JEZ5V7W2W#BzQA8jMAzwax. It doubles haptics intensity for DualSense edge?

SrAntu88 commented 6 days ago

@streetpea I've just tried it. It feels much better but now it's a bit too much. image

SrAntu88 commented 6 days ago

I would say to tune it down to roughly 75% what it is right now

SrAntu88 commented 6 days ago

@streetpea Oh and also forgot to mention on that new build Adaptive Triggers didn't work at all

streetpea commented 6 days ago

@SrAntu88 try this build please (I updated the build from the previously deleted comment to the correct one in this one): https://drive.proton.me/urls/2JEZ5V7W2W#BzQA8jMAzwax

SrAntu88 commented 6 days ago

I'm on it

SrAntu88 commented 6 days ago

@streetpea Okay, this new build fixes the Adaptive triggers, but the Haptic Feedback is still a bit too strong. It's nearly there image

streetpea commented 6 days ago

@SrAntu88 can you make sure you downloaded the build shown in the comment currently and not the deleted comment

SrAntu88 commented 6 days ago

Yeah I downloaded the one on the last comment

streetpea commented 6 days ago

@SrAntu88 please use this build and find an appropriate value and tell me. You can set the DualSense edge haptic intensity in the video settings. I can then take out that option and just use that constant. Note: You can use the arrow keys (or controller) to adjust the values precisely. https://drive.proton.me/urls/2JEZ5V7W2W#BzQA8jMAzwax

SrAntu88 commented 6 days ago

Okay I'll get back to you when I find the value that better fits

SrAntu88 commented 6 days ago

@streetpea okay after playing around a bit, a value of around x0.86/x0.87 is the closest i can get it. Though making 0.01 increments it's really hard to tell the difference I think it's as good as I can get it.

streetpea commented 6 days ago

@SrAntu88 I thought you said it was too weak to begin with. You want to make it weaker?

SrAntu88 commented 6 days ago

I just tried again the original "unfixed" Chiaki-ng and it has a weaker feedback than the Remote Play app. Now, in this last version you sent, I don't know what base value you're getting for the ratio, but x1.00 it's stronger than the "unfixed" Chiaki-ng version. I'm just telling you what value I find the most similar to the regular Remote Play app using the slider you implemented.

streetpea commented 4 days ago

@SrAntu88 since you and @streamingdv got different results for your DualSense Edges, I decided to check my regular DualSense against the official app and chiaki-ng. They both produced nearly equivalent results on my Windows 11 PC. I think something wonky is going on with your computer as you mentioned a stark difference between the DualSense output on both apps. This is probably contributing to why the edge isn’t working properly on your PC but is working fine with @streamingdv’s windows 11 device.

Note: I cycled through the Astro bot menu for the comparison as that was an easy way to reproduce relatively consistent haptic pulses (all around a 1-2 dB range from each other) for comparison.

SrAntu88 commented 4 days ago

I don't really know what could be wrong with my PC. Perhaps a faulty dualsense edge driver? Anyway, for now I think I'll stick with this version of Chiaki that has the slider, that works perfectly for me at least and has given me the best results. I'll try to reinstall the drivers. I hope any of my issues could've been of help to the project. Thank's for all the help!

streetpea commented 4 days ago

@SrAntu88 the reason why I think something strange is happening is because you reported differences between the regular DualSense haptics using chiaki-ng and the official remote play app. However, on my system there is no such difference (they are equivalent / have the same range of values when scrolling through the menus of Astro Bot).