summaryrefslogtreecommitdiff
path: root/Source/3rdParty/SDL2/src/core/linux
diff options
context:
space:
mode:
Diffstat (limited to 'Source/3rdParty/SDL2/src/core/linux')
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_dbus.c18
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_dbus.h9
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_evdev.c1
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.c171
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.h5
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_udev.c80
-rw-r--r--Source/3rdParty/SDL2/src/core/linux/SDL_udev.h32
7 files changed, 258 insertions, 58 deletions
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.c b/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.c
index ff4f0fe..e0d9972 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.c
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.c
@@ -173,17 +173,29 @@ SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *
if (conn) {
DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method);
if (msg) {
- int firstarg = va_arg(ap, int);
+ int firstarg;
+ va_list ap_reply;
+ va_copy(ap_reply, ap); /* copy the arg list so we don't compete with D-Bus for it */
+ firstarg = va_arg(ap, int);
if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {
DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL);
if (reply) {
- firstarg = va_arg(ap, int);
- if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap)) {
+ /* skip any input args, get to output args. */
+ while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) {
+ /* we assume D-Bus already validated all this. */
+ { void *dumpptr = va_arg(ap_reply, void*); (void) dumpptr; }
+ if (firstarg == DBUS_TYPE_ARRAY) {
+ { const int dumpint = va_arg(ap_reply, int); (void) dumpint; }
+ }
+ }
+ firstarg = va_arg(ap_reply, int);
+ if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) {
retval = SDL_TRUE;
}
dbus.message_unref(reply);
}
}
+ va_end(ap_reply);
dbus.message_unref(msg);
}
}
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.h b/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.h
index 062543d..aa787f2 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.h
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_dbus.h
@@ -39,9 +39,8 @@ typedef struct SDL_DBusContext {
void (*bus_add_match)(DBusConnection *, const char *, DBusError *);
DBusConnection * (*connection_open_private)(const char *, DBusError *);
void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t);
- dbus_bool_t (*connection_get_is_connected)(DBusConnection *);
- dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction,
- void *, DBusFreeFunction);
+ dbus_bool_t (*connection_get_is_connected)(DBusConnection *);
+ dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction);
dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *,
const DBusObjectPathVTable *, void *, DBusError *);
dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *);
@@ -51,7 +50,7 @@ typedef struct SDL_DBusContext {
void (*connection_flush)(DBusConnection *);
dbus_bool_t (*connection_read_write)(DBusConnection *, int);
DBusDispatchStatus (*connection_dispatch)(DBusConnection *);
- dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *);
+ dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *);
DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *);
dbus_bool_t (*message_append_args)(DBusMessage *, int, ...);
dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list);
@@ -61,7 +60,7 @@ typedef struct SDL_DBusContext {
dbus_bool_t (*message_iter_next)(DBusMessageIter *);
void (*message_iter_get_basic)(DBusMessageIter *, void *);
int (*message_iter_get_arg_type)(DBusMessageIter *);
- void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *);
+ void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *);
void (*message_unref)(DBusMessage *);
void (*error_init)(DBusError *);
dbus_bool_t (*error_is_set)(const DBusError *);
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev.c b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev.c
index a506926..5443c21 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev.c
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev.c
@@ -101,6 +101,7 @@ typedef struct SDL_EVDEV_PrivateData
SDL_EVDEV_keyboard_state *kbd;
} SDL_EVDEV_PrivateData;
+#undef _THIS
#define _THIS SDL_EVDEV_PrivateData *_this
static _THIS = NULL;
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.c b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.c
index 250e644..00a3a54 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.c
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.c
@@ -21,6 +21,7 @@
#include "../../SDL_internal.h"
#include "SDL_evdev_kbd.h"
+#include "SDL_hints.h"
#ifdef SDL_INPUT_LINUXKD
@@ -34,6 +35,8 @@
#include <linux/vt.h>
#include <linux/tiocl.h> /* for TIOCL_GETSHIFTSTATE */
+#include <signal.h>
+
#include "../../events/SDL_events_c.h"
#include "SDL_evdev_kbd_default_accents.h"
#include "SDL_evdev_kbd_default_keymap.h"
@@ -191,6 +194,151 @@ static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd)
return 0;
}
+static SDL_EVDEV_keyboard_state * kbd_cleanup_state = NULL;
+static int kbd_cleanup_sigactions_installed = 0;
+static int kbd_cleanup_atexit_installed = 0;
+
+static struct sigaction old_sigaction[NSIG];
+
+static int fatal_signals[] =
+{
+ /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */
+ SIGHUP, SIGQUIT, SIGILL, SIGABRT,
+ SIGFPE, SIGSEGV, SIGPIPE, SIGBUS,
+ SIGSYS
+};
+
+static void kbd_cleanup(void)
+{
+ SDL_EVDEV_keyboard_state* kbd = kbd_cleanup_state;
+ if (kbd == NULL) {
+ return;
+ }
+ kbd_cleanup_state = NULL;
+
+ fprintf(stderr, "(SDL restoring keyboard) ");
+ ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode);
+}
+
+void
+SDL_EVDEV_kbd_reraise_signal(int sig)
+{
+ raise(sig);
+}
+
+siginfo_t* SDL_EVDEV_kdb_cleanup_siginfo = NULL;
+void* SDL_EVDEV_kdb_cleanup_ucontext = NULL;
+
+static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontext)
+{
+ struct sigaction* old_action_p = &(old_sigaction[signum]);
+ sigset_t sigset;
+
+ /* Restore original signal handler before going any further. */
+ sigaction(signum, old_action_p, NULL);
+
+ /* Unmask current signal. */
+ sigemptyset(&sigset);
+ sigaddset(&sigset, signum);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+
+ /* Save original signal info and context for archeologists. */
+ SDL_EVDEV_kdb_cleanup_siginfo = info;
+ SDL_EVDEV_kdb_cleanup_ucontext = ucontext;
+
+ /* Restore keyboard. */
+ kbd_cleanup();
+
+ /* Reraise signal. */
+ SDL_EVDEV_kbd_reraise_signal(signum);
+}
+
+static void kbd_unregister_emerg_cleanup()
+{
+ int tabidx, signum;
+
+ kbd_cleanup_state = NULL;
+
+ if (!kbd_cleanup_sigactions_installed) {
+ return;
+ }
+ kbd_cleanup_sigactions_installed = 0;
+
+ for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
+ struct sigaction* old_action_p;
+ struct sigaction cur_action;
+ signum = fatal_signals[tabidx];
+ old_action_p = &(old_sigaction[signum]);
+
+ /* Examine current signal action */
+ if (sigaction(signum, NULL, &cur_action))
+ continue;
+
+ /* Check if action installed and not modifed */
+ if (!(cur_action.sa_flags & SA_SIGINFO)
+ || cur_action.sa_sigaction != &kbd_cleanup_signal_action)
+ continue;
+
+ /* Restore original action */
+ sigaction(signum, old_action_p, NULL);
+ }
+}
+
+static void kbd_cleanup_atexit(void)
+{
+ /* Restore keyboard. */
+ kbd_cleanup();
+
+ /* Try to restore signal handlers in case shared library is being unloaded */
+ kbd_unregister_emerg_cleanup();
+}
+
+static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd)
+{
+ int tabidx, signum;
+
+ if (kbd_cleanup_state != NULL) {
+ return;
+ }
+ kbd_cleanup_state = kbd;
+
+ if (!kbd_cleanup_atexit_installed) {
+ /* Since glibc 2.2.3, atexit() (and on_exit(3)) can be used within a shared library to establish
+ * functions that are called when the shared library is unloaded.
+ * -- man atexit(3)
+ */
+ atexit(kbd_cleanup_atexit);
+ kbd_cleanup_atexit_installed = 1;
+ }
+
+ if (kbd_cleanup_sigactions_installed) {
+ return;
+ }
+ kbd_cleanup_sigactions_installed = 1;
+
+ for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) {
+ struct sigaction* old_action_p;
+ struct sigaction new_action;
+ signum = fatal_signals[tabidx];
+ old_action_p = &(old_sigaction[signum]);
+ if (sigaction(signum, NULL, old_action_p))
+ continue;
+
+ /* Skip SIGHUP and SIGPIPE if handler is already installed
+ * - assume the handler will do the cleanup
+ */
+ if ((signum == SIGHUP || signum == SIGPIPE)
+ && (old_action_p->sa_handler != SIG_DFL
+ || (void (*)(int))old_action_p->sa_sigaction != SIG_DFL))
+ continue;
+
+ new_action = *old_action_p;
+ new_action.sa_flags |= SA_SIGINFO;
+ new_action.sa_sigaction = &kbd_cleanup_signal_action;
+ sigaction(signum, &new_action, NULL);
+ }
+}
+
SDL_EVDEV_keyboard_state *
SDL_EVDEV_kbd_init(void)
{
@@ -238,10 +386,20 @@ SDL_EVDEV_kbd_init(void)
kbd->key_maps = default_key_maps;
}
- /* Mute the keyboard so keystrokes only generate evdev events
- * and do not leak through to the console
- */
- ioctl(kbd->console_fd, KDSKBMODE, K_OFF);
+ /* Allow inhibiting keyboard mute with env. variable for debugging etc. */
+ if (getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) {
+ /* Mute the keyboard so keystrokes only generate evdev events
+ * and do not leak through to the console
+ */
+ ioctl(kbd->console_fd, KDSKBMODE, K_OFF);
+
+ /* Make sure to restore keyboard if application fails to call
+ * SDL_Quit before exit or fatal signal is raised.
+ */
+ if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) {
+ kbd_register_emerg_cleanup(kbd);
+ }
+ }
}
#ifdef DUMP_ACCENTS
@@ -260,6 +418,8 @@ SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
return;
}
+ kbd_unregister_emerg_cleanup();
+
if (kbd->console_fd >= 0) {
/* Restore the original keyboard mode */
ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode);
@@ -609,7 +769,10 @@ SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int d
shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate;
key_map = kbd->key_maps[shift_final];
if (!key_map) {
+ /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
+ kbd->shift_state = 0;
kbd->slockstate = 0;
+ kbd->lockstate = 0;
return;
}
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.h b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.h
index 831ba3a..5e51cdd 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.h
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_evdev_kbd.h
@@ -19,6 +19,9 @@
3. This notice may not be removed or altered from any source distribution.
*/
+#ifndef SDL_evdev_kbd_h_
+#define SDL_evdev_kbd_h_
+
struct SDL_EVDEV_keyboard_state;
typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
@@ -26,4 +29,6 @@ extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
+#endif /* SDL_evdev_kbd_h_ */
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_udev.c b/Source/3rdParty/SDL2/src/core/linux/SDL_udev.c
index dfbeb79..751e2ca 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_udev.c
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_udev.c
@@ -63,7 +63,7 @@ SDL_UDEV_load_syms(void)
{
/* cast funcs to char* first, to please GCC's strict aliasing rules. */
#define SDL_UDEV_SYM(x) \
- if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->x)) return -1
+ if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->syms.x)) return -1
SDL_UDEV_SYM(udev_device_get_action);
SDL_UDEV_SYM(udev_device_get_devnode);
@@ -100,7 +100,7 @@ static SDL_bool
SDL_UDEV_hotplug_update_available(void)
{
if (_this->udev_mon != NULL) {
- const int fd = _this->udev_monitor_get_fd(_this->udev_mon);
+ const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
if (SDL_IOReady(fd, SDL_FALSE, 0)) {
return SDL_TRUE;
}
@@ -130,21 +130,21 @@ SDL_UDEV_Init(void)
* Listen for input devices (mouse, keyboard, joystick, etc) and sound devices
*/
- _this->udev = _this->udev_new();
+ _this->udev = _this->syms.udev_new();
if (_this->udev == NULL) {
SDL_UDEV_Quit();
return SDL_SetError("udev_new() failed");
}
- _this->udev_mon = _this->udev_monitor_new_from_netlink(_this->udev, "udev");
+ _this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev");
if (_this->udev_mon == NULL) {
SDL_UDEV_Quit();
return SDL_SetError("udev_monitor_new_from_netlink() failed");
}
- _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL);
- _this->udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
- _this->udev_monitor_enable_receiving(_this->udev_mon);
+ _this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL);
+ _this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
+ _this->syms.udev_monitor_enable_receiving(_this->udev_mon);
/* Do an initial scan of existing devices */
SDL_UDEV_Scan();
@@ -170,11 +170,11 @@ SDL_UDEV_Quit(void)
if (_this->ref_count < 1) {
if (_this->udev_mon != NULL) {
- _this->udev_monitor_unref(_this->udev_mon);
+ _this->syms.udev_monitor_unref(_this->udev_mon);
_this->udev_mon = NULL;
}
if (_this->udev != NULL) {
- _this->udev_unref(_this->udev);
+ _this->syms.udev_unref(_this->udev);
_this->udev = NULL;
}
@@ -202,28 +202,28 @@ SDL_UDEV_Scan(void)
return;
}
- enumerate = _this->udev_enumerate_new(_this->udev);
+ enumerate = _this->syms.udev_enumerate_new(_this->udev);
if (enumerate == NULL) {
SDL_UDEV_Quit();
SDL_SetError("udev_enumerate_new() failed");
return;
}
- _this->udev_enumerate_add_match_subsystem(enumerate, "input");
- _this->udev_enumerate_add_match_subsystem(enumerate, "sound");
+ _this->syms.udev_enumerate_add_match_subsystem(enumerate, "input");
+ _this->syms.udev_enumerate_add_match_subsystem(enumerate, "sound");
- _this->udev_enumerate_scan_devices(enumerate);
- devs = _this->udev_enumerate_get_list_entry(enumerate);
- for (item = devs; item; item = _this->udev_list_entry_get_next(item)) {
- const char *path = _this->udev_list_entry_get_name(item);
- struct udev_device *dev = _this->udev_device_new_from_syspath(_this->udev, path);
+ _this->syms.udev_enumerate_scan_devices(enumerate);
+ devs = _this->syms.udev_enumerate_get_list_entry(enumerate);
+ for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) {
+ const char *path = _this->syms.udev_list_entry_get_name(item);
+ struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
if (dev != NULL) {
device_event(SDL_UDEV_DEVICEADDED, dev);
- _this->udev_device_unref(dev);
+ _this->syms.udev_device_unref(dev);
}
}
- _this->udev_enumerate_unref(enumerate);
+ _this->syms.udev_enumerate_unref(enumerate);
}
@@ -305,7 +305,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch
unsigned long v;
SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask));
- value = _this->udev_device_get_sysattr_value(pdev, attr);
+ value = _this->syms.udev_device_get_sysattr_value(pdev, attr);
if (!value) {
return;
}
@@ -340,8 +340,8 @@ guess_device_class(struct udev_device *dev)
/* walk up the parental chain until we find the real input device; the
* argument is very likely a subdevice of this, like eventN */
pdev = dev;
- while (pdev && !_this->udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
- pdev = _this->udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
+ while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
+ pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
}
if (!pdev) {
return 0;
@@ -405,28 +405,28 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
const char *path;
SDL_UDEV_CallbackList *item;
- path = _this->udev_device_get_devnode(dev);
+ path = _this->syms.udev_device_get_devnode(dev);
if (path == NULL) {
return;
}
- subsystem = _this->udev_device_get_subsystem(dev);
+ subsystem = _this->syms.udev_device_get_subsystem(dev);
if (SDL_strcmp(subsystem, "sound") == 0) {
devclass = SDL_UDEV_DEVICE_SOUND;
} else if (SDL_strcmp(subsystem, "input") == 0) {
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
- val = _this->udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
+ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
}
- val = _this->udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
+ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_MOUSE;
}
- val = _this->udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
+ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN;
}
@@ -437,14 +437,14 @@ device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
*/
- val = _this->udev_device_get_property_value(dev, "ID_INPUT_KEY");
+ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY");
if (val != NULL && SDL_strcmp(val, "1") == 0 ) {
devclass |= SDL_UDEV_DEVICE_KEYBOARD;
}
if (devclass == 0) {
/* Fall back to old style input classes */
- val = _this->udev_device_get_property_value(dev, "ID_CLASS");
+ val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS");
if (val != NULL) {
if (SDL_strcmp(val, "joystick") == 0) {
devclass = SDL_UDEV_DEVICE_JOYSTICK;
@@ -481,11 +481,11 @@ SDL_UDEV_Poll(void)
}
while (SDL_UDEV_hotplug_update_available()) {
- dev = _this->udev_monitor_receive_device(_this->udev_mon);
+ dev = _this->syms.udev_monitor_receive_device(_this->udev_mon);
if (dev == NULL) {
break;
}
- action = _this->udev_device_get_action(dev);
+ action = _this->syms.udev_device_get_action(dev);
if (SDL_strcmp(action, "add") == 0) {
/* Wait for the device to finish initialization */
@@ -496,7 +496,7 @@ SDL_UDEV_Poll(void)
device_event(SDL_UDEV_DEVICEREMOVED, dev);
}
- _this->udev_device_unref(dev);
+ _this->syms.udev_device_unref(dev);
}
}
@@ -547,6 +547,22 @@ SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
}
+const SDL_UDEV_Symbols *
+SDL_UDEV_GetUdevSyms(void)
+{
+ if (SDL_UDEV_Init() < 0) {
+ SDL_SetError("Could not initialize UDEV");
+ return NULL;
+ }
+
+ return &_this->syms;
+}
+
+void
+SDL_UDEV_ReleaseUdevSyms(void)
+{
+ SDL_UDEV_Quit();
+}
#endif /* SDL_USE_LIBUDEV */
diff --git a/Source/3rdParty/SDL2/src/core/linux/SDL_udev.h b/Source/3rdParty/SDL2/src/core/linux/SDL_udev.h
index edf5187..8be7434 100644
--- a/Source/3rdParty/SDL2/src/core/linux/SDL_udev.h
+++ b/Source/3rdParty/SDL2/src/core/linux/SDL_udev.h
@@ -64,22 +64,13 @@ typedef struct SDL_UDEV_CallbackList {
struct SDL_UDEV_CallbackList *next;
} SDL_UDEV_CallbackList;
-typedef struct SDL_UDEV_PrivateData
-{
- const char *udev_library;
- void *udev_handle;
- struct udev *udev;
- struct udev_monitor *udev_mon;
- int ref_count;
- SDL_UDEV_CallbackList *first, *last;
-
- /* Function pointers */
+typedef struct SDL_UDEV_Symbols {
const char *(*udev_device_get_action)(struct udev_device *);
const char *(*udev_device_get_devnode)(struct udev_device *);
const char *(*udev_device_get_subsystem)(struct udev_device *);
- struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
+ struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype);
const char *(*udev_device_get_property_value)(struct udev_device *, const char *);
- const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
+ const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr);
struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *);
void (*udev_device_unref)(struct udev_device *);
int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *);
@@ -100,6 +91,19 @@ typedef struct SDL_UDEV_PrivateData
void (*udev_unref)(struct udev *);
struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum);
dev_t (*udev_device_get_devnum) (struct udev_device *udev_device);
+} SDL_UDEV_Symbols;
+
+typedef struct SDL_UDEV_PrivateData
+{
+ const char *udev_library;
+ void *udev_handle;
+ struct udev *udev;
+ struct udev_monitor *udev_mon;
+ int ref_count;
+ SDL_UDEV_CallbackList *first, *last;
+
+ /* Function pointers */
+ SDL_UDEV_Symbols syms;
} SDL_UDEV_PrivateData;
extern int SDL_UDEV_Init(void);
@@ -110,8 +114,8 @@ extern void SDL_UDEV_Poll(void);
extern void SDL_UDEV_Scan(void);
extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb);
extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb);
-
-
+extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void);
+extern void SDL_UDEV_ReleaseUdevSyms(void);
#endif /* HAVE_LIBUDEV_H */