Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[input] Gamepad buttons and axis not working (linux) #1319

Closed
Vixeliz opened this issue Jul 22, 2020 · 18 comments
Closed

[input] Gamepad buttons and axis not working (linux) #1319

Vixeliz opened this issue Jul 22, 2020 · 18 comments

Comments

@Vixeliz
Copy link

Vixeliz commented Jul 22, 2020

Issue description

I have tried in both my own project and the gamepad example both in browser and
on my machine compiled. However it just shows up with gamepad not detected.
I have tested with jstest to make sure the joystick is showing up on a system
level and it appears to be fine. (To note i have tried this with both a Xbox
one controller and a steam controller)

Environment

I am on KISS Linux latest stable kernel.

Code Example

Just the code in the gamepad_test_example that checks if a gamepad is
available. AKA (IsGamePadAvailable(GAMEPAD_PLAYER1))

@raysan5
Copy link
Owner

raysan5 commented Jul 25, 2020

@muevoid is the gamepad connected before running the example? It should be at least detected... it could be a KISS Linux specific issue...

@Vixeliz
Copy link
Author

Vixeliz commented Jul 25, 2020

Yes i can confirm the gamepad is connected before hand. I'm not sure exactly what on KISS could cause this issue.

@raysan5
Copy link
Owner

raysan5 commented Jul 25, 2020

@muevoid raylib uses GLFW internally on DESKTOP_PLATFORM (Windows, Linux, macOS) to manage inputs. Every frame [core] PollInputEvents() is called that also scans possible gamepads with glfwJoystickPresent().

IsGamepadAvailable(int gamepad) just returns the result of that detection (true or false), you can try with different int gamepad values just in case but if the function always returns false then the issue is probably on GLFW side and not in raylib.

@Vixeliz
Copy link
Author

Vixeliz commented Jul 25, 2020

Kk I am familiar with glfw and will test this tommorow.

@raysan5
Copy link
Owner

raysan5 commented Jul 25, 2020

Just a reference in case it can be useful in the future for gamepad buttons mapping: https://www.glfw.org/docs/3.3/input_guide.html#gamepad

@defutura
Copy link

defutura commented Aug 10, 2020

An additional perspective > I just tried this on Ubuntu 20.04 LTS x86_64, kernel: 5.4.0-42-generic, using raylib 3.0.0. My build of 'core_input_gamepad.c' detects both a cheap Logitech controller and an 8bitdo SNES controller. They do not need to be plugged in before compilation; I can disconnect and reconnect the controllers, and the program will detect them and display their names correctly. However, I can't seem to be able to get any input from any of them, and neither buttons nor axes show up in the interface.

@Vixeliz
Copy link
Author

Vixeliz commented Aug 10, 2020

Hmmm I am still doing testing will post here soon.

@Vixeliz
Copy link
Author

Vixeliz commented Aug 11, 2020

This is for sure an issue with my configuration and not raylib. So I will close this jist of it was my Xorg configuration and some stuff with evdev.

Edit: I believe defutura's issue is unrelated to this issue.

@Vixeliz Vixeliz closed this as completed Aug 11, 2020
@Vixeliz
Copy link
Author

Vixeliz commented Aug 11, 2020

I may have talked too soon my issue is now identical to defuturas. Gamepad is detected by raylib however no buttons or axis is detected.

@Vixeliz Vixeliz reopened this Aug 11, 2020
@Vixeliz Vixeliz changed the title [input] Gamepad not showing up linux [input] Gamepad buttons and axis not working (linux) Aug 11, 2020
@defutura
Copy link

defutura commented Aug 11, 2020

neither buttons nor axes show up in the interface.

I should have expressed myself more clearly here. My build does in fact detect the 5 axes correctly with GetGamepadAxisCount() on line 164, and displays them with the following for loop, but no input data is shown for any of them.

@Vixeliz
Copy link
Author

Vixeliz commented Sep 2, 2020

@defutura Have you had any luck with this yet?

@defutura
Copy link

defutura commented Sep 5, 2020

@muevoid No, I haven't looked at it yet, I'm doing most of my programming on a Windows machine. Will post here if I find anything out.

@coderoth
Copy link
Contributor

coderoth commented Sep 16, 2020

@defutura, @muevoid:
I had the same problem today. Raylib identified my gamepad and correctly detected connections/disconnections, but couldn identify button presses and axis movements.

My joystick worked fine with SDL and glfw3 sample codes, but not with raylib.
Following @raysan5 comment, my case was that the glfw gamepad database mapping was not updated with my model (03000000c62400003a54000001010000).

I've found a mapping for my gamepad here:
https://github.com/gabomdq/SDL_GameControllerDB/

With the mapping configuration for my gamepad, I cloned the raylib repo and added the mapping in the file <RAYLIB_HOME>/src/external/glfw/src/mappings.h and then recompiled the whole thing again.

After this it all worked.

To find my gamepad ID, I added a debug printf to log js->guid at the beginning of findValidMapping (<RAYLIB_HOME>/src/external/glfw/src/input.c). Then I recompiled the gamepad example and ran, checking the console output for the Gamepad ID.

Or, you could try to update the mappings dynamically
https://www.glfw.org/docs/3.3/input_guide.html#gamepad_mapping

@raysan5
Copy link
Owner

raysan5 commented Sep 18, 2020

@coderoth thank you very much for reporting!

Please, could you check if GLFW3 main branch is also updated? I will update raylib glfw version with it...

@coderoth
Copy link
Contributor

coderoth commented Sep 18, 2020

It seems the glfw mappings.h file is outdated (it was updated 10 months ago and it has 476 lines, while the gamecontrollerdb.txt has more than 800).

They have a Cmake script that "updates" the mappings.h file with the latest gamecontrollerdb.txt contents:
https://github.com/glfw/glfw/blob/master/CMake/GenerateMappings.cmake

Maybe they manually execute that cmake script as part of the build?

I cloned their repository and issued the following commands to update the mappings and it worked (the final mappings file went from 476 lines to 954 and my gamepad id was finally there):

cd glfw/CMake
cmake -P GenerateMappings.cmake ../src/mappings.h.in ../src/mappings.h

That command worked when I executed it from the raylib repo too (<RAYLIB_ROOT>/src/external/glfw/CMake).
Maybe this additional step could be added to the raylib build process, before compiling?
Or you could run the above cmake command and commit a more recent mapping to the raylib repository.

@raysan5
Copy link
Owner

raysan5 commented Sep 19, 2020

@coderoth I maintain the plain Makefiles building system, not the CMake... maybe I can just update mappings.h manually on raylib side. Could you provide the updated file, please?

@coderoth
Copy link
Contributor

Updated version of the file:
mappings.h.txt

Created the following pull request, if you prefer:
#1381

@raysan5
Copy link
Owner

raysan5 commented Sep 25, 2020

Updated! It should work now! Closing the issue!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants