raylib: [rcore] Gamepad not working on macOS
Please, before submitting a new issue verify and check:
- I tested it on latest raylib version from master branch
- I checked there is no similar issue already reported
- I checked the documentation on the wiki
- My code has no errors or misuse of raylib
Issue description
Gamepad input not working. I tried 2 different controllers.
- Xbox One Series X connected via USB
- IsGamepadAvailable(0) returns false.
- Nintendo Switch Pro Controller connected via USB
- IsGamepadAvailable(0) returns true.
- No button input is ever detected
Environment
MacOSX Ventura on an M2 Mac.
Issue Screenshot
Can’t really show this.
Code Example
#include "raylib.h"
#include <stdio.h>
int main(void)
{
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "Gamepads Broken");
SetTargetFPS(60);
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
if(IsGamepadAvailable(0)) {
DrawText("FOUND GAMEPAD TEST", 190, 275, 20, PURPLE);
if(IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) {
DrawText("BUTTON PRESSED", 190, 350, 20, PURPLE);
}
}
EndDrawing();
}
CloseWindow();
return 0;
}
Provide minimal reproduction code to test the issue. Please, format the code properly and try to keep it as simple as possible, just focusing on the experienced issue.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 44 (13 by maintainers)
I think we maybe should keep it open to make it easier to track the progress upstream? Technically this issue is about all gamepads, so if the Switch Pro Controller is still not working, the issue is not yet resolved. Additionally, other people who might have problems with gamepads will find this (open) issue, instead of making a new one.
Edit: Added Pro Controller (Switch) test. Edit 2: With the changes made by @sleeptightAnsiC on #5036 , the Xbox Wireless Controller now works.
I can confirm the issue. At least for me, the only controller that works on macOS is the PS4 one.
I’m on Sequoia (15.4.1), using the offical gamepad example.
I tested:
Web
DUALSHOCK 4 Wireless Controller
Xbox Wireless Controller
Pro Controller (Switch)
macOS using raylib 5.5 (GLFW backend)
DUALSHOCK 4 Wireless Controller
Xbox Wireless Controller
Pro Controller (Switch)
@darzaccaro thanks for the update, reopening
This issue is not fixed.
Gamepads, while detected, do not update their inputs on MacOS for PLATFORM_DESKTOP with the GLFW backend. They work fine with the SDL backend or PLATFORM_WEB.
Tested all of these today on an M1 mac running Sequoia 15.3.2 with an “Xbox Series X Controller”.
Can we re-open this, or should I start a new issue?
Well, the problem still exist and gamepads still not work under MacOS with Raylib.
WARNING:Some comments on this issue thread seem to be removed by the user or by user-removal. It could be confusing to follow the conversation if there are references to deleted comments.Thanks @sleeptightAnsiC ! Now the Xbox Controller is working 🎉 Sadly, the Switch Pro Controller is still not recognised. But it’s something 😃
Can anyone here retest this issue with PR https://github.com/raysan5/raylib/pull/5036 ?
GLFW’s mappings are quite outdated in the current Raylib master branch. I also had a problem with the XSX|S Controller, and updating those mappings helped in my case (see https://github.com/raysan5/raylib/issues/5027#issuecomment-3054561168).
CC @hiulit @MikeshCZ @darzaccaro
@asdqwe I’ve tested under MacOS with pass results. Buttons are showed correctly in terminal.
I have the same issue on Linux with my working Xbox Wireless Controllers - key presses are never registered despite successful discovery. No matter what I do, I won’t move. Compiling raylib with
PLATFORM=PLATFORM_DESKTOP_SDLis the only thing that works.I did notice a few things that might help narrowing down the problem. Or they might not.
For the mentioned controller (Bluetooth paired), my kernel reports the following:
Based on which I would expect the following entry is correct:
However, running @konsumer 's sdl2-joystick.c reports the following:
Using steam as suggested by SDL_GameControllerDB returns the following:
If there’s anything I can help with, let me know. I can test/code/build on linux, macos and windows operating systems, with three Xbox Controllers each having a different firmware.
@konsumer This is returned value from your code:
Based on name/platform I narrowed the map lines down to these:
I get same issue, with
mapping: 1output.It still shows “Pro Controller” so mapping might not be working right.
I also tried adding same lines to mappings.h in glfw, with same results (wrong name, etc.)
Running a tester program, I got this from SDL2:
Searching through the existing mapping these are already in there, and have “correct” name:
and these were not in there:
Nothing seems to pick up these mappings, though. Like I also added this:
and for both SDL & GLFW, it uses names that are not “DK Switch Controller”
Reopening for further review.
Yep, I can setup a raylib tester with
PLATFORM_DESKTOP_SDLwith SDL2, and a no-raylib SDL2 tester.Yeh, and this all works in Linux, too, so I think it’s some mac-specific bug. It may just be that joystick, or Mac’s handling of switch controllers, I am not sure.
I have a similar issue with plain C, on mac M1 (Sonoma.) On web, it works fine, but with this code, I only get the name, but no button-events, on native raylib 5.5:
I tested with 2 controllers:
official PS5 controller, paired over bluetooth
PXN-P50S, connected over bluetooth, as “Pro Controller”
I am happy to test anything you like. I have 2 macs for testing (intel and M1.)
Update, after re-pairing a couple times, I got the PS5 controller to work, but not the PXN-P50S:
Update
I made a similar tester in GLFW (3.4) and got similar results.
Both were seen initially, but only PS5 updated it’s buttons. Like, I saw this, with some buttons pressed on both:
@SoloByte Your Raylib-cs example works fine on Linux.
I also cannot find any platform specific macos code in raylib. Maybe a newer version of GFLW will fix this.