sdl2-compat: Map lowercased SDL3 video backend names to their SDL2 equivalents.

From 61fc18709f669509689eebfe803fa2f6b7667e7f Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 25 Jan 2024 15:32:41 -0500
Subject: [PATCH] Map lowercased SDL3 video backend names to their SDL2
 equivalents.

---
 src/sdl2_compat.c | 29 +++++++++++++++++++++++++++++
 src/sdl3_syms.h   |  4 ++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index ed5bd6c..62727f4 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -1896,6 +1896,35 @@ SDL_FilterEvents(SDL2_EventFilter filter2, void *userdata)
 }
 
 
+/* Several SDL3 video backends have had their names lower-cased, map to the SDL2 equivalent name. */
+static const char *ReplaceVideoBackendName(const char *name)
+{
+    if (name) {
+        #define CHECKBACKEND(sdl2name) if (SDL_strcasecmp(name, sdl2name) == 0) { return sdl2name; }
+        CHECKBACKEND("KMSDRM");
+        CHECKBACKEND("RPI");
+        CHECKBACKEND("Android");
+        CHECKBACKEND("PSP");
+        CHECKBACKEND("PS2");
+        CHECKBACKEND("VITA");
+        #undef CHECKBACKEND
+    }
+    return name;
+}
+
+DECLSPEC const char * SDLCALL
+SDL_GetVideoDriver(int idx)
+{
+    return ReplaceVideoBackendName(SDL3_GetVideoDriver(idx));
+}
+
+DECLSPEC const char * SDLCALL
+SDL_GetCurrentVideoDriver(void)
+{
+    return ReplaceVideoBackendName(SDL3_GetCurrentVideoDriver());
+}
+
+
 /* mouse coords became floats in SDL3 */
 
 DECLSPEC Uint32 SDLCALL
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index a93a459..a6dd3f9 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -465,8 +465,8 @@ SDL3_SYM_PASSTHROUGH(int,GetNumTouchFingers,(SDL_TouchID a),(a),return)
 SDL3_SYM_PASSTHROUGH(SDL_Finger*,GetTouchFinger,(SDL_TouchID a, int b),(a,b),return)
 SDL3_SYM(int,GetVersion,(SDL_version *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,GetNumVideoDrivers,(void),(),return)
-SDL3_SYM_PASSTHROUGH(const char*,GetVideoDriver,(int a),(a),return)
-SDL3_SYM_PASSTHROUGH(const char*,GetCurrentVideoDriver,(void),(),return)
+SDL3_SYM(const char*,GetVideoDriver,(int a),(a),return)
+SDL3_SYM(const char*,GetCurrentVideoDriver,(void),(),return)
 SDL3_SYM(const char*,GetDisplayName,(SDL_DisplayID a),(a),return)
 SDL3_SYM(int,GetDisplayBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
 SDL3_SYM(float,GetDisplayContentScale,(SDL_DisplayID a),(a),return)