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

Allow for adding new SDL2 controller mappings? #4053

Open
HomeStarRunnerTron opened this issue Dec 7, 2022 · 13 comments
Open

Allow for adding new SDL2 controller mappings? #4053

HomeStarRunnerTron opened this issue Dec 7, 2022 · 13 comments
Labels
enhancement New feature or request input Related to Ryujinx.Input or Ryujinx.Input.SDL2

Comments

@HomeStarRunnerTron
Copy link

HomeStarRunnerTron commented Dec 7, 2022

Feature Request

Allow for adding new SDL2 controller mappings?

What feature are you suggesting?

Overview:

  • In the wxwidgets PCSX2 on Mac OS X (and I think also on Windows), which uses SDL2 for its controller mapping, it's possible to go into a plain text file called PAD.ini and add new controller mappings created in programs like SDL2 Gamepad Tool. I have controllers that currently aren't running normally in Ryujinx that I was able to map by replacing code in libSDL2.dylib-- it'd be so nice to be able to do this as simply as in PCSX2!

Smaller Details:

  • I'm just going to use this area to talk about what I did to get this working for myself. I have a whole bunch of controllers that show up in keyboard mappers and certain games automatically. They're just more from the last generation (Wii stuff hooked up through the DolphinBar, DDR pads hooked up through the Super Dual Box Pro, etc.), so they aren't the first thought to add compatibility for.

But they are recognized by the SDL2 Gamepad Tool, which made me wonder if I could do anything about this!

ryujinxsdl2hackA

I decided to open up Ryujinx's libSDL2.dylib in Hex Fiend and noticed that some of the code was storing controller mapping strings, just like what the Gamepad Tool generates!

ryujinxsdl2hackB

I tried just copying-and-pasting a new mapping, but of course, since this .dylib is compiled, there's no adding-- only replacing with the exact same amount of characters. So I found a controller mapping, and then modified the name of my controller until the line, in total, was the exact same amount of characters.

ryujinxsdl2hackC

And then my controller, which hadn't even shown up before, worked perfectly!

ryujinxsdl2hackD

Nature of Request:

  • ... and I'm going to use this section to ask if there's already something simpler I could do right now that could solve the problem I solved in this manner. Maybe something in the documentation I skipped over, you know. I'd also love to know if it's possible to just compile a whole new libSDL2.dylib with more/less controllers-- I wasn't able to find any info on that.

Why would this feature be useful?

... So, if instead of needing to replace in hex, one could just add a new line of code to a plain-text file; I think it could make a world of difference!

@marysaka
Copy link
Contributor

We already have support of controller mapping file.

You can open Ryujinx directory (the same one as the configuration) and puts a SDL_GameControllerDB.txt file in there.

https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.SDL2.Common/SDL2Driver.cs#L94

@HomeStarRunnerTron
Copy link
Author

HomeStarRunnerTron commented Dec 15, 2022

OHMAN, really?! MIRACLES OF MIRACLES! *tries it out* Okay, slight hiccup I'm having-- I can't have more than one controller on my Mayflash DolphinBar (which is in Mode 3, controller mode). In Dolphin and other emulators, it's possible to use all four at once, since none of them share the same button spaces in the GUID. Any chance I'm doing something wrong here? Only the last mapping I put in works, as if it's overwriting itself.

03000000790000000318000000010000,DolphinBar Player 1 Classic Controller,a:b8,b:b12,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b44,leftshoulder:b16,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b4,platform:Mac OS X,

03000000790000000318000000010000,DolphinBar Player 2 Classic Controller,platform:Mac OS X,a:b9,b:b13,x:b1,y:b5,back:b33,guide:b45,start:b37,leftshoulder:b17,rightshoulder:b21,dpup:h1.1,dpdown:h1.4,dpleft:h1.8,dpright:h1.2,leftx:a1,lefty:a5,rightx:a9,righty:a13,lefttrigger:b25,righttrigger:b29,

03000000790000000318000000010000,DolphinBar Player 3 GameCube Controller,platform:Mac OS X,a:b10,b:b14,x:b2,y:b6,start:b38,leftshoulder:b18,rightshoulder:b22,dpup:h2.1,dpdown:h2.4,dpleft:h2.8,dpright:h2.2,leftx:a2,lefty:a6,rightx:a10,righty:a14,lefttrigger:b26,righttrigger:b30,

03000000790000000318000000010000,DolphinBar Player 4 GameCube Controller,platform:Mac OS X,a:b11,b:b15,x:b3,y:b7,start:b39,leftshoulder:b19,rightshoulder:b23,dpup:h3.1,dpdown:h3.4,dpleft:h3.8,dpright:h3.2,leftx:a3,lefty:a7,rightx:a11,righty:a15,lefttrigger:b27,righttrigger:b31,

But yes-- this is incredible, Mary!! I haven't seen a single person talk about this-- obviously, I'm sure anyone who is developing the emulator or has any know-how about coding (which I really don't) would think this is "no-duh" common knowledge, but shouldn't this be added to some really accessible documentation about controllers so people can know what to do? ^_^ All the best.

@marysaka
Copy link
Contributor

OHMAN, really?! MIRACLES OF MIRACLES! tries it out Okay, slight hiccup I'm having-- I can't have more than one controller on my Mayflash DolphinBar (which is in Mode 3, controller mode). In Dolphin and other emulators, it's possible to use all four at once, since none of them share the same button spaces in the GUID. Any chance I'm doing something wrong here? Only the last mapping I put in works, as if it's overwriting itself.

Not really sure tbh I haven't used that feature much ^^'

But yes-- this is incredible, Mary!! I haven't seen a single person talk about this-- obviously, I'm sure anyone who is developing the emulator or has any know-how about coding (which I really don't) would think this is "no-duh" common knowledge, but shouldn't this be added to some really accessible documentation about controllers so people can know what to do? ^_^ All the best.

The reason it exists is because I wanted people to be able to use SDL_GameControllerDB if needed but never documented it yeah.

We should update the guide to have that baked in.

It should also be noted that it's not currently possible to reload that as it's done at initialization of the emulator.

@HomeStarRunnerTron
Copy link
Author

Hooray! Thank you so-so much for your hard work, all the best. I asked the question over at the DB GitHub, and they said it was a problem that SDL2 had to work out, but-- I mean, as I said, it seems to be possible to access all the info from all four at once, at least in Dolphin. Here's my GitHub issue, in-case it ends up being useful at all. Rock rock on!

@JaxzTW
Copy link

JaxzTW commented Jan 8, 2023

@marysaka i tried to put the file in the main directory called in the same way, nothing happen
image
image

@marysaka marysaka added enhancement New feature or request input Related to Ryujinx.Input or Ryujinx.Input.SDL2 labels Feb 25, 2023
@panda437
Copy link

We already have support of controller mapping file.

You can open Ryujinx directory (the same one as the configuration) and puts a SDL_GameControllerDB.txt file in there.

https://github.com/Ryujinx/Ryujinx/blob/master/Ryujinx.SDL2.Common/SDL2Driver.cs#L94

Wow, I placed the file and restarted, it worked. Thank you so much.

@HomeStarRunnerTron
Copy link
Author

HomeStarRunnerTron commented Feb 2, 2024

Just as a heads-up, looks like SDL_GameControllerDB.txt has stopped being read by Ryujinx on any version after 1.1.1118. Dunno if I've done something wrong with my formatting of the mapping, but yeah-- after 1.1.1118, my controller stops showing up under Input. I'm on macOS, if that makes a difference.

@AzureStar123
Copy link

@HomeStarRunnerTron There was a code change in the SDL2Driver class. Instead of placing it in the Ryujinx folder it should be placed in /Applications/Ryujinx.app/Contents/MacOS.

Screenshot 2024-02-10 at 12 45 02 PM Screenshot 2024-02-10 at 12 46 35 PM

@HomeStarRunnerTron
Copy link
Author

Oh, thank GOODNESS-- so happy that this massively important (for me) feature is moving forward! : )

@marysaka
Copy link
Contributor

I think that should be fixed, this should be placed somewhere else imo as otherwise you invalidate the app signature on macos..

@jcm93
Copy link
Contributor

jcm93 commented Feb 10, 2024

@HomeStarRunnerTron There was a code change in the SDL2Driver class. Instead of placing it in the Ryujinx folder it should be placed in /Applications/Ryujinx.app/Contents/MacOS.

Now that #6295 is merged, you (and others in this thread on macOS using this feature) will need to place the SDL_GameControllerDB.txt file inside ~/Library/Application Support/Ryujinx/. Windows users will need to place it in AppData/Roaming/Ryujinx/, Linux users in ~/.config/Ryujinx/ (by default).

@HomeStarRunnerTron
Copy link
Author

HomeStarRunnerTron commented Feb 10, 2024

In the current 1.1.1179 build, it seems like it only successfully reads the SDL_GameControllerDB.txt some of the Time-- like, 50% of the Time that I open Ryujinx, the controller I've added doesn't show up. Just seems random. Heading back to yesterday's builds for now!

EDIT: Shucks, I'm realizing with stress-testing that all versions since the change at 1.1.1119 are causing my controller to only sometimes show up on boot. With stress-testing 1.1.1118, it shows the controller every time. SO back to 1.1.1118 for me in the meantime.

@kiodo1981
Copy link

kiodo1981 commented May 5, 2024

I still have this problem on Linux. Gamepad does not appear.
Any solution?
Please help.
I use Ryujjinx 1297

EDIT: I found a solution. I downloaded the gamecontrollerdb.txt from https://github.com/mdqinc/SDL_GameControllerDB and I renamed it in SDL_GameControllerDB.txt and I put this in /home/XXX/.config/Ryujinx/

Is it possible to add this file automaticalli in the build?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request input Related to Ryujinx.Input or Ryujinx.Input.SDL2
Projects
None yet
Development

No branches or pull requests

7 participants