Skip to content

Enable GameCube controller adapter support on Linux - #118147

Open
Nintorch wants to merge 1 commit into
godotengine:masterfrom
Nintorch:enable-linux-gamecube-support
Open

Enable GameCube controller adapter support on Linux#118147
Nintorch wants to merge 1 commit into
godotengine:masterfrom
Nintorch:enable-linux-gamecube-support

Conversation

@Nintorch

@Nintorch Nintorch commented Apr 3, 2026

Copy link
Copy Markdown
Member

This PR enables GameCube controllers support on Linux by enabling libusb and HAVE_ENABLE_GAMECUBE_ADAPTORS that does proper GameCube controller initialization via libusb.
Not tested by me since I don't have GameCube controllers and GameCube adapters.

CC @Repiteo since you mention GameCube controller adapters in several of your Godot proposals:

Note: SDL described that the official adapter can be used exclusively by libusb, which detaches drivers and makes it unusable by the rest of the OS at the moment:

/* If the platform has any backend other than libusb, try to avoid using
* libusb as the main backend for devices, since it detaches drivers and
* therefore makes devices inaccessible to the rest of the OS.
*
* We do this by whitelisting devices we know to be accessible _exclusively_
* via libusb; these are typically devices that look like HIDs but have a
* quirk that requires direct access to the hardware.
*/
static const struct {
Uint16 vendor;
Uint16 product;
} SDL_libusb_whitelist[] = {
{ 0x057e, 0x0337 } // Nintendo WUP-028, Wii U/Switch GameCube Adapter
};

This means that while one process (the editor) has acquired the device, other processes (the debugger with the game) can't see it, but I think running the exported game alone should work!

TODO:

  • Disconnect the controllers from the editor so the running game can detect them (Not sure that would help at the moment :( )

@Nintorch Nintorch changed the title Enable GameCube support on Linux Enable GameCube controller adapter support on Linux Apr 3, 2026
@Nintorch Nintorch added this to the 4.x milestone Apr 3, 2026
@Nintorch
Nintorch force-pushed the enable-linux-gamecube-support branch 2 times, most recently from 8097e7f to 736f0b0 Compare April 3, 2026 10:23
@Nintorch
Nintorch force-pushed the enable-linux-gamecube-support branch from 736f0b0 to 16953cc Compare April 3, 2026 10:31
@Nintorch

Nintorch commented Apr 3, 2026

Copy link
Copy Markdown
Member Author

@bakana808 Hello, may I ask if you can test this PR, please? See https://contributing.godotengine.org/en/latest/pull_requests/testing.html on how to download a build of this PR, you'll want to download the linux-editor-mono one, but note that due to how Godot's CI is done, the Linux editor build requires .NET (C#) to be installed on the system. 😅

run: |
sudo apt-get update
sudo apt-get install libwayland-bin # TODO: Figure out somehow how to embed this one.
sudo apt-get install libusb-1.0-0-dev

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libusb-1.0-0-dev # Used by SDL's GameCube HIDAPI driver.

@bakana808

bakana808 commented Apr 3, 2026

Copy link
Copy Markdown

@bakana808 Hello, may I ask if you can test this PR, please? See https://contributing.godotengine.org/en/latest/pull_requests/testing.html on how to download a build of this PR, you'll want to download the linux-editor-mono one, but note that due to how Godot's CI is done, the Linux editor build requires .NET (C#) to be installed on the system. 😅

Thanks for your work on this! I did try it out briefly, and my Gamecube controller seems to be detected in the editor now (I can add input maps and such now), however when testing the game it doesn't seem to be working in the game, at least for me.

From my experience using this GCC adapter, when one app is already "using" the adapter, other apps cannot see or use it at the same time. I'm guessing that's what's happening here (the editor is already using the adapter so the game can't see it) but I'll play around with it more when I have more time. I suspect it probably works if I export the game first and run it on its own without the editor.

@Nintorch

Nintorch commented Apr 4, 2026

Copy link
Copy Markdown
Member Author

Thank you for testing! SDL described that the official adapter can be used exclusively by libusb, which detaches drivers and makes it unusable by the rest of the OS at the moment:

/* If the platform has any backend other than libusb, try to avoid using
* libusb as the main backend for devices, since it detaches drivers and
* therefore makes devices inaccessible to the rest of the OS.
*
* We do this by whitelisting devices we know to be accessible _exclusively_
* via libusb; these are typically devices that look like HIDs but have a
* quirk that requires direct access to the hardware.
*/
static const struct {
Uint16 vendor;
Uint16 product;
} SDL_libusb_whitelist[] = {
{ 0x057e, 0x0337 } // Nintendo WUP-028, Wii U/Switch GameCube Adapter
};

That's what might be happening here, one process (the editor) has acquired the device, so other processes (the debugger with the game) can't see it, but I think running the exported game alone should work!

EDIT: Now that I think about it, maybe we can make the Godot editor disconnect the controller so the game can then detect it, I will need to try it.

@Nintorch
Nintorch marked this pull request as ready for review April 4, 2026 04:24
@Nintorch
Nintorch requested review from a team as code owners April 4, 2026 04:24
@Nintorch
Nintorch requested a review from a team April 4, 2026 04:26
@Nintorch
Nintorch marked this pull request as draft April 4, 2026 07:45
@Nintorch

Copy link
Copy Markdown
Member Author

I checked the SDL GameCube HIDAPI driver source code and realized that it calls SDL_EnableGameCubeAdaptors() on device initialization and doesn't do anything on joystick open and close, so to fix the problem of the gamepad not working in game debug the code that deals with the gamepads via libusb will have to be changed, which I can't personally do since I don't have the controller (which will require quite a bit of testing) and I don't have any experience working with libusb, so that problem is now outside of the scope of this PR I'm afraid, unless someone can help me fix it :(

@ahpakar

ahpakar commented May 27, 2026

Copy link
Copy Markdown

Just commenting to confirm that I had the same experience with the mono build on Arch Linux; one can add input maps in the editor but no input is read (at all) when the scene is run. I can help you or others test this with my controller and adapter since I'm pretty desperate for this feature, but I'm not a libusb expert either.

@notroid5

notroid5 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Did not test this PR but if anyone wants to work on the libusb fix, I can help with testing, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GameCube Controllers Connected Via the Official GCC Adapter Not Working

4 participants