-
Notifications
You must be signed in to change notification settings - Fork 553
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
[Enhancement] GamecontrollerDB support #82
Comments
This is already a feature of SDL2: https://wiki.libsdl.org/SDL_HINT_GAMECONTROLLERCONFIG So you can set an environment variable with the config(s) for your controller. Obviously this won't give you a full set of controllers (at least not on platforms where environment variables have limited length), but I'd consider this a niche feature anyway, because VVVVVV allows remapping buttons. VVVVVV also doesn't visualize buttons or anything else where it would benefit from SDL_GameController. |
Well then something is not working. Controller is not being seen at all. I assumed it was from missing the support (actual mapping definitions not following the newer standards in Input.cpp) |
Here's what SDL2 sees
I attempt to remap in game and nothing happens. |
It's a feature of SDL2, but the program has to include the database and use the right button definitions for it to actually be used. That github repo I linked just hosts a txt file and instructions on how its used. It's still using all the SDL2 built in functions. |
We can do what I do in FNA and load the txt file directly from the base directory, right after initializing the filesystem: https://github.com/FNA-XNA/FNA/blob/master/src/FNAPlatform/SDL2_FNAPlatform.cs#L133 |
(This post contains some background knowledge about SDL_GameController / explanations first, then opinion - feel free to skip it)
I think you misinterpreted what I said / meant. SDL2 has SDL_GameController which VVVVVV is already using. That maps a standard joystick into the Xbox 360 layout (as you also described). The per-device configurations for SDL_GameController are loaded from different sources (not a complete list):
My personal preference has always been to encourage upstreaming of controller configs from SDL_GameControllerDB to SDL2. My second preferred option is to recommend launchers (like Steam big picture) or manually setting up their SDL2 environment variables (either completely manually, or through a tool to set the environment variables for you). My least favorite option has always been to load SDL_GameControllerDB from file because I don't like the idea of having a config per-application when it should be system-wide. I also don't like their recommended 6-button layout as it's incompatible with 6-button Xbox gamepads (to be fair, this probably also propagated to upstream SDL by now). Generally, I like the idea of SDL_GameControllerDB, but the implementation feels like a temporary hack that has gone permanent and leaves its traces in many applications. Unfortunately, loading a per-application SDL_GameControllerDB is slowly becoming the defacto standard (defeating the purpose of general-purpose and system-wide databases). |
Yeah I was focusing less on the DB and just generally supporting the mapping itself. That was the best jumping off point I could think of. I guess the main issue is the current input handling (in VVVVVV) doesn't seem to be controller agnostic. I'm not sure what it is supposed to recognize but I haven't found a controller I can map as of yet. |
Ok so I finally found my DS4 controller and that DID work. So what would be the reason for it not recognizing another gamepad? That was my whole point of trying to pass in a custom controllerdb entry. |
I feel like I explained this in my previous 2 posts: You can just use http://www.generalarcade.com/gamepadtool/ and create a mapping, then use "Set as environment variable". SDL2 will then expose the SDL joystick as an SDL_GameController and VVVVVV should pick it up (provided you aren't using an ancient SDL2). You want your SDL2 config to be generic (follow the Xbox 360 button layout). If you want to remap buttons in VVVVVV you should be able to use the VVVVVV options. Another solution to support more gamepads in VVVVVV would be to open devices as SDL joystick, then allow rebinding those manually (as it exposes all joystick devices, and also all buttons - not just those mapped by SDL_GameController). They could still just be pre-configured from the SDL_GameController configuration (this is how I usually use SDL_GameController myself, because it allows greater flexibility). For gamepads which aren't even detected as SDL joystick you'll have to use something like vjoy or uinput. But I feel like that's out of scope for VVVVVV (heck, even documenting how to use SDL_GameController should be out of scope - but here we are). |
Ok I think what confused me is I had the txt file and tried to use the function in SDL to use it and that wasn't working. I will try as the variable and see if I can get it working. Thanks. |
If it's the SDL2 revision that shipped with the current 2.2 release, it's probably just that it's super old and doesn't have that much in the database. Updating the lib that I shipped with should be pretty comprehensive, if not then there's a good chance that adding the gamecontrollerdb.txt functionality should make just about every other device work (and if not, the DB has a guide for adding new entries, and that's probably that @parkerlreed needs to do in addition to adding the LoadMappingsFromFile call after filesystem init). @JayFoxRox Managing the database is really tricky right now, for a number of reasons:
There's no real proper fix for the database issue - at best you might be able to upstream searching for the file in |
Ok so yeah the environment variable did indeed work. I tried adding the txt file import to main.cpp after the ASCII display and that wasn't working. Is there some place that would work better?
|
Note about the patch: This feels like it should have been in input related code, not filesystem related code. @flibitijibibo |
https://github.com/gabomdq/SDL_GameControllerDB
SDL2 supports reading from a file in the PWD/environment variable path containing a mapping of controllers centralized around the Xbox 360 mapping. This makes it dead simple to instantly support most every controller out there and easy to add new ones by just appending mappings to the file.
Would be great to have this support in VVVVVV
The text was updated successfully, but these errors were encountered: