backport commit 0b3496f:
Add support for SDL3 joystick input driver

Index: platform/x11/detect.py
--- platform/x11/detect.py.orig
+++ platform/x11/detect.py
@@ -89,29 +89,6 @@ def get_flags():
 def configure(env):
     ## Build type
 
-    if env["target"] == "release":
-        if env["optimize"] == "speed":  # optimize for speed (default)
-            env.Prepend(CCFLAGS=["-O3"])
-        elif env["optimize"] == "size":  # optimize for size
-            env.Prepend(CCFLAGS=["-Os"])
-
-        if env["debug_symbols"]:
-            env.Prepend(CCFLAGS=["-g2"])
-
-    elif env["target"] == "release_debug":
-        if env["optimize"] == "speed":  # optimize for speed (default)
-            env.Prepend(CCFLAGS=["-O2"])
-        elif env["optimize"] == "size":  # optimize for size
-            env.Prepend(CCFLAGS=["-Os"])
-
-        if env["debug_symbols"]:
-            env.Prepend(CCFLAGS=["-g2"])
-
-    elif env["target"] == "debug":
-        env.Prepend(CCFLAGS=["-ggdb"])
-        env.Prepend(CCFLAGS=["-g3"])
-        env.Append(LINKFLAGS=["-rdynamic"])
-
     if env["debug_symbols"]:
         # Adding dwarf-4 explicitly makes stacktraces work with clang builds,
         # otherwise addr2line doesn't understand them
@@ -371,6 +348,10 @@ def configure(env):
     else:
         print("Warning: ALSA libraries not found. Disabling the ALSA audio driver.")
 
+    print("Enabling sndio")
+    env.Append(CPPDEFINES=["SNDIO_ENABLED"])
+    env.Append(LINKFLAGS=["-lsndio"])
+
     if env["pulseaudio"]:
         if os.system("pkg-config --exists libpulse") == 0:  # 0 means found
             env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"])
@@ -398,6 +379,18 @@ def configure(env):
                 print("Warning: libudev development libraries not found. Disabling controller hotplugging support.")
     else:
         env["udev"] = False  # Linux specific
+
+    if env["sdl"]:
+        if env["builtin_sdl"]:
+            env.Append(CPPDEFINES=["SDL_ENABLED"])
+        elif os.system("pkg-config --exists fontconfig") == 0:  # 0 means found
+            env.ParseConfig("pkg-config sdl3 --cflags --libs")
+            env.Append(CPPDEFINES=["SDL_ENABLED"])
+        else:
+            print_warning(
+                "SDL3 development libraries not found, and `builtin_sdl` was explicitly disabled. Disabling SDL input driver support."
+            )
+            env["sdl"] = False
 
     # Linkflags below this line should typically stay the last ones
     if not env["builtin_zlib"]:
