-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Introduce new joypad features provided by SDL3 #107967
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
base: master
Are you sure you want to change the base?
Conversation
|
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 😄 |
9940d41 to
9e6d7d8
Compare
|
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! |
b39eef9 to
e70bbb5
Compare
|
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). |
|
Will the gamepad type for GameCube controllers be included? It seems to be the only one not added from |
|
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! 😄 |
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! |
e70bbb5 to
f891f14
Compare
|
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 If I add default cases to those switch statements, I get errors about the parameters in |
f891f14 to
3a143d4
Compare
|
I haven't tried to compile on macOS yet, but I think I fixed these 2 errors, I hope it should now compile! |
|
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: The backtrace seems to give an infinite loop? |
|
This PR should likely fix your issue: #107963 EDIT: Decided to rebase now! |
0e453aa to
898c22f
Compare
|
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 Note that after 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! |
True, but these errors are only printed if the engine was ran with |
|
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 |
|
Testing on macOS Sequoia 15.6.1 and a Joy-Con (R), with no Joy-Con (L) connected:
For a Joy-Con (L) connected and no Joy-Con (R) connected:
When both Joy-Con are connected:
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 |
|
Thank you for testing, Meorge!
Oh, that's interesting, I will have to look into it.
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. |
|
In Godot 4.5, is it still not possible to use Dualsense features? |
Dualsense features are implemented in this PR, so at the moment, no :( |
|
Is there any way I can access a build with this PR? |
|
Oh, thank you so much, and thank you so much for your work in bringing the DualSense features to Godot, with this, it will be possible to work on various experiences for players. |
|
You're welcome, and thank you for your kind words! ❤️ :) |
Also, may I ask if the DualSense's Adaptive Triggers work correctly with this PR? I wish I could test it myself, but I don't have a DualSense controller :( |
I can do that for you! |
|
Is there a built version of the Project? |
Yes, pull requests (or Godot builds with the pull requests applied) can be tested by following the steps in this link: https://docs.godotengine.org/en/4.4/contributing/workflow/testing_pull_requests.html |
Is there a non-mono Linux editor? |
|
I can confirm, the triggers do work! |
|
Rumble triggers don't though (Edit: I'm stupid, this is an Xbox feature lol, haven't tested on Xbox) |
|
One issue with the build: the Camera3Ds don't work from my testing |
That's good to hear! Thank you for testing! :) |
That's strange, I haven't touched anything 3D related in this PR. |
it could be a bug transitioning my project from godot 4.4 to 4.5, ill do some more testing (edit: its a me issue lol, ill figure it out) |
|
Testing on macOS with a DualSense controller plugged in via USB, the trigger haptics work for me! 🥳 The parameters the test project currently uses make it a bit hard to feel, but when I turn the strength up more I can definitely feel the difference in how the triggers respond. It shouldn't block the completion/merging of this PR, but I think it could be good to include a bit more detail in the documentation about how the haptic trigger functions work, perhaps with a code example or two. (I'd love for the docs to have something like this for haptics in general, actually, but again this is getting out of scope for this PR 😅 ) |
|
ive tested xbox controllers. the rumble trigger button doesnt work. ive used a program to test my rumble triggers and they are functional. ive tested over usb and wireless adapter. controller: xbox one controller (original, no bluetooth) program used: https://github.com/araghon007/X1nput |
|
Now that I think about it, I think I can separate this big PR into several smaller PRs so it can be reviewed and merged more easily. |
if i recall from testing on a separate project a couple of months ago: you'd need to enable one of the hints
the RawInput method is your best bet, but it's currently broken due to a Windows Update regression (libsdl-org/SDL#13047 (comment)). Which means: the best possible route to take is to enable GameInput (but requires either slapping in a not exactly ideal for the Trigger Rumbles situation |
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:
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
Input.get_joy_model()(because JoyType enum already exists) andInput.get_joy_scheme()(see SDL_GetGamepadType)SDL_GetJoystickVendor, SDL_GetJoystickProduct forMoved to FixInput.get_joy_info()(see Get joypad's vendor ID, product ID and name on Windows for XInput devices. #98861 )Input.get_joy_info()regression after the SDL input driver PR #108214Input.start_joy_motion_calibration(),Input.step_joy_motion_calibration(),Input.stop_joy_motion_calibration(),Input.clear_joy_motion_calibration())SDL_SetJoystickPlayerIndex to set the physical joypad's player indication (LED light count for Switch and Wii controllers, LED color for PlayStation, no action for other controllers)Didn't work for my joycon controllers and my Dualshock 4, even though the method returned trueInput.get/set_joy_motion_calibration()to save/load calibration settings, uses Dictionary to do thatInput.get_joy_model_axis/button_name()Input.get_joy_gravity()(see https://developer.android.com/reference/android/hardware/SensorEvent#values )Input.get_joy_touchpad_pressure()SDL_ENABLEDbeing not definedget_joy_scheme()override feature, and reflect that inget_joy_model_axis/button_name()(note for myself: I have an 8BitDo Wireless Adapter that can work in PlayStation Classic Controller mode, so at least an override for this one should exist so it actually reports as having PlayStation scheme)DualSense advanced haptic feedback? https://controllers.fandom.com/wiki/Sony_DualSense Output report Add support for DualSense adaptive triggers and haptic feedback godot-proposals#12087DualSense advanced haptic feedback is audio-based, I assume DualSense is exposing this features as an audio device on Windows (Sources: https://www.pcgamingwiki.com/wiki/Controller:DualSense#:~:text=audio%2Dbased%20haptic%20feedback%20are%20natively%20supported%20(see%20support%20in%20games)%2C%20though%20the%20latter%20is%20only%20supported%20with%20a%20wired%20connection and https://www.reddit.com/r/PS5/comments/jnp8tu/heres_how_to_get_audio_haptic_feedback_with/ ), so I assume it's already possible to use in Godot (see https://docs.godotengine.org/en/stable/classes/class_audioserver.html#class-audioserver-property-output-device ), but to make it work better multiple output devices are required, so this feature essentially depends on Add ability to output sound from different buses to different physical devices godot-proposals#11288Input.send_joy_packet()SDL_SendJoystickEffectDocumentation:
SDL_JoystickType): https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-controller-subtypes(BTW Horizontal joycons' yaw and roll axes are swapped, needs to be reported to SDL github)Just checked again, they're notInput.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 areTODO when Godot gets SDL input support for other platforms
TODO for separate PRs
Input.get_pov_hat_vector()(see AddInputEventJoypadHatgodot-proposals#9850 )InputEventJoypadHatgodot-proposals#9850 ) and ball eventsBattery/power eventsThat's not something the player can control, so no need to add these eventsInputEventJoypadAccelerometer,InputEventJoypadGyroscope)Features that need to be discussed whether they should be implemented or not
SDL_GetGamepadSteamHandle (for https://godotsteam.com/classes/input/ ?)Handled by FixInput.get_joy_info()regression after the SDL input driver PR #108214TODO 2:
Input.get_joy_accelerometer()should probably return the raw accelerometer values, while there should be another methodInput.get_joy_accelerometer_motion()that's equivalent to the current functionality, I think?PLAYSTATION_GENERICjoypad model or Steam Deck model)TODO, splitting:
Input.send_joy_packet(). ( Add support for DualSense Adaptive Triggers and custom joypad data packets #111682 )Here's a small project to test new joypad features:
JoypadTest.zip