Skip to content

Conversation

Nintorch
Copy link
Contributor

@Nintorch Nintorch commented Jun 25, 2025

Closes godotengine/godot-proposals#2829
Closes godotengine/godot-proposals#8519
Closes godotengine/godot-proposals#6930
Closes godotengine/godot-proposals#3799
Fixes #78805
Potentially addresses #98008
Partially addresses godotengine/godot-proposals#12087

Supersedes #88590
Supersedes #89193

Since SDL joypad driver was merged recently ( #106218 ), this PR adds support for new SDL joypad features that weren't previously possible due to older custom joypad implementations. These features include:

  • Getting access to gamepad's sensors (accelerometer and gyroscope), including sensor calibration and simulated gravity sensor (because SDL doesn't support real gravity sensors);
  • Setting gamepad's LED light, if supported by the gamepad;
  • Getting information about controller's power and connection information;
  • Getting access to gamepad's touchpad(s);
  • DualSense adaptive triggers;
  • Xbox rumble triggers (only available on Xbox One controllers, not to be confused with DualSense adaptive triggers).
  • Getting gamepad's model type to check if it's a PS4 controller, an Xbox One controller, etc.;
  • Getting joypad type (checking if it's a gamepad, arcade stick, flight stick, etc.);
  • Getting the number of available buttons and axes on a controller;
  • Getting the names for gamepad's button and axes names, if available (these may not work exactly as expected if the gamepad is not a first-party gamepad from PlayStation, Xbox or Nintendo because SDL cannot otherwise check what the labels on the controller are);
  • Sending custom data packets to supported controllers via Input.send_joy_packet().

There are other more complex features that can be done with SDL functionality, but I decided to move them to separate PRs (see "TODO for separate PRs" section below).

There are some SDL functions that may not be necessary in Godot, so I think they need some discussion before they can be implemented (see "Features that need to be discussed whether they should be implemented or not" section below).

Roadmap and TODO

Documentation:

  • Documentation for joypad device types (SDL_JoystickType): https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes
  • Sensor documentation: https://wiki.libsdl.org/SDL3/SDL_SensorType (BTW Horizontal joycons' yaw and roll axes are swapped, needs to be reported to SDL github) Just checked again, they're not
  • How accelerometer's gravity is calculated: https://developer.android.com/reference/android/hardware/SensorEvent#values
  • Document how to get raw accelerometer values (Input.get_joy_accelerometer() + Input.get_joy_gravity())
  • Input.get_joy_model_axis/button_name() may not work exactly as expected if the gamepad is not a first-party gamepad from PlayStation, Xbox or Nintendo because SDL cannot otherwise check what the labels on the controller are
  • Motion sensors examples with calibration
  • SDL doesn't support motion sensors (and LED light) on platforms other than the desktop ones (they don't work well on Android and iOS and they don't work at all on Web since no hidapi support on Web)
  • Fix "TODO: description"
TODO when Godot gets SDL input support for other platforms
TODO for separate PRs
Features that need to be discussed whether they should be implemented or not

TODO 2:

  • Test project on macOS doesn't recognize the joycon controllers, even though InputMap does recognize them
  • Mention that people will need some sort of driver for Xbox trigger rumble to work, there's an SDL github issue where that's described (or maybe they won't need it? [Windows] Trigger rumble libsdl-org/SDL#12071 )
  • Mention that it's recommended to disable the motion sensors if they're no longer needed because it can theoretically drain the controller's battery more quickly

Here's a small project to test new joypad features:
JoypadTest.zip

@Calinou
Copy link
Member

Calinou commented Jun 25, 2025

Supersedes #88590

Note that #88590 also implements DualSense adaptive triggers, which isn't on the roadmap of this PR currently. This could be done in a separate PR in any case, but I thought I'd mention it as SDL supports adaptive triggers.

@Nintorch
Copy link
Contributor Author

Supersedes #88590

Note that #88590 also implements DualSense adaptive triggers, which isn't on the roadmap of this PR currently. This could be done in a separate PR in any case, but I thought I'd mention it as SDL supports adaptive triggers.

Good catch, thank you, I'll add that to the roadmap!

@Meorge
Copy link
Contributor

Meorge commented Jun 25, 2025

I'm especially excited to see Joy-Con support listed here. I think those are really fun little controllers, so much so that I started making my own C++ library for interfacing with them and a Godot GDExtension based off of that - however, obviously being a GDExtension, it doesn't mesh very well with Godot's built-in APIs. Having the support be more built-in to the engine would be awesome!

I'm not sure how much overlap there is between SDL's Joy-Con support and what my library does, but if a lot of the Joy-Con-specific features don't have SDL APIs, I may be able to help on that front 😄

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch 2 times, most recently from 9940d41 to 9e6d7d8 Compare June 26, 2025 13:25
@Nintorch
Copy link
Contributor Author

I made a list of features that need discussion before implementing, so if you think any of the listed features are important to have built into the engine, you can let me know!

@Nintorch Nintorch changed the title Add support for new SDL joypad features (gyroscope, accelerometer, LED, etc.) (WIP) Introduce new joypad features provided by SDL3 (WIP) Jun 26, 2025
@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch 2 times, most recently from b39eef9 to e70bbb5 Compare June 27, 2025 18:47
@mubinulhaque
Copy link

mubinulhaque commented Jun 28, 2025

Feature request for a separate PR: querying for separate keyboards and mice (SDL_GetKeyboards and SDL_GetMice respectively)

@Calinou
Copy link
Member

Calinou commented Jun 28, 2025

Feature request for a separate PR: querying for separate keyboards and mice (SDL_GetKeyboards and SDL_GetMice respectively)

Multi-keyboard/mouse support seems subpar in SDL 3 from what I've heard, so it may not be worth the effort. This is based on what I've seen in the Perfect Dark PC port Discord (people have tried implementing it there, but quickly regretted it).

@LunaCapra
Copy link
Contributor

Will the gamepad type for GameCube controllers be included? It seems to be the only one not added from SDL_GamepadType.

@Meorge
Copy link
Contributor

Meorge commented Jun 28, 2025

I'm still very excited for Joy-Con support and would love to contribute where I can, but thinking about it more, I think specialized support for its features would fit better as a separate PR (if not some kind of plugin/addon). 😅

Maintainers should have more of a say in this of course, but I could see it being helpful to split this up into multiple smaller PRs so that each individual one is easier to test and verify.

That all being said, for this PR (whether it ends up being split later or not) I can certainly test its functionality on macOS. Let me know if/when you'd like me to give that a shot! 😄

@Nintorch
Copy link
Contributor Author

Will the gamepad type for GameCube controllers be included? It seems to be the only one not added from SDL_GamepadType.

Godot is currently using the latest stable release of SDL (3.2.16), which doesn't support GameCube controllers :( https://github.com/libsdl-org/SDL/blob/c9a6709bd21750f1ad9597be21abace78c6378c9/include/SDL3/SDL_gamepad.h

@LunaCapra
Copy link
Contributor

Will the gamepad type for GameCube controllers be included? It seems to be the only one not added from SDL_GamepadType.

Godot is currently using the latest stable release of SDL (3.2.16), which doesn't support GameCube controllers :( https://github.com/libsdl-org/SDL/blob/c9a6709bd21750f1ad9597be21abace78c6378c9/include/SDL3/SDL_gamepad.h

That's a shame. Maybe in the future then!

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch from e70bbb5 to f891f14 Compare July 2, 2025 18:17
@Meorge
Copy link
Contributor

Meorge commented Jul 2, 2025

I know this is still marked as a draft, so these may be things you're aware of and are planning on fixing, but just in case: I got excited and decided to pull it to test on macOS, and ran into some compilation errors.

In joypad_sdl.cpp, a few switch statements don't have default cases or otherwise handle all of the possible values:

drivers/sdl/joypad_sdl.cpp:335:10: error: enumeration values 'INVALID', 'SDL_MAX', and 'MAX' not handled in switch [-Werror,-Wswitch]
  335 |         switch (p_axis) {
      |                 ^~~~~~
drivers/sdl/joypad_sdl.cpp:335:10: note: add missing switch cases
  335 |         switch (p_axis) {
      |                 ^
  336 |                 case JoyAxis::LEFT_X:
drivers/sdl/joypad_sdl.cpp:451:10: error: enumeration values 'INVALID', 'SDL_MAX', and 'MAX' not handled in switch [-Werror,-Wswitch]
  451 |         switch (p_button) {
      |                 ^~~~~~~~
drivers/sdl/joypad_sdl.cpp:451:10: note: add missing switch cases
  451 |         switch (p_button) {
      |                 ^
  452 |                 case JoyButton::A:
2 errors generated.

If I add default cases to those switch statements, I get errors about the parameters in ScePadTriggerEffectParam not all being initialized:

[ 74%] In file included from core/input/.scu/scu_core_input.gen.cpp:1:
./core/input/input.cpp:1224:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1224 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_OFF);
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
      |                                               ^
[ 74%] ./core/input/input.cpp:1236:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1236 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_FEEDBACK);
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
[ 74%]                                               ^
./core/input/input.cpp:1257:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1257 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_WEAPON);
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
      |                                               ^
[ 74%] ./core/input/input.cpp:1279:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1279 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_VIBRATION);
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                   [ 74%]                        \
      |                                               ^
[ 74%] ./core/input/input.cpp:1291:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1291 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_MULTIPLE_POSITION_FEEDBACK);
      |         ^
[ 74%]  note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
      |                                               ^
./core/input/input.cpp:1320:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
[ 74%] E_SLOPE_FEEDBACK);GGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MOD
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
      |                                               ^
[ 74%] ./core/input/input.cpp:1337:2: error: missing field 'padding' initializer [-Werror,-Wmissing-field-initializers]
 1337 |         SETUP_TRIGGER_EFFECT(SCE_PAD_TRIGGER_EFFECT_MODE_MULTIPLE_POSITION_VIBRATION);
      |         ^
./core/input/input.cpp:1213:40: note: expanded from macro 'SETUP_TRIGGER_EFFECT'
 1213 |         ScePadTriggerEffectParam effect = { 0 };                                                                                                \
      |                                               ^
[ 77%] 7 errors generated.

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch from f891f14 to 3a143d4 Compare July 2, 2025 18:51
@Nintorch
Copy link
Contributor Author

Nintorch commented Jul 2, 2025

I haven't tried to compile on macOS yet, but I think I fixed these 2 errors, I hope it should now compile!

@Meorge
Copy link
Contributor

Meorge commented Jul 2, 2025

Thanks! It compiles now, but unfortunately I get a segmentation fault immediately upon starting Godot... I may be able to look further into that soon


LLDB is giving this output for the location of the segfault:

Godot Engine v4.5.beta.custom_build.3a143d442 (2025-07-02 18:50:15 UTC) - https://godotengine.org
Process 33797 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16f5ffff8)
    frame #0: 0x000000010307d4e0 godot.macos.editor.dev.arm64`dlmalloc(bytes=80) at SDL_malloc.c:4615:52
   4612     if (bytes <= MAX_SMALL_REQUEST) {
   4613       bindex_t idx;
   4614       binmap_t smallbits;
-> 4615       nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
   4616       idx = small_index(nb);
   4617       smallbits = gm->smallmap >> idx;
   4618
Target 0: (godot.macos.editor.dev.arm64) stopped.

The backtrace seems to give an infinite loop?

(lldb) bt
  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x16f5ffff8)
  * frame #0: 0x000000010307d4e0 godot.macos.editor.dev.arm64`dlmalloc(bytes=80) at SDL_malloc.c:4615:52
    frame #1: 0x0000000103081e94 godot.macos.editor.dev.arm64`dlcalloc(n_elements=1, elem_size=80) at SDL_malloc.c:4837:9
    frame #2: 0x0000000103084554 godot.macos.editor.dev.arm64`SDL_calloc(nmemb=1, size=80) at SDL_malloc.c:6471:11
    frame #3: 0x00000001030a14e0 godot.macos.editor.dev.arm64`SDL_CreateMutex at SDL_sysmutex.c:34:26
    frame #4: 0x00000001030a1894 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:75:23
    frame #5: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    frame #6: 0x00000001030a18a0 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:76:26
    frame #7: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    frame #8: 0x00000001030a18a0 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:76:26
    frame #9: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    ...
    frame #1322: 0x00000001030a18a0 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:76:26
    frame #1323: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    frame #1324: 0x00000001030a18a0 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:76:26
    frame #1325: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    frame #1326: 0x00000001030a18a0 godot.macos.editor.dev.arm64`SDL_CreateSemaphore(initial_value=0) at SDL_syssem.c:76:26
    frame #1327: 0x0000000103090bdc godot.macos.editor.dev.arm64`SDL_CreateCondition at SDL_syscond.c:58:21
    ...

@Nintorch
Copy link
Contributor Author

Nintorch commented Jul 3, 2025

This PR should likely fix your issue: #107963
It happened to you because I haven't rebased this PR yet, I will do that once all features are ready!

EDIT: Decided to rebase now!

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch 3 times, most recently from 0e453aa to 898c22f Compare July 3, 2025 08:10
@Meorge
Copy link
Contributor

Meorge commented Jul 3, 2025

Thanks for the rebase! With that, the editor is now building, and I'm able to run the demo project.

It looks like the instance of JoypadSDL being used by the game process doesn't receive the joystick/gamepad-added events, which causes the joypads to be registered as not attached, and thus the special methods to not work. Here's my console output with some print_line statements I added to track the state:

> godot --editor --path "/Users/malcolmanderson/Downloads/JoypadTest"
Godot Engine v4.5.beta.custom_build.898c22fd8 (2025-07-03 08:10:03 UTC) - https://godotengine.org
construct joypadsdl (FOR EDITOR)
Metal 3.2 - Forward+ - Using Device #0: Apple - Apple M4 Pro (Apple9)

joystick added event
get_sdl_joystick: p_pad_idx = 0, max is 16, attached = true
Event for joypad 0: 1619 (SDL_EVENT_GAMEPAD_ADDED)
Event for joypad 0: 1543 (SDL_EVENT_JOYSTICK_BATTERY_UPDATED)
[0]
DualSense Wireless Controller 050057564c050000e60c00001be36d04

(GAME STARTED)
Godot Engine v4.5.beta.custom_build.898c22fd8 (2025-07-03 08:10:03 UTC) - https://godotengine.org
construct joypadsdl
Metal 3.2 - Forward+ - Using Device #0: Apple - Apple M4 Pro (Apple9)

get_sdl_joystick: p_pad_idx = 0, max is 16, attached = false
ERROR: JoypadSDL::get_joypad_features: joy == nullptr
   at: get_joypad_features (drivers/sdl/joypad_sdl.cpp:584)
   GDScript backtrace (most recent call first):
       [0] _ready (res://test_2.gd:4)

Note that after GAME STARTED, a new JoypadSDL is constructed (print_line() in JoypadSDL::JoypadSDL() is run), but the SDL_EVENT_GAMEPAD_ADDED event is not caught by it, so it's not able to update its copy of the joypads array.

That's my hypothesis for what's going on at the moment, at least. I know you may still be working on putting together the core functionality for the PR, but please let me know if there's anything else I can test or results I can provide to help with the macOS support!

@Nintorch
Copy link
Contributor Author

Thank you for testing, Calinou! May I ask if you can somehow check the C++ stacktrace when the error happens? I would like to fix this issue, but I'm still confused on how get_joypad_features can be called if the joypad adding event hasn't been called.

@Calinou
Copy link
Member

Calinou commented Aug 13, 2025

Thank you for testing, Calinou! May I ask if you can somehow check the C++ stacktrace when the error happens? I would like to fix this issue, but I'm still confused on how get_joypad_features can be called if the joypad adding event hasn't been called.

Actually, I realized features work when not using game embedding (due to input working differently with macOS game embedding - it uses an IPC approach instead of fake window embedding). In this case, it works with all 3 controllers, although gyro stops working after hotplugging, even if I try to calibrate sensors again (LED control still works).

I'm not sure what it would take to make the new features work with macOS game embedding. @stuartcarnie Any ideas?

Screenshot 2025-08-13 at 15 23 39 Screenshot 2025-08-13 at 15 23 58 Screenshot 2025-08-13 at 15 24 33

@Nintorch
Copy link
Contributor Author

Nintorch commented Aug 13, 2025

I'm not a macOS developer, so I'm not sure how to fix the features being missing when the window is embedded 😅 But I'll look into the hotplugging issue later and see if I can fix it!

Actually, I will try to reproduce the first issue and see if I can fix it too

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch from f0f6feb to 8471453 Compare August 13, 2025 13:59
@Nintorch
Copy link
Contributor Author

Nintorch commented Aug 13, 2025

By the way, DualSense adaptive triggers should now be fixed! I used a piece of code from an older SDL2 test with adaptive triggers testing and this library (I also added it to COPYRIGHT.txt) to generate the DualSense packets.

Also, should SDL_SendJoystickEffect be exposed to the users? It was also used for DualSense adaptive triggers functionality here

@Nintorch
Copy link
Contributor Author

Thank you for testing, Calinou! May I ask if you can somehow check the C++ stacktrace when the error happens? I would like to fix this issue, but I'm still confused on how get_joypad_features can be called if the joypad adding event hasn't been called.

Actually, I realized features work when not using game embedding (due to input working differently with macOS game embedding - it uses an IPC approach instead of fake window embedding). In this case, it works with all 3 controllers, although gyro stops working after hotplugging, even if I try to calibrate sensors again (LED control still works).

I'm not sure what it would take to make the new features work with macOS game embedding. @stuartcarnie Any ideas?

Screenshot 2025-08-13 at 15 23 39 Screenshot 2025-08-13 at 15 23 58 Screenshot 2025-08-13 at 15 24 33

Also, now that I look at the button labels, may I ask what button presses trigger the Misc1 and paddles on DualSense and DualSense Edge? In other words, what should the code report instead of having these generic names for these controllers?

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch from 8471453 to d11b64f Compare August 13, 2025 17:20
@Meorge
Copy link
Contributor

Meorge commented Aug 13, 2025

I'm happy to also corroborate that when disabling the embedded game window, the DualSense is now mostly working on my end as well! 🥳

Godot.DualSense.demo.working.mp4

The "Misc1" button is the microphone mute button (button M in the "Front" diagram here). If by "paddles" you mean L2 and R2 (buttons B and E in the "Top" diagram here), I don't see that they are mapped to a button - instead, they're on an axis.

When I press the "Rumble triggers" button in verbose mode, I get an SDL debug message:

SDL Debug (priority: 6): That operation is not supported

@Nintorch
Copy link
Contributor Author

Thank you for testing, Meorge! At the moment I haven't added adaptive triggers to the test project, and rumble triggers is a feature exclusive to Xbox One controllers, so that's why the operation is not supported.
By paddles I meant buttons that are labeled "Paddle1", "Paddle2", "Paddle3" and "Paddle4" as seen on Calinou's DualSense Edge testing screenshot. Thanks for telling me that the Misc1 button is the microphone mute button!

@Meorge
Copy link
Contributor

Meorge commented Aug 14, 2025

Ahh alright, that definitely sounds like a valid reason for rumble triggers not working 😅

@bruvzg
Copy link
Member

bruvzg commented Aug 14, 2025

Using IPC for embedded process SDL joypad input is pretty much pointless, it should work directly - here's a PR - #109603 (in combination with this PR embedded process input and new features seems to work fine, no additional changes required).

@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch 2 times, most recently from 05cb260 to 431d03c Compare August 14, 2025 10:02
This commit adds support for new SDL joypad features that weren't previously possible due to older custom joypad implementations.
These features include accelerometer, gyroscope, LED lights, touchpads and more.
@Nintorch Nintorch force-pushed the joypad-new-sdl-features branch from 431d03c to 16c2fbf Compare August 14, 2025 13:06
@Nintorch Nintorch marked this pull request as ready for review August 14, 2025 13:07
@Nintorch Nintorch requested review from a team as code owners August 14, 2025 13:07
@Nintorch
Copy link
Contributor Author

Good news, the PR is basically done! :)

@Nintorch Nintorch changed the title Introduce new joypad features provided by SDL3 (WIP) Introduce new joypad features provided by SDL3 Aug 14, 2025
@santagada
Copy link
Contributor

I'm not a Godot contributor, but looking at the patch it looks great, except SDL_error.c where the logging of errors is uncommented, and it says right over it that many errors are recoverable and would never be seen in the public api, maybe logging them in the release of godot might not be a good idea.

@Nintorch
Copy link
Contributor Author

I'm not a Godot contributor, but looking at the patch it looks great, except SDL_error.c where the logging of errors is uncommented, and it says right over it that many errors are recoverable and would never be seen in the public api, maybe logging them in the release of godot might not be a good idea.

True, but these errors are only printed if the engine was ran with --verbose flag (see joypad_sdl.cpp, I made a custom logging function for SDL), so normally these errors won't be shown, but it would be helpful in case an SDL-related (or joystick input related) issue is reported so the users won't have to compile the engine with this fix themselves to see the SDL errors :)

@Nintorch
Copy link
Contributor Author

Nintorch commented Aug 25, 2025

Note for myself (or anyone else who's willing to test it, thanks :) ): check if #78805 is resolved by this PR or in newer 4.5 betas

@Meorge
Copy link
Contributor

Meorge commented Aug 25, 2025

Testing on macOS Sequoia 15.6.1 and a Joy-Con (R), with no Joy-Con (L) connected:

  • ZR is mapped to Joypad Button 18 (Xbox Paddle 3)
  • R is mapped to Joypad Button 16 (Xbox Paddle 1)
  • All other buttons seem to have expected mappings

For a Joy-Con (L) connected and no Joy-Con (R) connected:

  • The Minus button is mapped to Joypad Button 6 (Start, Xbox Menu, Nintendo +)
  • ZL is mapped to Joypad Button 19 (Xbox Paddle 4)
  • L is mapped to Joypad Button 17 (Xbox Paddle 2)
  • Capture is mapped to Joypad Button 5 (Guide, Sony PS, Xbox Home)
  • All other buttons seem to have expected mappings

When both Joy-Con are connected:

  • Joy-Con (L)'s SL is mapped to Joypad Button 17 (Xbox Paddle 2)
  • Joy-Con (L)'s SR is mapped to Joypad Button 19 (Xbox Paddle 4)
  • Joy-Con (R)'s SL is mapped to Joypad Button 18 (Xbox Paddle 3)
  • Joy-Con (R)'s SR is mapped to Joypad Button 16 (Xbox Paddle 1)
  • All other buttons seem to have expected mappings

TL;DR: every Joy-Con button is recognized 🙂


However, in testing this, I did find that it seems to struggle with Joy-Con controllers. The test project doesn't indicate that a controller is connected ("Gamepad connected" is unchecked, "Gamepad name" is empty, etc) although the Input Map menu does register inputs from them.

Additionally, if I connect the Joy-Cons to my computer while Godot is running, I often get an error like

ERROR: Error opening gamepad at index 3: Couldn't find mapping for device (3)
   at: process_events (drivers/sdl/joypad_sdl.cpp:144)

@Nintorch
Copy link
Contributor Author

Thank you for testing, Meorge!

However, in testing this, I did find that it seems to struggle with Joy-Con controllers. The test project doesn't indicate that a controller is connected ("Gamepad connected" is unchecked, "Gamepad name" is empty, etc) although the Input Map menu does register inputs from them

Oh, that's interesting, I will have to look into it.

Additionally, if I connect the Joy-Cons to my computer while Godot is running, I often get an error like

I also get an error like this when I connect both joycon controllers on Windows, but after that they work just fine, the test project recognizes them too.

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