From ce0da58755c492f848a1d574e2eeeec86e67d97f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 21 Dec 2025 09:15:23 -0800
Subject: [PATCH] Made udev hwdb functionality optional
---
src/core/linux/SDL_udev.c | 11 +++++++----
src/core/linux/SDL_udev.h | 2 +-
src/hidapi/linux/hid.c | 4 ++--
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c
index 00bed5e5fc75c..73071410ae401 100644
--- a/src/core/linux/SDL_udev.c
+++ b/src/core/linux/SDL_udev.c
@@ -81,6 +81,9 @@ static bool SDL_UDEV_load_syms(void)
if (!SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x)) \
return false
+#define SDL_UDEV_SYM_OPTIONAL(x) \
+ SDL_UDEV_load_sym(#x, (void **)(char *)&_this->syms.x);
+
SDL_UDEV_SYM(udev_device_get_action);
SDL_UDEV_SYM(udev_device_get_devnode);
SDL_UDEV_SYM(udev_device_get_driver);
@@ -98,6 +101,7 @@ static bool SDL_UDEV_load_syms(void)
SDL_UDEV_SYM(udev_enumerate_scan_devices);
SDL_UDEV_SYM(udev_enumerate_unref);
SDL_UDEV_SYM(udev_list_entry_get_name);
+ SDL_UDEV_SYM(udev_list_entry_get_value);
SDL_UDEV_SYM(udev_list_entry_get_next);
SDL_UDEV_SYM(udev_monitor_enable_receiving);
SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype);
@@ -110,10 +114,9 @@ static bool SDL_UDEV_load_syms(void)
SDL_UDEV_SYM(udev_device_new_from_devnum);
SDL_UDEV_SYM(udev_device_get_devnum);
- SDL_UDEV_SYM(udev_hwdb_new);
- SDL_UDEV_SYM(udev_hwdb_unref);
- SDL_UDEV_SYM(udev_hwdb_get_properties_list_entry);
- SDL_UDEV_SYM(udev_list_entry_get_value);
+ SDL_UDEV_SYM_OPTIONAL(udev_hwdb_new);
+ SDL_UDEV_SYM_OPTIONAL(udev_hwdb_unref);
+ SDL_UDEV_SYM_OPTIONAL(udev_hwdb_get_properties_list_entry);
#undef SDL_UDEV_SYM
diff --git a/src/core/linux/SDL_udev.h b/src/core/linux/SDL_udev.h
index 3f69ce6237d40..d4f737c07cabc 100644
--- a/src/core/linux/SDL_udev.h
+++ b/src/core/linux/SDL_udev.h
@@ -72,6 +72,7 @@ typedef struct SDL_UDEV_Symbols
int (*udev_enumerate_scan_devices)(struct udev_enumerate *);
void (*udev_enumerate_unref)(struct udev_enumerate *);
const char *(*udev_list_entry_get_name)(struct udev_list_entry *);
+ const char *(*udev_list_entry_get_value)(struct udev_list_entry *);
struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *);
int (*udev_monitor_enable_receiving)(struct udev_monitor *);
int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *);
@@ -87,7 +88,6 @@ typedef struct SDL_UDEV_Symbols
struct udev_hwdb *(*udev_hwdb_new)(struct udev *udev);
struct udev_hwdb *(*udev_hwdb_unref)(struct udev_hwdb *hwdb);
struct udev_list_entry *(*udev_hwdb_get_properties_list_entry)(struct udev_hwdb *hwdb, const char *modalias, unsigned flags);
- const char *(*udev_list_entry_get_value)(struct udev_list_entry *list_entry);
} SDL_UDEV_Symbols;
diff --git a/src/hidapi/linux/hid.c b/src/hidapi/linux/hid.c
index 9bb781a79d972..47233d1f8fce4 100644
--- a/src/hidapi/linux/hid.c
+++ b/src/hidapi/linux/hid.c
@@ -916,7 +916,7 @@ static struct hid_device_info * create_device_info_for_device(struct udev_device
root = cur_dev;
}
tmp->next = NULL;
-
+
hid_free_enumeration(tmp);
} else {
prev_dev = cur_dev;
@@ -1071,7 +1071,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
tmp = create_device_info_for_device(raw_dev);
if (tmp) {
- if (!tmp->manufacturer_string) {
+ if (!tmp->manufacturer_string && udev_hwdb_new) {
key = "ID_VENDOR_FROM_DATABASE";
if ((hwdb = udev_hwdb_new(udev)) != NULL) {