Skip to content

Commit ca515cf

Browse files
committed
Merge pull request #108373 from Nintorch/fix-sowrap-enabled
Fix the usage of udev and dbus with SDL joystick input driver
2 parents 62dc131 + 0e19ad5 commit ca515cf

File tree

13 files changed

+171
-1406
lines changed

13 files changed

+171
-1406
lines changed

drivers/sdl/SCsub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ if env["builtin_sdl"]:
145145
"thread/pthread/SDL_systls.c",
146146
"timer/unix/SDL_systimer.c",
147147
]
148+
env_sdl.Prepend(CPPPATH=[thirdparty_dir + "core/linux"])
148149

149150
elif env["platform"] == "macos":
150151
env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_MACOS"])

drivers/sdl/SDL_build_config_private.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,18 @@
9292
#define HAVE_UNSETENV 1
9393
#endif
9494

95-
// TODO: handle dynamic loading with SOWRAP_ENABLED
96-
97-
// (even though DBus can also be loaded with SOWRAP_ENABLED, we load it
98-
// statically regardless of SOWRAP_ENABLED, because otherwise SDL won't compile)
9995
#ifdef DBUS_ENABLED
10096
#define HAVE_DBUS_DBUS_H 1
97+
#define SDL_USE_LIBDBUS 1
98+
// SOWRAP_ENABLED is handled in thirdparty/sdl/core/linux/SDL_dbus.c
10199
#endif
102100

103-
#if defined(UDEV_ENABLED) && !defined(SOWRAP_ENABLED)
101+
#ifdef UDEV_ENABLED
104102
#define HAVE_LIBUDEV_H 1
103+
#define SDL_USE_LIBUDEV
104+
#ifdef SOWRAP_ENABLED
105+
#define SDL_UDEV_DYNAMIC "libudev.so.1"
106+
#endif
105107
#endif
106108

107109
#define SDL_LOADSO_DLOPEN 1

platform/linuxbsd/SCsub

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ if env["fontconfig"]:
3131
if env["use_sowrap"]:
3232
common_linuxbsd.append("fontconfig-so_wrap.c")
3333

34-
if env["udev"]:
35-
if env["use_sowrap"]:
36-
common_linuxbsd.append("libudev-so_wrap.c")
37-
3834
if env["dbus"]:
3935
if env["use_sowrap"]:
4036
common_linuxbsd.append("dbus-so_wrap.c")

platform/linuxbsd/detect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ def configure(env: "SConsEnvironment"):
380380
env.Append(CPPDEFINES=["XKB_ENABLED"])
381381

382382
if platform.system() == "Linux":
383-
env.Append(CPPDEFINES=["JOYDEV_ENABLED"])
384383
if env["udev"]:
385384
if not env["use_sowrap"]:
386385
if os.system("pkg-config --exists libudev") == 0: # 0 means found

platform/linuxbsd/libudev-so_wrap.c

Lines changed: 0 additions & 1013 deletions
This file was deleted.

platform/linuxbsd/libudev-so_wrap.h

Lines changed: 0 additions & 378 deletions
This file was deleted.

thirdparty/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ Patches:
971971
- `0002-msvc-constants-fpstrict.patch` (GH-106218)
972972
- `0003-std-include.patch` (GH-108144)
973973
- `0004-errno-include.patch` (GH-108354)
974+
- `0005-fix-libudev-dbus.patch` (GH-108373)
974975

975976
The SDL source code folder includes `hidapi` library inside of folder `thirdparty/sdl/hidapi/`.
976977
Its version and license is described in this file under `hidapi`.

thirdparty/sdl/core/linux/SDL_dbus.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,18 @@ static bool LoadDBUSSyms(void)
9797

9898
static void UnloadDBUSLibrary(void)
9999
{
100+
#ifdef SOWRAP_ENABLED // Godot build system constant
100101
if (dbus_handle) {
101102
SDL_UnloadObject(dbus_handle);
102103
dbus_handle = NULL;
103104
}
105+
#endif
104106
}
105107

106108
static bool LoadDBUSLibrary(void)
107109
{
108110
bool result = true;
111+
#ifdef SOWRAP_ENABLED // Godot build system constant
109112
if (!dbus_handle) {
110113
dbus_handle = SDL_LoadObject(dbus_library);
111114
if (!dbus_handle) {
@@ -118,6 +121,9 @@ static bool LoadDBUSLibrary(void)
118121
}
119122
}
120123
}
124+
#else
125+
result = LoadDBUSSyms();
126+
#endif
121127
return result;
122128
}
123129

thirdparty/sdl/core/linux/SDL_udev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838

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

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

4344
static bool SDL_UDEV_load_sym(const char *fn, void **addr);
4445
static bool SDL_UDEV_load_syms(void);

thirdparty/sdl/core/linux/SDL_udev.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#define SDL_USE_LIBUDEV 1
3131
#endif
3232

33-
#include <libudev.h>
33+
//#include <libudev.h>
34+
#include "thirdparty/linuxbsd_headers/udev/libudev.h"
3435
#include <sys/time.h>
3536
#include <sys/types.h>
3637

0 commit comments

Comments
 (0)