msxmine / SI2DSU

SteamInput to DSU wrapper
23 stars 2 forks source link

Rumble support (exposing an XInput device) #4

Open doctor-amaton opened 3 years ago

doctor-amaton commented 3 years ago

Hi!

I'm not currently certain as to why you had to resort to use the DSU Client only, instead of allowing steam to also present the XInput emulator they use... There might be some techincal reasoning, or is it just not implemented yet?

I'm not sure if I'll be able to help out, but I will look into it and see if I can come up with a PR for it, in case it's possible.

Thanks for this project BTW, it's exactly what I needed for my setup! (Steam Link + Bluetooth DS4 + Cemu).

msxmine commented 3 years ago

Steam switches it's Xinput emulation off automatically when a game has a SteamInput mapping file. Without that mapping file (retaining Xinput), it only gives you access to the Gyro/Accelerometer data, Haptics/Rumble, ability to set LED color/brightness and general info about the controller. No way to access any analog/digital inputs. As you noticed, the DSU protocol also doesn't include any rumble/feedback support so for now it has to go through Xinput. As such, if I wanted to add rumble support while still sending button states over DSU, I would either have to emulate a new Xinput device myself with something like ViGEm which is outside the scope or switch from reading them via SteamInput to reading them via Xinput, and only use SteamInput for motion data.

However, this all assumes that your client has the ability to use multiple Input apis at the same time to use rumble. This is true for Cemuhook but not for vanilla cemu for example afaik. If that is the case, you may as well use Xinput for the buttons directly without it passing through DSU, so adding that feature would be pointless.

For that (your) usecase, you should be able to just delete the SI2DSU game_actions_appid.vdf file from your steam install directory. I'm not sure what the API calls will do without that file but I'm guessing that they will just return zeros/fake data for digital/analog actions but should still work for motion. So you should end up with working Gyro over DSU and working buttons/rumble over Xinput by just deleting that single file. If it crashes or something let me know. It should be possible to detect whether Steam is in SteamInput or Xinput mode with GetDeviceBindingRevision or GetGamepadIndexForController and handle the presence/lack of the binding file properly

doctor-amaton commented 3 years ago

That was a delight to read, very informative.

I'll be testing and update this as soon as I can.

EDIT: Tested it, it works flawlessly, although I also had to choose a different (default) controller configuration in the steam controller settings, as it was taking a personal (modified action set to match the buttons) configuration file instead of just the regular base in the installation directory.

Now everything is 100% perfect! (well except that people think I play a lot of Plants vs Zombies now hahaha) Thanks!