From ef250372b8c76d20188d909b32db0a6bd34d4294 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Fri, 1 Dec 2023 22:37:00 +0300
Subject: [PATCH] update after SDL_GetErrorMsg removal in SDL3
---
src/sdl2_compat.c | 7 +++++++
src/sdl3_include_wrapper.h | 40 ++++++++++++++------------------------
src/sdl3_syms.h | 1 -
3 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 8498217..491e5ac 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -1275,6 +1275,13 @@ SDL_GetRevision(void)
return SDL2COMPAT_REVISION;
}
+DECLSPEC char * SDLCALL
+SDL_GetErrorMsg(char *errstr, int maxlen)
+{
+ SDL3_strlcpy(errstr, SDL3_GetError(), maxlen);
+ return errstr;
+}
+
DECLSPEC int SDLCALL
SDL_SetError(const char *fmt, ...)
{
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 60fd1f9..2be2ec7 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -190,7 +190,6 @@
#define SDL_GetDisplayUsableBounds IGNORE_THIS_VERSION_OF_SDL_GetDisplayUsableBounds
#define SDL_GetDisplays IGNORE_THIS_VERSION_OF_SDL_GetDisplays
#define SDL_GetError IGNORE_THIS_VERSION_OF_SDL_GetError
-#define SDL_GetErrorMsg IGNORE_THIS_VERSION_OF_SDL_GetErrorMsg
#define SDL_GetEventFilter IGNORE_THIS_VERSION_OF_SDL_GetEventFilter
#define SDL_GetFullscreenDisplayModes IGNORE_THIS_VERSION_OF_SDL_GetFullscreenDisplayModes
#define SDL_GetGamepadAppleSFSymbolsNameForAxis IGNORE_THIS_VERSION_OF_SDL_GetGamepadAppleSFSymbolsNameForAxis
@@ -214,9 +213,7 @@
#define SDL_GetGamepadInstanceVendor IGNORE_THIS_VERSION_OF_SDL_GetGamepadInstanceVendor
#define SDL_GetGamepadJoystick IGNORE_THIS_VERSION_OF_SDL_GetGamepadJoystick
#define SDL_GetGamepadMapping IGNORE_THIS_VERSION_OF_SDL_GetGamepadMapping
-#define SDL_GetGamepadMappings IGNORE_THIS_VERSION_OF_SDL_GetGamepadMappings
#define SDL_GetGamepadMappingForGUID IGNORE_THIS_VERSION_OF_SDL_GetGamepadMappingForGUID
-#define SDL_GetGamepadMappingForIndex IGNORE_THIS_VERSION_OF_SDL_GetGamepadMappingForIndex
#define SDL_GetGamepadName IGNORE_THIS_VERSION_OF_SDL_GetGamepadName
#define SDL_GetGamepadPath IGNORE_THIS_VERSION_OF_SDL_GetGamepadPath
#define SDL_GetGamepadPlayerIndex IGNORE_THIS_VERSION_OF_SDL_GetGamepadPlayerIndex
@@ -355,8 +352,6 @@
#define SDL_GetThreadName IGNORE_THIS_VERSION_OF_SDL_GetThreadName
#define SDL_GetTicks IGNORE_THIS_VERSION_OF_SDL_GetTicks
#define SDL_GetTicksNS IGNORE_THIS_VERSION_OF_SDL_GetTicksNS
-#define SDL_GetTouchDevices IGNORE_THIS_VERSION_OF_SDL_GetTouchDevices
-#define SDL_GetTouchDeviceName IGNORE_THIS_VERSION_OF_SDL_GetTouchDeviceName
#define SDL_GetTouchDeviceType IGNORE_THIS_VERSION_OF_SDL_GetTouchDeviceType
#define SDL_GetTouchFinger IGNORE_THIS_VERSION_OF_SDL_GetTouchFinger
#define SDL_GetVersion IGNORE_THIS_VERSION_OF_SDL_GetVersion
@@ -987,6 +982,9 @@
#define SDL_GetBooleanProperty IGNORE_THIS_VERSION_OF_SDL_GetBooleanProperty
#define SDL_CreateTextureWithProperties IGNORE_THIS_VERSION_OF_SDL_CreateTextureWithProperties
#define SDL_CreateRendererWithProperties IGNORE_THIS_VERSION_OF_SDL_CreateRendererWithProperties
+#define SDL_GetGamepadMappings IGNORE_THIS_VERSION_OF_SDL_GetGamepadMappings
+#define SDL_GetTouchDevices IGNORE_THIS_VERSION_OF_SDL_GetTouchDevices
+#define SDL_GetTouchDeviceName IGNORE_THIS_VERSION_OF_SDL_GetTouchDeviceName
#define SDL_FUNCTION_POINTER_IS_VOID_POINTER 1
@@ -1663,10 +1661,6 @@
#undef SDL_GetError
#endif
-#ifdef SDL_GetErrorMsg
-#undef SDL_GetErrorMsg
-#endif
-
#ifdef SDL_GetEventFilter
#undef SDL_GetEventFilter
#endif
@@ -1759,18 +1753,10 @@
#undef SDL_GetGamepadMapping
#endif
-#ifdef SDL_GetGamepadMappings
-#undef SDL_GetGamepadMappings
-#endif
-
#ifdef SDL_GetGamepadMappingForGUID
#undef SDL_GetGamepadMappingForGUID
#endif
-#ifdef SDL_GetGamepadMappingForIndex
-#undef SDL_GetGamepadMappingForIndex
-#endif
-
#ifdef SDL_GetGamepadName
#undef SDL_GetGamepadName
#endif
@@ -2323,14 +2309,6 @@
#undef SDL_GetTicksNS
#endif
-#ifdef SDL_GetTouchDevices
-#undef SDL_GetTouchDevices
-#endif
-
-#ifdef SDL_GetTouchDeviceName
-#undef SDL_GetTouchDeviceName
-#endif
-
#ifdef SDL_GetTouchDeviceType
#undef SDL_GetTouchDeviceType
#endif
@@ -4851,6 +4829,18 @@
#undef SDL_CreateRendererWithProperties
#endif
+#ifdef SDL_GetGamepadMappings
+#undef SDL_GetGamepadMappings
+#endif
+
+#ifdef SDL_GetTouchDevices
+#undef SDL_GetTouchDevices
+#endif
+
+#ifdef SDL_GetTouchDeviceName
+#undef SDL_GetTouchDeviceName
+#endif
+
/* undefine these macros too: */
/* redefine as SDL3_xxx, if needed. */
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 7ca7583..01e146b 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -662,7 +662,6 @@ SDL3_SYM(SDL_JoystickID,AttachVirtualJoystickEx,(const SDL_VirtualJoystickDesc *
SDL3_SYM_RENAMED(int,JoystickSetVirtualAxis,SetJoystickVirtualAxis,(SDL_Joystick *a, int b, Sint16 c),(a,b,c),return)
SDL3_SYM_RENAMED(int,JoystickSetVirtualButton,SetJoystickVirtualButton,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
SDL3_SYM_RENAMED(int,JoystickSetVirtualHat,SetJoystickVirtualHat,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
-SDL3_SYM_PASSTHROUGH(char*,GetErrorMsg,(char *a, int b),(a,b),return)
SDL3_SYM_PASSTHROUGH(void*,Metal_GetLayer,(SDL_MetalView a),(a),return)
SDL3_SYM_PASSTHROUGH(double,trunc,(double a),(a),return)
SDL3_SYM_PASSTHROUGH(float,truncf,(float a),(a),return)