sdl2-compat: update after SDL3 changed bit width of SDL_Keymod.

From 19333bd0acfeb6f68d5df38f69aafbd32797f56a Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 11 May 2024 03:11:32 +0300
Subject: [PATCH] update after SDL3 changed bit width of SDL_Keymod.

---
 src/dynapi/SDL_dynapi_procs.h |  4 ++--
 src/sdl2_compat.c             | 12 ++++++++++++
 src/sdl2_compat.h             |  2 ++
 src/sdl2_protos.h             |  4 ++--
 src/sdl3_include_wrapper.h    | 15 +++++++++++++++
 src/sdl3_syms.h               |  4 ++--
 6 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 9985131..18e4600 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -248,8 +248,8 @@ SDL_DYNAPI_PROC(Uint8,SDL_JoystickGetButton,(SDL_Joystick *a, int b),(a,b),retur
 SDL_DYNAPI_PROC(void,SDL_JoystickClose,(SDL_Joystick *a),(a),)
 SDL_DYNAPI_PROC(SDL_Window*,SDL_GetKeyboardFocus,(void),(),return)
 SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return)
-SDL_DYNAPI_PROC(SDL_Keymod,SDL_GetModState,(void),(),return)
-SDL_DYNAPI_PROC(void,SDL_SetModState,(SDL_Keymod a),(a),)
+SDL_DYNAPI_PROC(SDL2_Keymod,SDL_GetModState,(void),(),return)
+SDL_DYNAPI_PROC(void,SDL_SetModState,(SDL2_Keymod a),(a),)
 SDL_DYNAPI_PROC(SDL_Keycode,SDL_GetKeyFromScancode,(SDL_Scancode a),(a),return)
 SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromKey,(SDL_Keycode a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetScancodeName,(SDL_Scancode a),(a),return)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 847ca38..9e94502 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -2019,6 +2019,18 @@ SDL_RegisterEvents(int numevents)
     return r > 0 ? r : (Uint32)(-1);
 }
 
+DECLSPEC SDL2_Keymod SDLCALL
+SDL_GetModState(void)
+{
+    return SDL3_GetModState();
+}
+
+DECLSPEC void SDLCALL
+SDL_SetModState(SDL2_Keymod modstate)
+{
+    SDL3_SetModState((SDL_Keymod)modstate);
+}
+
 
 /* Several SDL3 video backends have had their names lower-cased, map to the SDL2 equivalent name. */
 static const char *ReplaceVideoBackendName(const char *name)
diff --git a/src/sdl2_compat.h b/src/sdl2_compat.h
index 458c5f2..f50c12b 100644
--- a/src/sdl2_compat.h
+++ b/src/sdl2_compat.h
@@ -32,6 +32,8 @@ SDL_COMPILE_TIME_ASSERT(SDL23bool, sizeof(SDL2_DUMMY_ENUM) == sizeof(SDL_bool));
 
 /* these types were removed from / renamed in SDL3. We need them for SDL2 APIs exported here. */
 
+typedef int SDL2_Keymod; /* actually this is an enum in real SDL2 */
+
 typedef enum SDL_errorcode
 {
     SDL_ENOMEM,
diff --git a/src/sdl2_protos.h b/src/sdl2_protos.h
index 943d260..e912d7a 100644
--- a/src/sdl2_protos.h
+++ b/src/sdl2_protos.h
@@ -238,8 +238,8 @@ SDL2_PROTO(Uint8,JoystickGetButton,(SDL_Joystick *a, int b))
 SDL2_PROTO(void,JoystickClose,(SDL_Joystick *a))
 SDL2_PROTO(SDL_Window*,GetKeyboardFocus,(void))
 SDL2_PROTO(const Uint8*,GetKeyboardState,(int *a))
-SDL2_PROTO(SDL_Keymod,GetModState,(void))
-SDL2_PROTO(void,SetModState,(SDL_Keymod a))
+SDL2_PROTO(SDL2_Keymod,GetModState,(void))
+SDL2_PROTO(void,SetModState,(SDL2_Keymod a))
 SDL2_PROTO(SDL_Keycode,GetKeyFromScancode,(SDL_Scancode a))
 SDL2_PROTO(SDL_Scancode,GetScancodeFromKey,(SDL_Keycode a))
 SDL2_PROTO(const char*,GetScancodeName,(SDL_Scancode a))
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 164dde6..840c314 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -712,6 +712,7 @@
 #define SDL_SeekIO IGNORE_THIS_VERSION_OF_SDL_SeekIO
 #define SDL_SendGamepadEffect IGNORE_THIS_VERSION_OF_SDL_SendGamepadEffect
 #define SDL_SendJoystickEffect IGNORE_THIS_VERSION_OF_SDL_SendJoystickEffect
+#define SDL_SendJoystickVirtualSensorData IGNORE_THIS_VERSION_OF_SDL_SendJoystickVirtualSensorData
 #define SDL_SetAssertionHandler IGNORE_THIS_VERSION_OF_SDL_SetAssertionHandler
 #define SDL_SetAudioPostmixCallback IGNORE_THIS_VERSION_OF_SDL_SetAudioPostmixCallback
 #define SDL_SetAudioStreamFormat IGNORE_THIS_VERSION_OF_SDL_SetAudioStreamFormat
@@ -739,8 +740,10 @@
 #define SDL_SetJoystickLED IGNORE_THIS_VERSION_OF_SDL_SetJoystickLED
 #define SDL_SetJoystickPlayerIndex IGNORE_THIS_VERSION_OF_SDL_SetJoystickPlayerIndex
 #define SDL_SetJoystickVirtualAxis IGNORE_THIS_VERSION_OF_SDL_SetJoystickVirtualAxis
+#define SDL_SetJoystickVirtualBall IGNORE_THIS_VERSION_OF_SDL_SetJoystickVirtualBall
 #define SDL_SetJoystickVirtualButton IGNORE_THIS_VERSION_OF_SDL_SetJoystickVirtualButton
 #define SDL_SetJoystickVirtualHat IGNORE_THIS_VERSION_OF_SDL_SetJoystickVirtualHat
+#define SDL_SetJoystickVirtualTouchpad IGNORE_THIS_VERSION_OF_SDL_SetJoystickVirtualTouchpad
 #define SDL_SetLogOutputFunction IGNORE_THIS_VERSION_OF_SDL_SetLogOutputFunction
 #define SDL_SetMainReady IGNORE_THIS_VERSION_OF_SDL_SetMainReady
 #define SDL_SetMemoryFunctions IGNORE_THIS_VERSION_OF_SDL_SetMemoryFunctions
@@ -3786,6 +3789,10 @@
 #undef SDL_SendJoystickEffect
 #endif
 
+#ifdef SDL_SendJoystickVirtualSensorData
+#undef SDL_SendJoystickVirtualSensorData
+#endif
+
 #ifdef SDL_SetAssertionHandler
 #undef SDL_SetAssertionHandler
 #endif
@@ -3894,6 +3901,10 @@
 #undef SDL_SetJoystickVirtualAxis
 #endif
 
+#ifdef SDL_SetJoystickVirtualBall
+#undef SDL_SetJoystickVirtualBall
+#endif
+
 #ifdef SDL_SetJoystickVirtualButton
 #undef SDL_SetJoystickVirtualButton
 #endif
@@ -3902,6 +3913,10 @@
 #undef SDL_SetJoystickVirtualHat
 #endif
 
+#ifdef SDL_SetJoystickVirtualTouchpad
+#undef SDL_SetJoystickVirtualTouchpad
+#endif
+
 #ifdef SDL_SetLogOutputFunction
 #undef SDL_SetLogOutputFunction
 #endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index a990117..48604b9 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -221,8 +221,8 @@ SDL3_SYM_RENAMED(Uint8,JoystickGetButton,GetJoystickButton,(SDL_Joystick *a, int
 SDL3_SYM_RENAMED(void,JoystickClose,CloseJoystick,(SDL_Joystick *a),(a),)
 SDL3_SYM_PASSTHROUGH(SDL_Window*,GetKeyboardFocus,(void),(),return)
 SDL3_SYM_PASSTHROUGH(const Uint8*,GetKeyboardState,(int *a),(a),return)
-SDL3_SYM_PASSTHROUGH(SDL_Keymod,GetModState,(void),(),return)
-SDL3_SYM_PASSTHROUGH(void,SetModState,(SDL_Keymod a),(a),)
+SDL3_SYM(SDL_Keymod,GetModState,(void),(),return)
+SDL3_SYM(void,SetModState,(SDL_Keymod a),(a),)
 SDL3_SYM_PASSTHROUGH(SDL_Keycode,GetKeyFromScancode,(SDL_Scancode a),(a),return)
 SDL3_SYM_PASSTHROUGH(SDL_Scancode,GetScancodeFromKey,(SDL_Keycode a),(a),return)
 SDL3_SYM_PASSTHROUGH(const char*,GetScancodeName,(SDL_Scancode a),(a),return)