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

[Bug] Controller settings are not saved & [Feature Request] xinput implementation #577

Open
williansti opened this issue Jan 25, 2025 · 45 comments
Labels
enhancement New feature or request not planned but open to a PR I do not intend on working on this myself, but I would not be opposed to an implementation.

Comments

@williansti
Copy link
Contributor

Overview

In my case I use original Xbox Series X controls, but every time I open the emulator, the input device is disabled. even though I leave everything right with player 1 using xinput 0 and player 2 using xinput 1, even creating a profile for each control, applying the settings and using them correctly, When I return to the emulator I have to do everything again, because nothing is saved. In short, the settings only work during use, they are not saved..

Smaller details

They could improve compatibility with xinput, implementing functionality like reicast, xenia, xemu or dolphin.

reicast already immediately detects any xinput control when triggered and sets each player to an xinput.

xenia and xemu detect xinput controls almost like a native console, no adjustments are required.

Dolphin, after all the configuration and usage indication for xinput 0: player 1, xinput 1: player 2, xinput 2: player 3 and xinput 3: player 4.
By doing all this and saving a profile for each player, the emulator does not forget the configuration and resumes correctly after each use.

Nature of request

Improve compatibility, efficiency and management of xinput controls in the emulator, so that the emulator "remembers" the settings.

Why would this feature be useful?

It would be useful to solve this annoying problem of every time you open the emulator, having to reconfigure all the controls again, for me and many others who use 4 controls, it is terribly sad, redoing everything every time you want to play.

@williansti williansti added the enhancement New feature or request label Jan 25, 2025
@GreemDev
Copy link
Member

SDL is used to avoid controller-specific code. Xinput is not going to be added, at least not officially.
This is not going to be worked on.

@GreemDev GreemDev added the not planned but open to a PR I do not intend on working on this myself, but I would not be opposed to an implementation. label Jan 25, 2025
@williansti
Copy link
Contributor Author

I understand, this may not even be a priority, I also understand that there is much more useful work than this, if there was a collaborator who could implement at least the two options, as in pcsx2 among others, it would be interesting, options are always welcome, think carefully perhaps in the future.

@Anthonyc833
Copy link

havent you press apply when you change the input device?

@williansti
Copy link
Contributor Author

havent you press apply when you change the input device?

Yes, I pressed apply, I've tried creating the profiles too, it doesn't work, every time I turn off and on the computer and the controls, everything has to be redone, SDL is complicated, I know there are settings in SDL that save in other emulators, even old ones, like yabasunshiro, but the ideal would be to have an option to detect xinput.

@Anthonyc833
Copy link

are you 100% sure? I just checked on my machine and the settings and my controller input is still saved

@williansti
Copy link
Contributor Author

williansti commented Jan 29, 2025

are you 100% sure? I just checked on my machine and the settings and my controller input is still saved

I will give examples of the problems that occur. If you only use 1 controller (I use Xbox series X/S), the setting is kept for xinput 0, as long as you don't open the emulator with the controller turned off, otherwise the input device will be disabled.

If you use 2 or 4 controls, the configuration gets mixed up, player 1 has xinput 1 and no longer 0, player 2 also has xinput 1.

The entire configuration is lost, even if you set it correctly as I mentioned.

Player 1: xinput 0
Player 2: xinput 1
Player 3: xinput 2
Player 4: xinput 3

When opening the emulator again if the controls are turned off, everything will be lost, and if you open the emulator with the controls turned on, each player's input device will shuffle or simply use the same xinput.

That's why I say that it would be very good to implement xinput support as an option in this emulator, because just like redream, flycast, duckstation, pcsx2, rpcs3, xenia, xemu, dolphin, etc... the configuration would be maintained, regardless of whether the control is connected with the emulator open or closed, nothing would ever be lost, in addition to the configuration always being set correctly.

@Anthonyc833
Copy link

wait a second are you connecting your controller by bluetooth or wired?

@williansti
Copy link
Contributor Author

I connect all 4 by bluetooth, as I mentioned, older emulators such as yabasanshiro which only uses SDL, saves the settings,

unfortunately ryujinx "forgets" the settings and disables the input if it doesn't find the connected controller, and even if I avoid opening the emulator with the controller disconnected, assuming that I only open it when the controllers are connected, it still scrambles the xinput order as I already mentioned... it's very sad, every time I open the emulator, I have to go in there and activate each control in the input and indicate one by one.

@manituan
Copy link

manituan commented Feb 3, 2025

Same here. This would be my number 1 issue to fix.

@Tartifless
Copy link

Xinput does not always assign the same playernumber to the same controller, so this is normal, not really an issue.

SDL is more stable

@GreemDev
Copy link
Member

Xinput does not always assign the same playernumber to the same controller, so this is normal, not really an issue.

SDL is more stable

Xbox controllers have that jank even when using their official API?

@Tartifless
Copy link

Yes Xinput is a mess, sdl is the way to go.

@GreemDev
Copy link
Member

I was never going to add Xinput support, so cool I guess

@williansti
Copy link
Contributor Author

Well, I just suggested such an implementation, because in all other emulators it works without any problem, I have never seen such repulsion for a simple resource, if I had the necessary skill I would do such an implementation, because I believe that more options are always better than just one option, see dolphin, pcsx2, rpcs3, duckstation, xenia, xemu, flycast among others, well let's not discuss it anymore, if xinput is criticized here let's close this topic and depend only on SDL.

@Tartifless
Copy link

Flycast only has sdl, not xinput

@GreemDev
Copy link
Member

Well, I just suggested such an implementation, because in all other emulators it works without any problem, I have never seen such repulsion for a simple resource, if I had the necessary skill I would do such an implementation, because I believe that more options are always better than just one option, see dolphin, pcsx2, rpcs3, duckstation, xenia, xemu, flycast among others, well let's not discuss it anymore, if xinput is criticized here let's close this topic and depend only on SDL.

If we add multiple input backends, it needs explaining what each one does, when to use it, etc.
And then you'll get countless people who don't read the words written in the UI, or on the wiki, use the wrong backend and wonder why their controller isn't working.
If these other emulators don't have the same issues as Ryujinx does, while also using SDL in that emulator, then it's a problem that can be solved in the Ryujinx SDL code.
Doing this also doesn't require a completely new input backend to be made from the ground up for a small subset of users who use Xbox controllers for their Nintendo Switch games.

Simply adopting a completely foreign HID API for a very small subsection of users who will even get a benefit from it is not a way to solve this problem.

@Tartifless
Copy link

I have xbox series x controller and don't have similar problem.
Are you sure it's not just the settings file or folder that is read-only ?

@williansti
Copy link
Contributor Author

Well, I had already closed this topic, but I will reopen it due to the continuity of the conversation, I will try to demonstrate with prints exactly what happens, I hope that this will be clearer for everyone.

1 - Doing the basics, we turn on all the Xbox controllers until they are paired with the PC.
2 - We open the emulator and go to settings >> input
3 - We define each controller in its specific player and apply the settings before clicking ok

see the pictures everything is ok, perfectly defined

Image

Image

Image

Image

Now let's see the following, I just closed the emulator and then opened it again and see what happened to the controls
They were simply all disabled, sometimes this happens and sometimes their order gets mixed up, other times 2 or more players have the same xinput

Image

Image

Image

Image

Absolutely nothing has changed in the connection of the controls, they are all active in Windows and paired, working perfectly.

Image

Image

As I mentioned several times, I can open other emulators, and all the controls are perfectly defined, for example, I opened Dolphin and there they are all perfectly configured for a long time.

Image

Image

Image

Image

I understand that implementing xinput may not be necessary, although it would be very useful for those who use controls like mine, but there are certainly problems in SDL that need to be fixed.

As previously stated, absolutely no emulator I use presents this issue of simply "forgetting" the control settings, whether with SDL or xinput, not even citron, sudachi, yuzu and all the others for other consoles, so I kindly ask that you review why SDL in ryujinx does not keep my controls properly configured and enabled.

@williansti williansti reopened this Feb 17, 2025
@Tartifless
Copy link

Tartifless commented Feb 17, 2025

What is strange is that i do not have this issue with same controllers !
Are you sure the folder or file where Config.json is located is not read-only ?

Because if it does this in sdl, it will also do it with xinput or any other wrapper

@manituan
Copy link

I have the same experience. Let me know if I can help debug this issue.

The issue we are facing is more of an annoyance than a blocker. Controllers end up working. But we have to configure input settings each time we play, as the settings don't get saved. The input setup doesn´t persist between runs.
I've also made a profile that does persist, but it gets unassigned each time as well.

I'm running the latest Ryujinx and I've tried with multiple 8bitdo/xbox/ps4 controllers.

@Tartifless
Copy link

Tartifless commented Feb 17, 2025

Ok, i have just tried with the following controllers:

  • Xbox series X
  • Xbox One S
  • Xbox elite 2
  • 8BitDo Pro2 (switch and xinput mode)
  • Dualsense

I am unable to reproduce the issue.

I save configuration, exit ryujinx, launch it again, and settings are still there and controllers still assigned.

But this issue is not at all related to SDL vs Xinput, it's more about ryujinx not saving the configuration for your installation.

Where did you install ryujinx ? Which folder ?
Have you checked that the file Config.json located in the "portable" folder of ryujinx is correctly saved when exiting ryujinx after defining the controls ?

@williansti
Copy link
Contributor Author

What is strange is that i do not have this issue with same controllers ! Are you sure the folder or file where Config.json is located is not read-only ?

Because if it does this in sdl, it will also do it with xinput or any other wrapper

I use the settings inside the "portable" folder, I checked the properties and both the folder and Config.json are not read-only.

@williansti
Copy link
Contributor Author

I have the same experience. Let me know if I can help debug this issue.

The issue we are facing is more of an annoyance than a blocker. Controllers end up working. But we have to configure input settings each time we play, as the settings don't get saved. The input setup doesn´t persist between runs. I've also made a profile that does persist, but it gets unassigned each time as well.

I'm running the latest Ryujinx and I've tried with multiple 8bitdo/xbox/ps4 controllers.

Thanks for reporting, they already thought I was crazy lol

@Tartifless
Copy link

Tartifless commented Feb 17, 2025

Can you try the following:

  1. open ryujinx, configure your controls, apply/save, do not exit and share the Config.json file number 1
  2. exit ryujinx, open again, ensure controllers appear as disconnected, do nothing, quit and share Config.json number 2
  3. open again, set the controllers to the right ones (from disconnected to the ones as working in step 1 (do not change mapping of buttons), apply and save again, and share the 3rd version of the file.

If there is a difference, it will allow finding the culprit, my guess is that it will be the guid of the controller...

@williansti
Copy link
Contributor Author

Ok, i have just tried with the following controllers:

  • Xbox series X
  • Xbox One S
  • Xbox elite 2
  • 8BitDo Pro2 (switch and xinput mode)
  • Dualsense

I am unable to reproduce the issue.

I save configuration, exit ryujinx, launch it again, and settings are still there and controllers still assigned.

But this issue is not at all related to SDL vs Xinput, it's more about ryujinx not saving the configuration for your installation.

Where did you install ryujinx ? Which folder ? Have you checked that the file Config.json located in the "portable" folder of ryujinx is correctly saved when exiting ryujinx after defining the controls ?

folder where ryujinx is installed = D:\Emuladores\Nintendo Switch\Emulador
folder where Config.json is located = D:\Emuladores\Nintendo Switch\Emulador\portable

portable folder and config.json are not read-only I tried testing with version 1.2.82 and the same problem occurs
I tried deleting config.json and letting the emulator recreate it but the problem still occurs.
I found that after enabling the controls, applying and clicking OK on the settings and closing the emulator, the config.json is modified correctly, but after opening the emulator again it resets the controls settings to disabled.

I just noticed something interesting, I put just 1 of my controllers on the cable, and the settings were saved and kept, even after closing and reopening the emulator
So we conclude that this problem is occurring with Xbox controls connected via Bluetooth, when connected via cable there are no problems.

The controls are identified differently on Bluetooth and the cable and perhaps SDL is not knowing how to deal with this, it is something to be investigated.

Bluetooth controls where the settings are not saved

Image

On-cable controls where problems don't occur and settings are maintained

Image

@williansti
Copy link
Contributor Author

Can you try the following:

  1. open ryujinx, configure your controls, apply/save, do not exit and share the Config.json file number 1

Config1.json

  1. exit ryujinx, open again, ensure controllers appear as disconnected, do nothing, quit and share Config.json number 2

Config2.json

  1. open again, set the controllers to the right ones (from disconnected to the ones as working in step 1 (do not change mapping of buttons), apply and save again, and share the 3rd version of the file.> > If there is a difference, it will allow finding the culprit, my guess is that it will be the guid of the controller...

Config3.json

@Tartifless
Copy link

Tartifless commented Feb 17, 2025

Ok, so what we can see, between 1 and 2, just by quitting ryujinx, there are already changes in the file.

With your working configuration we get:
Player 1 - 0-9a460003-045e-0000-130b-000013057200
Player 2 - 0-9a460003-045e-0000-130b-000009057200
Player 3 - 0-9a460003-045e-0000-130b-000021057200
Player 4 - 0-9a460003-045e-0000-130b-000020057200

Re-run, change nothing and close: (we just loose Player 4)
Player 1 - 0-9a460003-045e-0000-130b-000013057200
Player 2 - 0-9a460003-045e-0000-130b-000009057200
Player 3 - 0-9a460003-045e-0000-130b-000021057200

After reconfiguration, we get brand new ids:
Player 1 - 0-466a0003-045e-0000-130b-000013057200
Player 2 - 0-466a0003-045e-0000-130b-000009057200
Player 3 - 0-466a0003-045e-0000-130b-000021057200
Player 4 - 0-466a0003-045e-0000-130b-000020057200

@GreemDev : Is it something already seen ? I just tried with 2 controllers of exactly the same type (XBox One S) but did not encounter any such issue.
I don't know what could be causing this with the example above, where the guid of controllers changes upon relaunching the app...

@williansti
Copy link
Contributor Author

And strangely this only occurs when the controllers are connected via bluetooth, where they are displayed as "Xinput Bluetooth LE compatible input device"

but when connected via usb cable, and they are detected as "Controller (Xbox One for Windows)" no problem occurs.

Are the controller IDs different when used via bluetooth?

@Tartifless
Copy link

The fact that your xbox controller shows as bluetooth LE compatible device is problematic, it should show as Xbox Series controller...

Maybe you should check the driver/firmware of the controller.

@williansti
Copy link
Contributor Author

williansti commented Feb 17, 2025

They appear as Bluetooth LE compatible device because they are connected via Bluetooth and not through the original wireless adapter for Xbox controls that exists for PC, however, my Bluetooth is of excellent quality and is Intel Bluetooth 5.1 LMP11, which is already embedded on my motherboard, a Gigabyte B660M AORUS PRO AX.

But this doesn't seem to be a problem caused by the way I connect the controls to the PC, since it's a problem exclusive to ryujinx, absolutely all the other emulators I use, none of them present a problem, and believe me, I use them a lot...

PS: the firmware of all controls are up to date, v5.23.5.0

My database and emulators

Image

Image

@Tartifless
Copy link

Even with bluetooth and whatever the bluetooth receiver, they should have their correct name and appear as Xbox controllers, not as Bluetooth LE compatible...

@williansti
Copy link
Contributor Author

I found these answers on google...

What can happen when connecting an Xbox controller via Bluetooth?
1 - The Xbox Series S controller may be recognized as “XINPUT LE-compatible input device” when connected via Bluetooth to a laptop.
2 - The Xbox Series controller may be registered as an HID-compatible XINPUT device in Windows 11.
3 - The Xbox Series controller connected via Bluetooth may not be detected as an Xbox controller, but only as a generic XInput controller.

Number 3 is my case and applies to me.

but strangely this doesn't affect anything I use, from PC games and other emulators, the only software that isn't keeping the settings really is just ryujinx, that's why I suggested the implementation of xinput as another option, somehow it seems that in bluetooth the controls enter as generic xinput devices, and there's something missing in the ryujinx SDL to work well with this.

@Tartifless
Copy link

Xinput will not fix this, as xinput ids (from 0 to 3) will not be assigned always to the same controller, but at least they won't appear disconnected.

But this should be fixed by ryujinx dev in sdl, it seems the code assigns different guids upon restart of app, which is messy....

@Tartifless
Copy link

This might be the culprit:
0f3c7f9

Maybe...

@GreemDev
Copy link
Member

it looks like the controller IDs are directly obtained from SDL

@Tartifless
Copy link

The fact that the guid changes upon application restart is very strange and indeed other emulators also use guid (pcsx2, citra forks, yuzu forks....) and do not show this behaviour.

Maybe instead of using guid, just sdl index would be enough...

@GreemDev
Copy link
Member

i really do not want to break everyone's input configs because of, specifically, Xbox controllers users on Bluetooth lol

@williansti
Copy link
Contributor Author

I understand that with xinput the control in my hand will not always be player 1, it may simply be player 2 on the next restart, but what is certain is that both will connect without requiring any type of configuration, almost automatically.

When I mention options it is because it is common in other projects, for example in pcsx2 I don't even turn on the SDL option... every time an emulator has an option for xinput, I just leave it turned on and there is no need to define any configuration, see how each control already goes to xinput0 or xinput1 by itself.

But I don't want to be more annoying than I already am, I understood that the problem here is some code in SDL X Xinput via bluetooth, since other emulators that I use with SDL do not present a problem, but I am grateful that we finally found the source of the problem.

Image

Image

Image

@Tartifless
Copy link

It's already broken it seems.

@williansti : can you try with older version 1.2.19 if you experience the same:
https://github.com/Ryubing/Ryujinx/releases/download/1.2.19/ryujinx-1.2.19-win_x64.zip

@williansti
Copy link
Contributor Author

williansti commented Feb 17, 2025

It's already broken it seems.

@williansti : can you try with older version 1.2.19 if you experience the same: https://github.com/Ryubing/Ryujinx/releases/download/1.2.19/ryujinx-1.2.19-win_x64.zip

I tested this version and unfortunately the same problem occurred. I also tried deleting the portable folder and letting it recreate the config.json in another location, but it also didn't save the control settings.

I went further and also tested the old ryujinx, ryujinx-1.1.1402-win_x64, and the same thing happens, apparently it's a very old problem, strange that no one has ever reported this.

@Tartifless
Copy link

So basically this issue is very limited to xbox series controller and only when they are in the case you explained hereover (recognized as generic xinput device).

It can be fixable, but for this a dev with sdl2 minimal knowledge is required.

@Tartifless
Copy link

Tartifless commented Feb 17, 2025

Well, just saw someone on github with similar issue:

Image

Seems indeed like something is broken at controller level also in linux.

What is still puzzling is that this happens only for some people, for others, with same controllers, there is no issue...

And looking at the code, it uses standard sdl2 features, so absolutely no reason within this code for it not to work.

@Tartifless
Copy link

@williansti , just a quick question, do you have Steam running in parallel ? (Even minimised to tray)

@williansti
Copy link
Contributor Author

I have steam but it is completely closed, and I leave his background disabled

@williansti williansti changed the title [Feature Request] Better compatibility with xinput, controllers are turned off when opening and closing the emulator [Bug] Controller settings are not saved & [Feature Request] xinput implementation Feb 18, 2025
@williansti
Copy link
Contributor Author

Video reproducing the problem

recording-2025-02-18-22-24-45.video-converter.com.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not planned but open to a PR I do not intend on working on this myself, but I would not be opposed to an implementation.
Projects
None yet
Development

No branches or pull requests

5 participants