darthcloud / BlueRetro

Multiplayer Bluetooth controllers adapter for retro video game consoles
https://blueretro.io
Apache License 2.0
1.31k stars 109 forks source link

Add DualSense trigger effects #640

Closed coolbho3k closed 1 year ago

coolbho3k commented 1 year ago

This PR adds DualSense trigger effects to simulate a "click" when mapped to a digital button.

Currently, we reference the DS4Windows code's way to find the corresponding values to send to the controller from the perc_threshold setting for the trigger buttons. We make the trigger click when it reaches the configured threshold, simulating a digital button at some point in the middle of the travel.

The trigger effect is turned on when rumble is turned on. Here is the logic:

The above logic works out nicely, and will feel pretty authentic in most cases.

  1. For consoles with just analog L/R, the triggers won't click in most peoples' configurations.
  2. For consoles with just digital L/R, the triggers won't click by default if there's just one mapping. The triggers can be set up to click by adding an additional digital mapping.
  3. For GameCube, which has both analog and digital L/R on the same button, they will click at the digital threshold point.

Demo video: https://www.youtube.com/watch?v=nUx-Em1jNR8

Fixes #483

darthcloud commented 1 year ago

My appetite for config format changes is extremely low TBH.

If rumble is enabled just enable this aswell.

If done well this feature shouldn't bother people who aren't bothered with rumble to start with.

coolbho3k commented 1 year ago

Ok it looks all good from my ESP32 board. I'd like to try it on my GameCube internal board, but having a little trouble; I can't get the web firmware to recognize my build as hw2.

I checked the binary with a hex editor and I think the problem is the header doesn't contain hw2.

I'm building with configs/hw2/gamecube.

coolbho3k commented 1 year ago

Nvm,

for file in configs/hw2/*; do echo "$(git describe --always --tags --dirty) hw2 $(basename $file)" | cut -c -31 > version.txt; cat version.txt; cp configs/hw2/$(basename $file) sdkconfig; idf.py build; mv build/BlueRetro.bin build/BlueRetro_$(basename $file).bin; done

from the GitHub Action file looks like it does the trick.

coolbho3k commented 1 year ago

Still can't figure out how to get the threshold for "LM/RM mapped to digital trigger/button" from ps.c. Will keep looking tomorrow

coolbho3k commented 1 year ago

@darthcloud Okay I think I finally got it.

The logic is as follows. When the controller init:

darthcloud commented 1 year ago

First of thanks a lot for this PR.

I tried it and it's quite cool.

I made a few change, can you please review them?

I retested and it look fine.

coolbho3k commented 1 year ago

Everything looks good to me!

Looking forward to this!

coolbho3k commented 1 year ago

Actually I just tried it on my GameCube, I have 1 comment

darthcloud commented 1 year ago

I'm away for weekend, will build and retest when I'm back tomorrow night. But look good. Thanks!

darthcloud commented 1 year ago

Thanks again!!