Skip to content

Fix the usage of udev and dbus with SDL joystick input driver#108373

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Nintorch:fix-sowrap-enabled
Aug 3, 2025
Merged

Fix the usage of udev and dbus with SDL joystick input driver#108373
Repiteo merged 1 commit intogodotengine:masterfrom
Nintorch:fix-sowrap-enabled

Conversation

@Nintorch
Copy link
Contributor

@Nintorch Nintorch commented Jul 7, 2025

In the SDL joystick input PR I decided to not compile it with libudev because it was a bit too late to make new changes.
Yesterday I found out that SDL actually uses dynamic loading of libudev and uses the <libudev.h> only for structs, typedefs, etc. in the thirdparty/sdl/core/linux/SDL_udev.c file, so I decided to fix the compilation of libudev to use the header file that was already bundled with Godot's source code (thirdparty/linuxbsd_headers/udev/libudev.h) and in another file (thirdparty/sdl/hidapi/linux/hid.c) where SDL actually does use functions from said header, I redirect the calls to the struct where they're loaded dynamically (the one in SDL_udev.c). And I removed the usage of SOWRAP_ENABLED in the detect.py file where UDEV_ENABLED is defined, because SDL loads the library dynamically anyway and we probably can't/shouldn't change the way it works.
I tested the PR with WSL and it didn't seem to crash or break the controller support (my Dualshock 4 and a cheap Sega Mega Drive-like controller work fine just like before), so I assume it works 😅 (EDIT: need testing again)

EDIT: also made dbus load "statically" too (i.e. pull its functions from Godot binaries just like udev without SDL_UDEV_DYNAMIC)

TODO:

  • SDL can load the library "statically" if null is passed to dlsym() (i.e. search for the symbols inside of Godot binaries instead of a separate library file, I think?), so we can check for SOWRAP_ENABLED here
  • Do the same for dbus

@Nintorch Nintorch requested a review from a team as a code owner July 7, 2025 09:05
@Nintorch Nintorch force-pushed the fix-sowrap-enabled branch from 6312500 to 64b1a96 Compare July 7, 2025 09:12
@AThousandShips AThousandShips added this to the 4.5 milestone Jul 7, 2025
@Nintorch Nintorch force-pushed the fix-sowrap-enabled branch 3 times, most recently from d73623e to eae10d9 Compare July 30, 2025 15:00
@Nintorch Nintorch requested a review from a team as a code owner July 30, 2025 15:00
@Nintorch Nintorch force-pushed the fix-sowrap-enabled branch 4 times, most recently from 2bc8a19 to 28975ab Compare July 31, 2025 09:59
@Nintorch Nintorch changed the title Fix the usage of libudev with SDL joystick input driver Fix the usage of udev and dbus with SDL joystick input driver Jul 31, 2025
Previously, libudev was ignored if SOWRAP_ENABLED was defined (it is defined by default) because otherwise it would crash CI builds due to a missing header, and dbus was always linked dynamically. This commit should fix this issue and make libudev usable again
@Nintorch Nintorch force-pushed the fix-sowrap-enabled branch from 28975ab to 0e19ad5 Compare July 31, 2025 10:05
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally on Linux, it works as expected (including hotplugging). Code looks good to me.

Tested controllers:

  • DualSense
  • DualSense Edge
  • Switch Pro Controller
  • Xbox Elite Series 2 controller
  • Nyxi Warrior

@Nintorch
Copy link
Contributor Author

Nintorch commented Aug 2, 2025

Thank you for your reviews, Calinou and bruvzg!

@Repiteo Repiteo merged commit ca515cf into godotengine:master Aug 3, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Aug 3, 2025

Thanks!

@Nintorch
Copy link
Contributor Author

Nintorch commented Aug 3, 2025

Thank you so much! :D

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.

5 participants