sdl2-compat: syncing with latest SDL2 and SDL3 (53a34)

From 53a3493ec40afb96d4241d94a7b5f9299de01f45 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 23 Apr 2024 20:01:40 +0300
Subject: [PATCH] syncing with latest SDL2 and SDL3

---
 include/SDL2/SDL_audio.h          | 36 +++++++++++++++----------------
 include/SDL2/SDL_gamecontroller.h | 15 ++++++-------
 include/SDL2/SDL_keyboard.h       |  9 ++++----
 include/SDL2/SDL_video.h          |  4 ++--
 src/sdl3_include_wrapper.h        |  5 +++++
 test/testmouse.c                  | 19 ++++++++++++----
 6 files changed, 52 insertions(+), 36 deletions(-)

diff --git a/include/SDL2/SDL_audio.h b/include/SDL2/SDL_audio.h
index bd8e7ab..df09c3a 100644
--- a/include/SDL2/SDL_audio.h
+++ b/include/SDL2/SDL_audio.h
@@ -44,24 +44,24 @@ extern "C" {
 #endif
 
 /**
- *  \brief Audio format flags.
- *
- *  These are what the 16 bits in SDL_AudioFormat currently mean...
- *  (Unspecified bits are always zero).
- *
- *  \verbatim
-    ++-----------------------sample is signed if set
-    ||
-    ||       ++-----------sample is bigendian if set
-    ||       ||
-    ||       ||          ++---sample is float if set
-    ||       ||          ||
-    ||       ||          || +---sample bit size---+
-    ||       ||          || |                     |
-    15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
-    \endverbatim
- *
- *  There are macros in SDL 2.0 and later to query these bits.
+ * Audio format flags.
+ *
+ * These are what the 16 bits in SDL_AudioFormat currently mean...
+ * (Unspecified bits are always zero).
+ *
+ * ```
+ * ++-----------------------sample is signed if set
+ * ||
+ * ||       ++-----------sample is bigendian if set
+ * ||       ||
+ * ||       ||          ++---sample is float if set
+ * ||       ||          ||
+ * ||       ||          || +---sample bit size---+
+ * ||       ||          || |                     |
+ * 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
+ * ```
+ *
+ * There are macros in SDL 2.0 and later to query these bits.
  */
 typedef Uint16 SDL_AudioFormat;
 
diff --git a/include/SDL2/SDL_gamecontroller.h b/include/SDL2/SDL_gamecontroller.h
index 44089cf..30210c8 100644
--- a/include/SDL2/SDL_gamecontroller.h
+++ b/include/SDL2/SDL_gamecontroller.h
@@ -527,8 +527,8 @@ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameControl
 /**
  * Get the Steam Input handle of an opened controller, if available.
  *
- * Returns an InputHandle_t for the controller that can be used with Steam Input API:
- * https://partner.steamgames.com/doc/api/ISteamInput
+ * Returns an InputHandle_t for the controller that can be used with Steam
+ * Input API: https://partner.steamgames.com/doc/api/ISteamInput
  *
  * \param gamecontroller the game controller object to query.
  * \returns the gamepad handle, or 0 if unavailable.
@@ -704,13 +704,12 @@ SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameController
  *
  * The axis indices start at index 0.
  *
- * For thumbsticks, the state is a value ranging from -32768 (up/left)
- * to 32767 (down/right).
+ * For thumbsticks, the state is a value ranging from -32768 (up/left) to
+ * 32767 (down/right).
  *
- * Triggers range from 0 when released to 32767 when fully pressed, and
- * never return a negative value. Note that this differs from the value
- * reported by the lower-level SDL_GetJoystickAxis(), which normally uses
- * the full range.
+ * Triggers range from 0 when released to 32767 when fully pressed, and never
+ * return a negative value. Note that this differs from the value reported by
+ * the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
  *
  * \param gamecontroller a game controller
  * \param axis an axis index (one of the SDL_GameControllerAxis values)
diff --git a/include/SDL2/SDL_keyboard.h b/include/SDL2/SDL_keyboard.h
index 03c7b5a..d12fcf6 100644
--- a/include/SDL2/SDL_keyboard.h
+++ b/include/SDL2/SDL_keyboard.h
@@ -298,10 +298,11 @@ extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
 extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
 
 /**
- * Set the rectangle used to type Unicode text inputs. Native input methods
- * will place a window with word suggestions near it, without covering the
- * text being inputted.
- * 
+ * Set the rectangle used to type Unicode text inputs.
+ *
+ * Native input methods will place a window with word suggestions near it,
+ * without covering the text being inputted.
+ *
  * To start text input in a given location, this function is intended to be
  * called before SDL_StartTextInput, although some platforms support moving
  * the rectangle even while text input (and a composition) is active.
diff --git a/include/SDL2/SDL_video.h b/include/SDL2/SDL_video.h
index 667880f..2fc8264 100644
--- a/include/SDL2/SDL_video.h
+++ b/include/SDL2/SDL_video.h
@@ -1347,8 +1347,8 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
  *
  * Note that this function will update _at least_ the rectangles specified,
  * but this is only intended as an optimization; in practice, this might
- * update more of the screen (or all of the screen!), depending on what
- * method SDL uses to send pixels to the system.
+ * update more of the screen (or all of the screen!), depending on what method
+ * SDL uses to send pixels to the system.
  *
  * \param window the window to update
  * \param rects an array of SDL_Rect structures representing areas of the
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index c89f16b..71a1bb0 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -1045,6 +1045,7 @@
 #define SDL_wcsnstr IGNORE_THIS_VERSION_OF_SDL_wcsnstr
 #define SDL_wcsstr IGNORE_THIS_VERSION_OF_SDL_wcsstr
 #define SDL_wcstol IGNORE_THIS_VERSION_OF_SDL_wcstol
+#define SDL_WriteStorageFile IGNORE_THIS_VERSION_OF_SDL_WriteStorageFile
 
 
 #define SDL_FUNCTION_POINTER_IS_VOID_POINTER 1
@@ -5117,6 +5118,10 @@
 #undef SDL_wcstol
 #endif
 
+#ifdef SDL_WriteStorageFile
+#undef SDL_WriteStorageFile
+#endif
+
 #undef SDL_ThreadID /* see at top. */
 
 /* undefine these macros, too: redefine as SDL3_xxx, if needed. */
diff --git a/test/testmouse.c b/test/testmouse.c
index 0583ead..1622a48 100644
--- a/test/testmouse.c
+++ b/test/testmouse.c
@@ -18,7 +18,13 @@
 
 #include <stdlib.h> /* exit() */
 
-#ifdef __IPHONEOS__
+#ifdef __3DS__
+/* For mouse-based tests, we want to have the window on the touch screen */
+#define SCREEN_X 40
+#define SCREEN_Y 240
+#define SCREEN_WIDTH    320
+#define SCREEN_HEIGHT   240
+#elif defined(__IPHONEOS__)
 #define SCREEN_WIDTH    320
 #define SCREEN_HEIGHT   480
 #else
@@ -26,6 +32,13 @@
 #define SCREEN_HEIGHT 480
 #endif
 
+#ifndef SCREEN_X
+#define SCREEN_X SDL_WINDOWPOS_CENTERED
+#endif
+#ifndef SCREEN_Y
+#define SCREEN_Y SDL_WINDOWPOS_CENTERED
+#endif
+
 static SDL_Window *window;
 
 typedef struct _Object
@@ -263,9 +276,7 @@ int main(int argc, char *argv[])
     }
 
     /* Create a window to display joystick axis position */
-    window = SDL_CreateWindow("Mouse Test", SDL_WINDOWPOS_CENTERED,
-                              SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
-                              SCREEN_HEIGHT, 0);
+    window = SDL_CreateWindow("Mouse Test", SCREEN_X, SCREEN_Y, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
     if (!window) {
         SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
         return SDL_FALSE;