Skip to content

Steam Virtual Gamepad support / Steam Input sharing Device Info with SDL #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AL2009man
Copy link
Contributor

@AL2009man AL2009man commented Mar 6, 2025

As I was working on #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 #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:

Sonic.s.Steam.Controller.has.been.Unleashed.mp4

@AL2009man AL2009man closed this Mar 6, 2025
@AL2009man AL2009man deleted the SteamVirtualGamepad-Prompts branch March 6, 2025 19:04
@blueskythlikesclouds
Copy link
Member

What's up, why'd you close it?

@AL2009man AL2009man restored the SteamVirtualGamepad-Prompts branch March 6, 2025 19:15
@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 6, 2025

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.

@AL2009man AL2009man reopened this Mar 6, 2025
This changes the way how a Controller will be prioritized. By default: it'll always prioritize based on Player 1. It should play nicely with Steam Deck's internal inputs when Steam Input is active
… same time.

An attempt to remedy the Lightbar activation. While Player 2/3/4 will override the in-game lightbar event upon connection: it'll later revert back to the in-game event.
To avoid "the Controller is leaking" situation, there's now a Gamepad stat management that should reset Controller state based on connected controller.
Another attempt to fix the lightbar by redoing the controller state mangement. For some reason: the Lightbar gets disabled when a controller is already plugged prior to game launch. It reverts back to normal until the next game event.
@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 7, 2025

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.

To ensure all Hotplug-related changes don't accidentally get leftover: this commit will revert all the back back to the accidental removal of Button Label's note.
@DeaTh-G
Copy link
Contributor

DeaTh-G commented Mar 10, 2025

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.

@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 10, 2025

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.

@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 10, 2025

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

image

@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 12, 2025

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:

2025-03-11.9-45-46.PM.mp4

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 #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..

@DeaTh-G
Copy link
Contributor

DeaTh-G commented Mar 12, 2025

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.

@DeaTh-G DeaTh-G added this to the v1.0.3 milestone Mar 20, 2025
@hyperbx
Copy link
Member

hyperbx commented Mar 20, 2025

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.

image

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.

since hedge-dev#1045 will include it: we're gonna get rid of it on this code section to avoid conflicts.
Based on @hyperbx's suggestions: It'll look for SDL's Controller Name as opposed to EInputDevice's naming scheme.
Now that SDL_GameControllerName handles Controller naming conventions, the hid.ccp portion of GetInputDeviceName is no longer needed.
@AL2009man
Copy link
Contributor Author

AL2009man commented Mar 21, 2025

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 Jumping in gameplay keeps pausing game #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.

AL2009man added a commit to AL2009man/UnleashedRecomp that referenced this pull request Mar 22, 2025
to avoid conflictions with other PRs (hedge-dev#1086 and hedge-dev#1045): the remaining codebae was restore to how the master build look.

the downside is that it makes it far harder to test it's behavior with Steam Input mode. but this is only temporarily until it gets added to the Master branch.
@AL2009man AL2009man mentioned this pull request Mar 26, 2025
8 tasks
@blueskythlikesclouds blueskythlikesclouds merged commit b282cbc into hedge-dev:main Mar 29, 2025
1 check failed
@AL2009man AL2009man deleted the SteamVirtualGamepad-Prompts branch March 29, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PlayStation Controller Icon detection doesn't work through Steam Input on Linux
4 participants