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

specific controller (nintendo switch online official snes controller) keeps disconnecting every few seconds with sdl2 driver on retroarch #12470

Open
yanon182 opened this issue Mar 5, 2025 · 14 comments

Comments

@yanon182
Copy link

yanon182 commented Mar 5, 2025

Hello! Basically as the title said, All my other controllers work fine (switch online n64 controller, xbox one, xbox series controllers) all stay connected and work fine but for some reason the snes one keeps disconnecting every few seconds then reconnecting? I tested other drivers (xinput and dinput) and neither one have this issue and it stayed connected fine, I also tested in multiple seperate emulators and the snes controller performed great with no disconnects so ive concluded its not the controller or bluetooth connection since the issue only happens with sdl2. I have to use sdl2 drivers because its the only one that properly identifies and perfectly maps my different controllers for me in retroarch, the others dont. Ive also tried multiple different sdl2.dll versions, 2.20.12 (which seemed to work fine just a few weeks ago) and up to 2.32.2 (the newest version i found) all of which exhibit the same behavior. Does anyone know whats going on or if there is a fix?

@stbeaumont98
Copy link

I'm not sure if it's exactly the same issue, but my NSO SNES controller also disconnects when using the latest SDL2 with Retroarch. Let me explain what I've tested:

When pressing and holding any button on the specific controller, the input is detected for 4-5 seconds before it stops, and then I have to press and hold the button again, just for the issue to reoccur.

Like you, this happens with my NSO SNES controller via Bluetooth using the SDL2 driver in Retroarch. The issue also occurs with my NSO Sega Genesis controller, but I have no problems with any other controller.

I also prefer the SDL2 drivers for proper controller detection/mapping, so if the issue could be resolved in some way, I'd really appreciate it!

@yanon182
Copy link
Author

yanon182 commented Mar 8, 2025

I'm not sure if it's exactly the same issue, but my NSO SNES controller also disconnects when using the latest SDL2 with Retroarch. Let me explain what I've tested:

When pressing and holding any button on the specific controller, the input is detected for 4-5 seconds before it stops, and then I have to press and hold the button again, just for the issue to reoccur.

Like you, this happens with my NSO SNES controller via Bluetooth using the SDL2 driver in Retroarch. The issue also occurs with my NSO Sega Genesis controller, but I have no problems with any other controller.

I also prefer the SDL2 drivers for proper controller detection/mapping, so if the issue could be resolved in some way, I'd really appreciate it!

This is my exact problem too, You explained it better lol. same controllers having the same issues. I noticed the notifications on retroarch shows the controller connects but then disconnects, it used to not do that, and its almost like it is disconnecting for a second then reconnecting. Not to windows but to retroarch and sdl2, windows its flawless cuz i tested it on external emulators and it doesnt do that. But yes, Same issue! Hope its resolved soon.

@yanon182
Copy link
Author

yanon182 commented Mar 8, 2025

I'm not sure if it's exactly the same issue, but my NSO SNES controller also disconnects when using the latest SDL2 with Retroarch. Let me explain what I've tested:

When pressing and holding any button on the specific controller, the input is detected for 4-5 seconds before it stops, and then I have to press and hold the button again, just for the issue to reoccur.

Like you, this happens with my NSO SNES controller via Bluetooth using the SDL2 driver in Retroarch. The issue also occurs with my NSO Sega Genesis controller, but I have no problems with any other controller.

I also prefer the SDL2 drivers for proper controller detection/mapping, so if the issue could be resolved in some way, I'd really appreciate it!

Hey @stbeaumont98 would you mind trying something for me? I may have a weird work around i found. Its kind of complicated. There is a version of sdl2 called SDL2 compat (here - https://github.com/libsdl-org/sdl2-compat/releases) Download the newest version of it and put both sdl2 AND sdl3 in the retroarch folder (replace the old sdl2) open a game on snes and you will notice the controls are all weird and backwards, Y is B, A is X, so on. Close down the game and delete sdl2 AND sdl3 from retroarch, then download version 2.32.0 from here - https://github.com/libsdl-org/SDL/releases and put sdl2.dll in retroarch folder and i swear it fixed it for me, No more issues. Try that and get back to me, If you have any questions let me know. If this fixes it for you also then hopefully someone from the dev team sees this and understands why it fixes it and they can fix the new sdl2 compat version properly.

Summary- It seems putting sdl2 compat 2.30.50 (and included sdl3.dll) in retroarch folder, playing a game then deleting sdl2 and sdl3 compat (because the controls are screwed up) THEN putting in the newest version of standard sdl2.dll (sdl2 2.32.0) suddenly it fixes the issue where the controls randomly stop working. Note that sdl2 2.32.0 did NOT work before hand (it had the issue with controls just stopping) but seemingly this resolves after installing sdl2 and sdl3 compat, playing a game, closing it, deleting sdl2 and sdl3 compat THEN reinstalling sdl2.dll 2.32.0. Confusing, I know, but 2 others now have said it fixed it.

LAST NOTE- It seems its only a temporary fix. Once you turn off your controller and then reconnect it, the problem is back until you put sdl2 compat and sdl3 back in, start game, stop game, remove both, then put sdl2 normal back in and it works good again...till you turn off the controller. its annoying. Hopefully this is fixed soon.

@stbeaumont98
Copy link

I started testing before your "LAST NOTE" appeared on my screen, but yeah, I was having the same reconnection issue. Not sure I want to have to go through all these steps every time I want to use my SNES or Genesis controller.

It seems that when using sdl2-compat, besides the ABXY buttons being mis-mapped, I have no connection issues at all. So, after a simple remapping, the connection issues are resolved, and the controls are properly mapped. The only issue I'm having using sdl2-compat is that when connecting a controller while Retroarch is running, it causes Retroarch to crash, so no hotswapping, which isn't ideal either. But I'd rather do this than to jump through hoops moving files back and forth.

I'm not sure how niche this issue is or if the same bug is causing issues for other people in other scenarios, so there's no telling whether it'll be a priority to get fixed. Alternatively, we can hope that it'll get resolved by chance in a future update.

@slouken
Copy link
Collaborator

slouken commented Mar 9, 2025

Can you get a stack trace for the crash?

@stbeaumont98
Copy link

Not sure I did this correctly, but I followed this guide and used gdb to get a trace.

When disconnecting the controller while running Retroarch, I get this trace.

And when connecting a controller while running Retroarch, this is the trace.

Let me know if you need more information or if I did this incorrectly (if that's the case, please point me in the right direction).

@slouken
Copy link
Collaborator

slouken commented Mar 9, 2025

I think that's helpful, but I don't see gdb stopping because of the crash, did that part just get omitted from the pastebin? Usually there's some more context about the crash.

@stbeaumont98
Copy link

stbeaumont98 commented Mar 9, 2025

Sorry, I wasn't sure how much was relevant.

Disconnecting a controller.
Connecting a controller.

Both start from the "run" command in gdb and end when Retroarch has terminated. Hope this helps!

@slouken
Copy link
Collaborator

slouken commented Mar 9, 2025

Okay, I tried to repro, here were my steps:

  • Download the RetroArch nightly build for Windows 64
  • Download sdl2-compat 2.32.52
  • Install RetroArch
  • Rename SDL2.dll SDL2.dll.dist
  • Unpack sdl2-compat into the RetroArch install directory
  • Launch RetroArch
  • While sitting on the main menu, plug in an Xbox controller
  • While sitting on the main menu, unplug an Xbox controller

This works for me, what am I missing?

@stbeaumont98
Copy link

I'm using Retroarch stable, although I'm not sure it matters since I built my "retroarch_debug.exe" from the latest code.

Once Retroarch is installed, follow these steps:

  • Launch Retroarch
  • Navigate to Settings > Drivers, and set the Controller driver to "sdl2"
  • Quit Retroarch
  • Rename SDL2.dll SDL2.dll.dist
  • Unpack sdl2-compat into the RetroArch install directory
  • Launch Retroarch
  • If controller is already connected, disconnect controller
  • While sitting on the main menu, connect any controller

It doesn't seem to matter whether the controller is connected via Bluetooth or plugged in via USB.

I've noticed that disconnecting a controller while Retroarch is running doesn't crash the program, but it still caused a segfault in gdb.

@slouken
Copy link
Collaborator

slouken commented Mar 9, 2025

Ah, switching the controller driver to sdl2 was key, thanks!

@slouken
Copy link
Collaborator

slouken commented Mar 9, 2025

The crash is fixed in libsdl-org/sdl2-compat@4dc33f9

@yanon182
Copy link
Author

yanon182 commented Mar 9, 2025

Glad to hear thats fixed, I had made this video to explain it https://youtu.be/fbKE7DuLxu0 since im a streamer and its easier for me to explain than type, i suck with words lol. But i see you guys already are resolving it. The weird mapping on the x y a b buttons arent saving for me though, after i restart retroarch the buttons i remap are reset, Thats most likely a retroarch issue though, But where sdl2 compat isnt mapped properly in the first place that seems to be the core issue. I showed that in the vid, Thanks @slouken for taking time to check this out with us man, It means a alot!

@stbeaumont98
Copy link

@yanon182 not sure if this will do it for you, but after remapping in RetroPad Binds, I selected "Save Controller Profile" before restarting RetroArch. I don't know why sdl2-compat is mapping it differently in the first place, but since it's a compatibility layer for sdl3, it could be that it's just mapped differently in sdl3.

Anyways, I was able to remap the controls, and I hope I was able to help you do it too, but I'm satisfied with using sdl2-compat for now (or until another issue pops up). I'll be sure to keep it up-to-date, especially since the next version will fix the crash problem.

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

No branches or pull requests

3 participants