-
Notifications
You must be signed in to change notification settings - Fork 12
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
Incompatible gamepad because SDL detects it as a Joystick #6
Comments
I tried to fix this by getting a proper SDL gamepad config for my gamepad. But when I try to provide it in the flex-launcher |
Thanks for the report. If you have entered a valid controller mapping in a text file and provided it via the In regard to your other problem, an undefined symbol error is a linking issue. Out of curiosity, did you compile Flex Launcher yourself, or are you using a binary package from the release page? And which distro are you using? |
Compiled myself. I'm on Gentoo so my package manager didn't take any of the provided package files. My guess is that my Gentoo USEflags enabled some feature of SDL that's usually disabled or vice versa, & as a result SDL decided to call into libudev when (in your binaries) it wouldn't. Anyway, I did a little more debugging; it looks like the error I was seeing with the linking isn't relevant; it has no effect on the actual issue whether or not the library is linked in. Here's my controller config file:
Only one line. I had to hack this together because the generator tool you linked is very out of date & won't even run on my system. But if there's a typo I can't find it. The issue I am handling now, seems to be twofold. First off, the log reports an error from SDL_GameControllerAddMappingsFromFile(), but I'm not sure it actually should be.
According to the SDL documentation, this function's return value works like that of SDL_GameControllerAddMappingsFromRW, which returns the number of mappings found in the file, or -1 if the file couldn't be loaded. If it's successfully loading my file, it should return 1 (since there's one line in it), which it does. I enhanced the error message:
And what I see is a return of "1" and (if I link in libudev) no error at all. But I still see the joystick attached message instead of gamepad attached, so it doesn't connect. |
You need to include the platform at the end of your mapping, otherwise SDL won't accept it. So add Thanks for the info about the mapping tool, I will see if I can find a replacement. |
Huh, that's good to know. The ones Steam generates seem to put platform near the beginning instead. I'll try moving it to the end. |
New contents of controller config file:
Output of I still see However, if I then unplug and plug back in the game controller while the app is still running, the subsequent plug-in will be detected as a Is |
...just out of curiosity I tried moving the |
OK, I've gotten something in my local environment that "solves" the issue for me (whether it's a real solution or just a dirty hack I'll leave to someone who actually knows their way around SDL 😂). After adding the mappings from file, I check if there's already a gamepad at the position specified in
With this my controller can be used right away, without having to unplug & replug it. |
OK. SDL will push a bunch of initial events onto the event queue when it's initialized. I'm assuming that since we call
This would effectively "forward" the joy event as game controller event so we can properly connect the device via the game controller subsystem. |
On second thought, it looks like SDL pushes both a joy event and a game controller event when a recognized gamepad is connected, so we would have duplicate events in that case. Probably not an elegant solution. |
After some thought, I believe the most straightforward solution is to just use the joy events and check whether the given joystick device is a valid game controller. By the time this is evaluated in the main event loop, the new mapping will have taken effect. I uploaded my proposed fix in a new branch |
I gave it a test run and it seems to work great! |
Good to hear. Thanks for your help in debugging this issue. I'll merge this fix now. And thanks for the heads up on the incorrect handling of the return value of |
My gamepad in lsusb:
Bus 003 Device 005: ID 0925:1700 Lakeview Research PS/SS/N64 Joypad
This pad works fine in some games but wasn't being recognized by flex-launcher.
I did some debugging and discovered that SDL raises a
SDL_JOYDEVICEADDED
event for this gamepad but NOT aSDL_CONTROLLERDEVICEADDED
event, so the current code never ends up callingconnect_gamepad()
about it.I may be able to hack a fix together for my own use case. But this should probably be fixed for a more general audience too.
The text was updated successfully, but these errors were encountered: