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

MonoGame 3.8.1 turns off controller immediately after turning on #8082

Open
2 tasks done
Bikonja opened this issue Oct 14, 2023 · 7 comments
Open
2 tasks done

MonoGame 3.8.1 turns off controller immediately after turning on #8082

Bikonja opened this issue Oct 14, 2023 · 7 comments
Milestone

Comments

@Bikonja
Copy link

Bikonja commented Oct 14, 2023

Prerequisites

  • I have verified this issue is not present in the develop branch
  • I have searched open and closed issues to ensure it has not already been reported.

MonoGame Version

MonoGame 3.8.1.303

Which MonoGame platform are you using?

MonoGame Cross-Platform Desktop Application (mgdesktopgl)

Operating System

Windows

Description

Even in a blank MonoGame project, if a MonoGame window is running, the controller (specifically using an Xbox One controller with the wireless adapter, not sure if it makes a difference) works initially, however if the controller is turned off while the game is running, then turned on again, the controller immediately turns off.

I verified my code isn't the issue by testing against a blank MonoGame app as well as the tutorial from the MonoGame website.
I also verified that this did not occur in MonoGame 3.8.0.1641 by taking the same project, downgrading MonoGame and running the project. The same issue with the controller does not occur (but due to other incompatibilities my game does not work correctly with the older version).

A little bit of extra info, I tried debugging my app to see what the state of "GamePad.GetState" is in this scenario and, while it didn't provide me with overly useful info, I was able to observe that if I'm stopped in the debugger while connecting the controller, and then resume the app after the controller has turned on, the controller does not turn off.

I am trying to run a local build of develop branch to see if the issue is present there, but am currently unable to do so, I'll post back if I'm able to get it running.
I was able to run develop and yes, the problem is present in latest develop branch as well.

Steps to Reproduce

  1. Create an empty MonoGame Cross-Platform Desktop Application using MonoGame 3.8.1.303
  2. Run the game (either from VS or outside of VS, either debug or release, doesn't matter)
  3. Turn on controller (if not already on), specifically Xbox One controller with Wireless Adapter, though not sure if applicable to all controllers
  4. Turn off controller (hold the Big Button for ~5 seconds)
  5. Turn the controller on again (game should still be running through all these steps)

Minimal Example Repo

No response

Expected Behavior

The controller should now be on and ready to use with the game.

Resulting Behavior

The controller turns on and then immediately turns off.

Files

No response

@Bikonja
Copy link
Author

Bikonja commented Oct 14, 2023

After debugging a bit, I can see that it is the SDL_JoystickOpen call that turns the controller off, specifically this line, called from this line.

@Bikonja
Copy link
Author

Bikonja commented Oct 14, 2023

After searching, I found someone encountered the same issue in the Ryujinx Switch emulator.
They already did a bunch of investigation and it appears this issue was resolved in SDL in this commit.

So on MonoGame side, an update of SDL is needed.

@Bikonja
Copy link
Author

Bikonja commented Oct 14, 2023

For reference, downloaded the first (non-RC) release after that commit of SDL (2.28.0) and put the DLL manually into my project, works perfectly, no issues and the controller does not turn off anymore.

@Vectovox
Copy link
Contributor

Vectovox commented Oct 16, 2023

Well investigated @Bikonja ! I can confirm all of the above in DesktopGL, with a Wireless Xbox One Controller, on my end as well.

In my case, I just tried the latest SDL2 DLL and that works as opposed to the latest MG-develop.

@Zorcher
Copy link

Zorcher commented Feb 12, 2024

As a result of this fix, it appears there is now a new issue. When you join in a player first with an XBox One controller using the wireless adapter and then connect another controller that isn't an XBox One controller, that controller joins in as two players instead of one. It appears there is a "ghost" controller added that shouldn't be there. Using a version of SDL prior to v2.28.0 does not reproduce this new issue.

@mrhelmut
Copy link
Contributor

Ghost controllers are almost always due to third party controller drivers doing hacky stuff (x360ce, unofficial drivers...) or software to bind virtual keys (joy2key, vjoy, vxbox...), and sometime even remote desktop software messing up with drivers (Monect is notoriously breaking stuff). From my experience, even though it looks related to SDL, it's likely not. I mean, I can be proven wrong, but 100% of the times I've received such reports on our games, it's been due to local drivers/software.

@Zorcher
Copy link

Zorcher commented Mar 3, 2024

This is most definitely an SDL issue as I don't have to update MonoGame or anything else. Just switch to the latest version of SDL by modifying the nuget package itself, (making a backup before doing so), and switching between SDL versions to replicate the issue.

@mrhelmut mrhelmut added this to the 3.8.2 milestone Mar 12, 2024
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 a pull request may close this issue.

4 participants