Skip to content
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

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

AL2009man
Copy link

@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
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
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.
@AL2009man AL2009man marked this pull request as ready for review March 7, 2025 23:01
If EInputDeviceExplicit doesn't recognize a specific Controller Type or Device: it'll fallback to SDL's naming conventions. This helps troubleshooting Controller-related issues when using the debug console.
Changes some of EInputDeviceExplicit's names to match the device's official name (such as Nintendo Switch Pro Controller, Xbox Wireless Controller, Amazon Luna Controller, etc.)
@AL2009man
Copy link
Author

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

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

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.

3 participants