From afde1cc9c238f90dd0ad945f2b1035b7fbef0393 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 3 Aug 2024 12:02:50 -0700
Subject: [PATCH] Added SDL_HINT_EVDEV_DEVICES
---
include/SDL3/SDL_hints.h | 15 +++++++++++++++
src/core/linux/SDL_evdev.c | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index 0bffad638f689..ab94f7eab64e3 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -685,6 +685,21 @@ extern "C" {
*/
#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
+/**
+ * A variable containing a list of evdev devices to use if udev is not available.
+ *
+ * The list of devices is in the form:
+ *
+ * deviceclass:path[,deviceclass:path[,...]]
+ *
+ * where device class is an integer representing the SDL_UDEV_deviceclass and path is the full path to the event device.
+ *
+ * This hint should be set before SDL is initialized.
+ *
+ * \since This hint is available since SDL 3.0.0.
+ */
+#define SDL_HINT_EVDEV_DEVICES "SDL_EVDEV_DEVICES"
+
/**
* A variable controlling verbosity of the logging of SDL events pushed onto
* the internal queue.
diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c
index 43b3b3b77d06a..96c59802bc20c 100644
--- a/src/core/linux/SDL_evdev.c
+++ b/src/core/linux/SDL_evdev.c
@@ -198,7 +198,7 @@ int SDL_EVDEV_Init(void)
where device class is an integer representing the
SDL_UDEV_deviceclass and path is the full path to
the event device. */
- const char *devices = SDL_getenv("SDL_EVDEV_DEVICES");
+ const char *devices = SDL_GetHint(SDL_HINT_EVDEV_DEVICES);
if (devices) {
/* Assume this is the old use of the env var and it is not in
ROM. */