Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/sdl/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ if env["builtin_sdl"]:
"thread/pthread/SDL_systls.c",
"timer/unix/SDL_systimer.c",
]
env_sdl.Prepend(CPPPATH=[thirdparty_dir + "core/linux"])

elif env["platform"] == "macos":
env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_MACOS"])
Expand Down
12 changes: 7 additions & 5 deletions drivers/sdl/SDL_build_config_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@
#define HAVE_UNSETENV 1
#endif

// TODO: handle dynamic loading with SOWRAP_ENABLED

// (even though DBus can also be loaded with SOWRAP_ENABLED, we load it
// statically regardless of SOWRAP_ENABLED, because otherwise SDL won't compile)
#ifdef DBUS_ENABLED
#define HAVE_DBUS_DBUS_H 1
#define SDL_USE_LIBDBUS 1
// SOWRAP_ENABLED is handled in thirdparty/sdl/core/linux/SDL_dbus.c
#endif

#if defined(UDEV_ENABLED) && !defined(SOWRAP_ENABLED)
#ifdef UDEV_ENABLED
#define HAVE_LIBUDEV_H 1
#define SDL_USE_LIBUDEV
#ifdef SOWRAP_ENABLED
#define SDL_UDEV_DYNAMIC "libudev.so.1"
#endif
#endif

#define SDL_LOADSO_DLOPEN 1
Expand Down
4 changes: 0 additions & 4 deletions platform/linuxbsd/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ if env["fontconfig"]:
if env["use_sowrap"]:
common_linuxbsd.append("fontconfig-so_wrap.c")

if env["udev"]:
if env["use_sowrap"]:
common_linuxbsd.append("libudev-so_wrap.c")

if env["dbus"]:
if env["use_sowrap"]:
common_linuxbsd.append("dbus-so_wrap.c")
Expand Down
1 change: 0 additions & 1 deletion platform/linuxbsd/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def configure(env: "SConsEnvironment"):
env.Append(CPPDEFINES=["XKB_ENABLED"])

if platform.system() == "Linux":
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
if env["udev"]:
if not env["use_sowrap"]:
if os.system("pkg-config --exists libudev") == 0: # 0 means found
Expand Down
1,013 changes: 0 additions & 1,013 deletions platform/linuxbsd/libudev-so_wrap.c

This file was deleted.

378 changes: 0 additions & 378 deletions platform/linuxbsd/libudev-so_wrap.h

This file was deleted.

1 change: 1 addition & 0 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ Patches:
- `0002-msvc-constants-fpstrict.patch` (GH-106218)
- `0003-std-include.patch` (GH-108144)
- `0004-errno-include.patch` (GH-108354)
- `0005-fix-libudev-dbus.patch` (GH-108373)

The SDL source code folder includes `hidapi` library inside of folder `thirdparty/sdl/hidapi/`.
Its version and license is described in this file under `hidapi`.
Expand Down
6 changes: 6 additions & 0 deletions thirdparty/sdl/core/linux/SDL_dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,18 @@ static bool LoadDBUSSyms(void)

static void UnloadDBUSLibrary(void)
{
#ifdef SOWRAP_ENABLED // Godot build system constant
if (dbus_handle) {
SDL_UnloadObject(dbus_handle);
dbus_handle = NULL;
}
#endif
}

static bool LoadDBUSLibrary(void)
{
bool result = true;
#ifdef SOWRAP_ENABLED // Godot build system constant
if (!dbus_handle) {
dbus_handle = SDL_LoadObject(dbus_library);
if (!dbus_handle) {
Expand All @@ -118,6 +121,9 @@ static bool LoadDBUSLibrary(void)
}
}
}
#else
result = LoadDBUSSyms();
#endif
return result;
}

Expand Down
3 changes: 2 additions & 1 deletion thirdparty/sdl/core/linux/SDL_udev.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };

static SDL_UDEV_PrivateData *_this = NULL;
SDL_UDEV_PrivateData *SDL_UDEV_PrivateData_this = NULL;
#define _this SDL_UDEV_PrivateData_this

static bool SDL_UDEV_load_sym(const char *fn, void **addr);
static bool SDL_UDEV_load_syms(void);
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/sdl/core/linux/SDL_udev.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#define SDL_USE_LIBUDEV 1
#endif

#include <libudev.h>
//#include <libudev.h>
#include "thirdparty/linuxbsd_headers/udev/libudev.h"
#include <sys/time.h>
#include <sys/types.h>

Expand Down
32 changes: 31 additions & 1 deletion thirdparty/sdl/hidapi/linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,37 @@
#include <linux/hidraw.h>
#include <linux/version.h>
#include <linux/input.h>
#include <libudev.h>
//#include <libudev.h>
#include "SDL_udev.h"
extern SDL_UDEV_PrivateData *SDL_UDEV_PrivateData_this;
#define udev_device_get_action (SDL_UDEV_PrivateData_this->syms.udev_device_get_action)
#define udev_device_get_devnode (SDL_UDEV_PrivateData_this->syms.udev_device_get_devnode)
#define udev_device_get_syspath (SDL_UDEV_PrivateData_this->syms.udev_device_get_syspath)
#define udev_device_get_subsystem (SDL_UDEV_PrivateData_this->syms.udev_device_get_subsystem)
#define udev_device_get_parent_with_subsystem_devtype (SDL_UDEV_PrivateData_this->syms.udev_device_get_parent_with_subsystem_devtype)
#define udev_device_get_property_value (SDL_UDEV_PrivateData_this->syms.udev_device_get_property_value)
#define udev_device_get_sysattr_value (SDL_UDEV_PrivateData_this->syms.udev_device_get_sysattr_value)
#define udev_device_new_from_syspath (SDL_UDEV_PrivateData_this->syms.udev_device_new_from_syspath)
#define udev_device_unref (SDL_UDEV_PrivateData_this->syms.udev_device_unref)
#define udev_enumerate_add_match_property (SDL_UDEV_PrivateData_this->syms.udev_enumerate_add_match_property)
#define udev_enumerate_add_match_subsystem (SDL_UDEV_PrivateData_this->syms.udev_enumerate_add_match_subsystem)
#define udev_enumerate_get_list_entry (SDL_UDEV_PrivateData_this->syms.udev_enumerate_get_list_entry)
#define udev_enumerate_new (SDL_UDEV_PrivateData_this->syms.udev_enumerate_new)
#define udev_enumerate_scan_devices (SDL_UDEV_PrivateData_this->syms.udev_enumerate_scan_devices)
#define udev_enumerate_unref (SDL_UDEV_PrivateData_this->syms.udev_enumerate_unref)
#define udev_list_entry_get_name (SDL_UDEV_PrivateData_this->syms.udev_list_entry_get_name)
#define udev_list_entry_get_next (SDL_UDEV_PrivateData_this->syms.udev_list_entry_get_next)
#define udev_monitor_enable_receiving (SDL_UDEV_PrivateData_this->syms.udev_monitor_enable_receiving)
#define udev_monitor_filter_add_match_subsystem_devtype (SDL_UDEV_PrivateData_this->syms.udev_monitor_filter_add_match_subsystem_devtype)
#define udev_monitor_get_fd (SDL_UDEV_PrivateData_this->syms.udev_monitor_get_fd)
#define udev_monitor_new_from_netlink (SDL_UDEV_PrivateData_this->syms.udev_monitor_new_from_netlink)
#define udev_monitor_receive_device (SDL_UDEV_PrivateData_this->syms.udev_monitor_receive_device)
#define udev_monitor_unref (SDL_UDEV_PrivateData_this->syms.udev_monitor_unref)
#define udev_new (SDL_UDEV_PrivateData_this->syms.udev_new)
#define udev_unref (SDL_UDEV_PrivateData_this->syms.udev_unref)
#define udev_device_new_from_devnum (SDL_UDEV_PrivateData_this->syms.udev_device_new_from_devnum)
#define udev_device_get_devnum (SDL_UDEV_PrivateData_this->syms.udev_device_get_devnum)
#undef SDL_UDEV_SYM

#include "../hidapi/hidapi.h"

Expand Down
4 changes: 2 additions & 2 deletions thirdparty/sdl/loadso/dlopen/SDL_sysloadso.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject *handle, const char *name)
symbol = dlsym(handle, _name);
SDL_small_free(_name, isstack);
if (!symbol) {
SDL_SetError("Failed loading %s: %s", name,
(const char *)dlerror());
//SDL_SetError("Failed loading %s: %s", name,
// (const char *)dlerror());
}
}
return symbol;
Expand Down
119 changes: 119 additions & 0 deletions thirdparty/sdl/patches/0005-fix-libudev-dbus.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
diff --git a/thirdparty/sdl/core/linux/SDL_dbus.c b/thirdparty/sdl/core/linux/SDL_dbus.c
index 9a2fc1ea531..9dc5c266732 100644
--- a/thirdparty/sdl/core/linux/SDL_dbus.c
+++ b/thirdparty/sdl/core/linux/SDL_dbus.c
@@ -97,15 +97,18 @@ static bool LoadDBUSSyms(void)

static void UnloadDBUSLibrary(void)
{
+#ifdef SOWRAP_ENABLED // Godot build system constant
if (dbus_handle) {
SDL_UnloadObject(dbus_handle);
dbus_handle = NULL;
}
+#endif
}

static bool LoadDBUSLibrary(void)
{
bool result = true;
+#ifdef SOWRAP_ENABLED // Godot build system constant
if (!dbus_handle) {
dbus_handle = SDL_LoadObject(dbus_library);
if (!dbus_handle) {
@@ -118,6 +121,9 @@ static bool LoadDBUSLibrary(void)
}
}
}
+#else
+ result = LoadDBUSSyms();
+#endif
return result;
}

diff --git a/thirdparty/sdl/core/linux/SDL_udev.c b/thirdparty/sdl/core/linux/SDL_udev.c
index 907c34c7f66..fbf2ff04440 100644
--- a/thirdparty/sdl/core/linux/SDL_udev.c
+++ b/thirdparty/sdl/core/linux/SDL_udev.c
@@ -38,7 +38,8 @@

static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" };

-static SDL_UDEV_PrivateData *_this = NULL;
+SDL_UDEV_PrivateData *SDL_UDEV_PrivateData_this = NULL;
+#define _this SDL_UDEV_PrivateData_this

static bool SDL_UDEV_load_sym(const char *fn, void **addr);
static bool SDL_UDEV_load_syms(void);
diff --git a/thirdparty/sdl/core/linux/SDL_udev.h b/thirdparty/sdl/core/linux/SDL_udev.h
index 738f4bafe3f..50bed36248e 100644
--- a/thirdparty/sdl/core/linux/SDL_udev.h
+++ b/thirdparty/sdl/core/linux/SDL_udev.h
@@ -30,7 +30,8 @@
#define SDL_USE_LIBUDEV 1
#endif

-#include <libudev.h>
+//#include <libudev.h>
+#include "thirdparty/linuxbsd_headers/udev/libudev.h"
#include <sys/time.h>
#include <sys/types.h>

diff --git a/thirdparty/sdl/hidapi/linux/hid.c b/thirdparty/sdl/hidapi/linux/hid.c
index dbbb3277854..51a32ef892f 100644
--- a/thirdparty/sdl/hidapi/linux/hid.c
+++ b/thirdparty/sdl/hidapi/linux/hid.c
@@ -40,7 +40,37 @@
#include <linux/hidraw.h>
#include <linux/version.h>
#include <linux/input.h>
-#include <libudev.h>
+//#include <libudev.h>
+#include "SDL_udev.h"
+extern SDL_UDEV_PrivateData *SDL_UDEV_PrivateData_this;
+#define udev_device_get_action (SDL_UDEV_PrivateData_this->syms.udev_device_get_action)
+#define udev_device_get_devnode (SDL_UDEV_PrivateData_this->syms.udev_device_get_devnode)
+#define udev_device_get_syspath (SDL_UDEV_PrivateData_this->syms.udev_device_get_syspath)
+#define udev_device_get_subsystem (SDL_UDEV_PrivateData_this->syms.udev_device_get_subsystem)
+#define udev_device_get_parent_with_subsystem_devtype (SDL_UDEV_PrivateData_this->syms.udev_device_get_parent_with_subsystem_devtype)
+#define udev_device_get_property_value (SDL_UDEV_PrivateData_this->syms.udev_device_get_property_value)
+#define udev_device_get_sysattr_value (SDL_UDEV_PrivateData_this->syms.udev_device_get_sysattr_value)
+#define udev_device_new_from_syspath (SDL_UDEV_PrivateData_this->syms.udev_device_new_from_syspath)
+#define udev_device_unref (SDL_UDEV_PrivateData_this->syms.udev_device_unref)
+#define udev_enumerate_add_match_property (SDL_UDEV_PrivateData_this->syms.udev_enumerate_add_match_property)
+#define udev_enumerate_add_match_subsystem (SDL_UDEV_PrivateData_this->syms.udev_enumerate_add_match_subsystem)
+#define udev_enumerate_get_list_entry (SDL_UDEV_PrivateData_this->syms.udev_enumerate_get_list_entry)
+#define udev_enumerate_new (SDL_UDEV_PrivateData_this->syms.udev_enumerate_new)
+#define udev_enumerate_scan_devices (SDL_UDEV_PrivateData_this->syms.udev_enumerate_scan_devices)
+#define udev_enumerate_unref (SDL_UDEV_PrivateData_this->syms.udev_enumerate_unref)
+#define udev_list_entry_get_name (SDL_UDEV_PrivateData_this->syms.udev_list_entry_get_name)
+#define udev_list_entry_get_next (SDL_UDEV_PrivateData_this->syms.udev_list_entry_get_next)
+#define udev_monitor_enable_receiving (SDL_UDEV_PrivateData_this->syms.udev_monitor_enable_receiving)
+#define udev_monitor_filter_add_match_subsystem_devtype (SDL_UDEV_PrivateData_this->syms.udev_monitor_filter_add_match_subsystem_devtype)
+#define udev_monitor_get_fd (SDL_UDEV_PrivateData_this->syms.udev_monitor_get_fd)
+#define udev_monitor_new_from_netlink (SDL_UDEV_PrivateData_this->syms.udev_monitor_new_from_netlink)
+#define udev_monitor_receive_device (SDL_UDEV_PrivateData_this->syms.udev_monitor_receive_device)
+#define udev_monitor_unref (SDL_UDEV_PrivateData_this->syms.udev_monitor_unref)
+#define udev_new (SDL_UDEV_PrivateData_this->syms.udev_new)
+#define udev_unref (SDL_UDEV_PrivateData_this->syms.udev_unref)
+#define udev_device_new_from_devnum (SDL_UDEV_PrivateData_this->syms.udev_device_new_from_devnum)
+#define udev_device_get_devnum (SDL_UDEV_PrivateData_this->syms.udev_device_get_devnum)
+#undef SDL_UDEV_SYM

#include "../hidapi/hidapi.h"

diff --git a/thirdparty/sdl/loadso/dlopen/SDL_sysloadso.c b/thirdparty/sdl/loadso/dlopen/SDL_sysloadso.c
index c84d1a1b5f9..e09c09080cd 100644
--- a/thirdparty/sdl/loadso/dlopen/SDL_sysloadso.c
+++ b/thirdparty/sdl/loadso/dlopen/SDL_sysloadso.c
@@ -65,8 +65,8 @@ SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject *handle, const char *name)
symbol = dlsym(handle, _name);
SDL_small_free(_name, isstack);
if (!symbol) {
- SDL_SetError("Failed loading %s: %s", name,
- (const char *)dlerror());
+ //SDL_SetError("Failed loading %s: %s", name,
+ // (const char *)dlerror());
}
}
return symbol;
Loading