Steam Virtual Gamepad support / Steam Input sharing Device Info with SDL
As I was working on https://github.com/hedge-dev/UnleashedRecomp/pull/1045, I've been searching for a way to get SDL2 to handshake Steam Input. At first, I needed to put a SDL2.dll file.
but ultimately, with the help of GitHub's Pilot AI. I've been able to determine the problem. Turns out SDL_GameControllerTypeForIndex(index) is being used as opposed to return SDL_GameControllerGetType(controller). I might be wrong on this one.
After swapping a few codes and new additions (which also helps prepare for improved Nintendo Switch controller support down in the line), I'm able to get Steam Input to handshake the game directly and will handle the Button prompt detection system. Going forward: if a player is using a Steam Deck, and they hook up with a PlayStation gamepad: the button prompts will be properly shown on screen. This also addresses https://github.com/hedge-dev/UnleashedRecomp/issues/371
I already tested it on my end with Steam Input and without Steam Input on Windows 11. However: additional testing will be required before submitting for review, especially on Linux.
But, here's how this new code now functions when you set the .exe file as a non-Steam Shortcut and forcefully override Steam Input mode:
https://github.com/user-attachments/assets/90300479-e5d4-47f7-9bf3-292d89c6d9dd
What's up, why'd you close it?
What's up, why'd you close it?
sorry, I was actually cleaning things up while I was working on improving controller slot logic. Let me try to restore pull request ASAP.
Ultimately, I decided to move all Controller Hotplug changes to a separate branch (with it's own Pull Request, coming soon) for the time being, this will avoid conflicting with the work that was already done with Steam Virtual Gamepad.
for this Pull Request: it'll be ready for review shortly.
edit: ok, it is now ready for review. if this merge request gets accepted to the Master build: I might suggest updating PlayStation controller support and Input Remapper section on README.MD.
so, Unleashed Recomp has its own EInputDeviceExplicit, which will handle Controller Type detection. if a unknown controller is detected: the debug console will tell you "Controller Detected: Unknown".
I was researching an alternative way to get the console to also see the device name, and I figured out the problem. Do you know SDL_GameControllerName? it'll have its own naming conventions, so I needed to show the SDL's naming conventions on top of the game's very own.
now: it'll use SDL2's controller naming conventions as a fallback if the game doesn't know a "PS6 Controller" exist. This solves a specific issue when trying to use a Steam Controller/Steam Deck while making it easier for troubleshooting/debug purposes.
I finally got time to test it the behaviour didn't seem to change with Steam Deck when running it with Steam Input enabled. Here's the results in Desktop Mode with a DualShock 4 v2:
- Icon Detection works in when launching through the Start Menu (Steam Input is not interfering here).
- Icon Detection does not work when launching the game through Steam with Steam Input Enabled.
- Icon Detection works when launching the game through Steam with Steam Input Disabled.
As for Gaming Mode with the same controller:
- Icon Detection does not work when launching the game through Steam with Steam Input Enabled.
- Icon Detection works when launching the game through Steam with Steam Input Disabled.
I finally got time to test it the behaviour didn't seem to change with Steam Deck when running it with Steam Input enabled. Here's the results in Desktop Mode with a DualShock 4 v2:
- Icon Detection works in when launching through the Start Menu (Steam Input is not interfering here).
- Icon Detection does not work when launching the game through Steam with Steam Input Enabled.
- Icon Detection works when launching the game through Steam with Steam Input Disabled.
As for Gaming Mode with the same controller:
- Icon Detection does not work when launching the game through Steam with Steam Input Enabled.
- Icon Detection works when launching the game through Steam with Steam Input Disabled.
I tested it on Windows first using GitHub Actions. even tho it actually works with my compiled build: the GitHub Action file doesn't work. I think GitHub Actions seems to pretend my changes do not exist, at all.
I'm going to investigate why GitHub Action isn't looking for my chances. I'm starting to believe something went terribly wrong with my fork, and I might need to repair it (the nuclear option would be to delete my fork, refork and redo the pull request.
to make it easier for @DeaTh-G and everyone: I compiled a Windows devbuild for everyone to test. Just unzip the file using 7zip or NanaZip and dragged the .exe file to your file. For Linux: this might involve extra steps.
However, I already tested the Windows devbuild it on my end and it works as it should (edit: I also tested it on Linux via Flatpak, it also works properly). the alternative would be to download my fork, select SteamVirtualController branch, and build it there. You can verify if it is the right build if the version numbers mention "SteamVirtualGamepad"...only for Windows OS, but alternatively: you can try opening the Console and keep a eye out on the Detected Controller info when swapping between Controller Types.
https://drive.google.com/file/d/1mNr_WXOVuU-iQ0Kv1v1nMN7yTKCqIUSH/view?usp=sharing
side-note: Even if you download it from there (and I make sure it has nothing but the .exe file only), it's still better to compile the build yourself.
I found out the issue.
For some reason: it's using the Main branch (and I mean, this repository ) and NOT the AL2009man fork's "SteamVirtualGamepad-Prompts" branch. This will explain why my Nintendo Switch controller is still following button labels and the Device Info still says "Xbox One" instead of "Xbox Wireless Controller" on the console...despite my build having no problem with it.
I will have to find a way to remedy the issue in my end, the alternative would be to forward all the changes to the main branch for case of simplification
While I watched for an unrelated GitHub Action issue to be solved: I needed to compile a Linux build myself in order to test it on Steam Deck (this took several hours to get it working).
I will update the existing G-Drive link to include both Linux and Flatpak app/flatpak file who wanna test out...but I strongly suggest (and safer) building it thru my forked repository. This will remain the case until GitHub Action works properly for this Pull Request.
I conducted a super quick test using Steam Deck, although: I don't have access to the console (it might be in use on Konsole, tho?), I can confirm a few things!
- PlayStation glyphs now works when on either Desktop Mode under Steam Input, or within Game Mode.
- the same behavior applies when using Steam Remote Play
but due to the way how Steam Deck's onboard input system is handled (as it's considered to be "Player 1"): it'll try to look at Steam Deck first (will default to Xbox prompts) before PlayStation's turn. See the video below:
https://github.com/user-attachments/assets/624cbc29-5bdb-4a35-8daa-11678af96329
This might be fine for those who who wanna skip straight to the game without needing to watch the bootup sequence... but those who are gonna be on the Installation step: they'll see the problem for at least 2-3 seconds before it disappears or the moment you press any Inputs.
This issue is mostly fixed on https://github.com/hedge-dev/UnleashedRecomp/pull/1188, where it'll attempt to prioritize "Player 1" to a PlayStation Controller and vice-versa, but this can be improved upon-- depending if it's needed..
Used your drive link, can confirm it PlayStation icon detection now behaves nicely with Steam Input enabled on the Steam Deck in both Desktop and Gaming Mode.
so, Unleashed Recomp has its own
EInputDeviceExplicit, which will handle Controller Type detection. if a unknown controller is detected: the debug console will tell you "Controller Detected: Unknown".I was researching an alternative way to get the console to also see the device name, and I figured out the problem. Do you know
SDL_GameControllerName? it'll have its own naming conventions, so I needed to show the SDL's naming conventions on top of the game's very own.now: it'll use SDL2's controller naming conventions as a fallback if the game doesn't know a "PS6 Controller" exist. This solves a specific issue when trying to use a Steam Controller/Steam Deck while making it easier for troubleshooting/debug purposes.
EInputDeviceExplicit was added specifically for touchpad support for using different parameters depending on whether a DualShock 4 or DualSense is used. Keeping the naming convention in hid::GetInputDeviceName() isn't important, so feel free to omit that and just use the name SDL returns instead.
quick note: if Version 1.0.3 is around the corner and this PR will be part of it: I strongly suggest updating portions of README.md regarding "PlayStation controller as an Xbox controller".
instead: it should inform Steam client users two things:
- verify if the Desktop Layout (for External Controllers outside of Steam Controller/Remote Play) is using keyboard or controller bindings and ensure it's completely disabled (or rebind everything to be completely empty). For some reason: it might default to Keyboard/Mouse config layout meant for Desktop navigation. and It's typically the source of sooooo many issues that people have reported even outside of UnleashedRecomp. (this covers https://github.com/hedge-dev/UnleashedRecomp/issues/515, but I might investigate how to remedy the issue myself in a separate PR that covers Controller Hotswaps)
- Informed that Steam Input mode (assuming the player made UnleashedRecomp.exe/app as a non-Steam Shortcut) can detect and provide the correct button prompts, but still recommends native support for the best possible experience.
