sdl2-compat: updated after re-addition of balls to SDL3 joystick api

From fa3c843fc2246f1b439eda7e5a89a6b65dcedaf8 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 11 Mar 2024 11:40:04 +0300
Subject: [PATCH] updated after re-addition of balls to SDL3 joystick api

---
 src/sdl2_compat.c          | 20 --------------------
 src/sdl3_include_wrapper.h | 10 ++++++++++
 src/sdl3_syms.h            |  5 ++---
 3 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index e8027f5..fe4f26b 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -2835,26 +2835,6 @@ DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo
     return SDL_TRUE;
 }
 
-/* this API was removed from SDL3 since nothing supported it. Just report 0. */
-DECLSPEC int SDLCALL
-SDL_JoystickNumBalls(SDL_Joystick *joystick)
-{
-    if (SDL3_GetNumJoystickAxes(joystick) == -1) {
-        return -1;  /* just to call JOYSTICK_CHECK_MAGIC on `joystick`. */
-    }
-    return 0;
-}
-
-/* this API was removed from SDL3 since nothing supported it. Just report failure. */
-DECLSPEC int SDLCALL
-SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
-{
-    if (SDL3_GetNumJoystickAxes(joystick) == -1) {
-        return -1;  /* just to call JOYSTICK_CHECK_MAGIC on `joystick`. */
-    }
-    return SDL3_SetError("Joystick only has 0 balls");
-}
-
 
 /* this API was removed in SDL3; use sensor event timestamps instead! */
 DECLSPEC int SDLCALL
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index 38ed9fc..7ac8984 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -1005,6 +1005,8 @@
 #define SDL_qsort_r IGNORE_THIS_VERSION_OF_SDL_qsort_r
 #define SDL_bsearch_r IGNORE_THIS_VERSION_OF_SDL_bsearch_r
 #define SDL_AddVulkanRenderSemaphores IGNORE_THIS_VERSION_OF_SDL_AddVulkanRenderSemaphores
+#define SDL_GetNumJoystickBalls IGNORE_THIS_VERSION_OF_SDL_GetNumJoystickBalls
+#define SDL_GetJoystickBall IGNORE_THIS_VERSION_OF_SDL_GetJoystickBall
 
 
 #define SDL_FUNCTION_POINTER_IS_VOID_POINTER 1
@@ -4917,6 +4919,14 @@
 #undef SDL_AddVulkanRenderSemaphores
 #endif
 
+#ifdef SDL_GetNumJoystickBalls
+#undef SDL_GetNumJoystickBalls
+#endif
+
+#ifdef SDL_GetJoystickBall
+#undef SDL_GetJoystickBall
+#endif
+
 #undef SDL_ThreadID /* see at top. */
 
 /* undefine these macros, too: redefine as SDL3_xxx, if needed. */
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 3f1b876..fb936f8 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -24,15 +24,12 @@
 #ifndef SDL3_SYM
 #define SDL3_SYM(rc,fn,params,args,ret)
 #endif
-
 #ifndef SDL3_SYM_PASSTHROUGH
 #define SDL3_SYM_PASSTHROUGH(rc,fn,params,args,ret) SDL3_SYM(rc,fn,params,args,ret)
 #endif
-
 #ifndef SDL3_SYM_RENAMED
 #define SDL3_SYM_RENAMED(rc,oldfn,newfn,params,args,ret) SDL3_SYM(rc,newfn,params,args,ret)
 #endif
-
 #ifndef SDL3_SYM_VARARGS
 #define SDL3_SYM_VARARGS(rc,fn,params) SDL3_SYM(rc,fn,params,unused,unused)
 #endif
@@ -213,10 +210,12 @@ SDL3_SYM_RENAMED(SDL_JoystickGUID,JoystickGetGUIDFromString,GetJoystickGUIDFromS
 SDL3_SYM_RENAMED(SDL_bool,JoystickGetAttached,JoystickConnected,(SDL_Joystick *a),(a),return)
 SDL3_SYM(SDL_JoystickID,GetJoystickInstanceID,(SDL_Joystick *a),(a),return)
 SDL3_SYM_RENAMED(int,JoystickNumAxes,GetNumJoystickAxes,(SDL_Joystick *a),(a),return)
+SDL3_SYM_RENAMED(int,JoystickNumBalls,GetNumJoystickBalls,(SDL_Joystick *a),(a),return)
 SDL3_SYM_RENAMED(int,JoystickNumHats,GetNumJoystickHats,(SDL_Joystick *a),(a),return)
 SDL3_SYM_RENAMED(int,JoystickNumButtons,GetNumJoystickButtons,(SDL_Joystick *a),(a),return)
 SDL3_SYM_RENAMED(void,JoystickUpdate,UpdateJoysticks,(void),(),)
 SDL3_SYM_RENAMED(Sint16,JoystickGetAxis,GetJoystickAxis,(SDL_Joystick *a, int b),(a,b),return)
+SDL3_SYM_RENAMED(int,JoystickGetBall,GetJoystickBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return);
 SDL3_SYM_RENAMED(Uint8,JoystickGetHat,GetJoystickHat,(SDL_Joystick *a, int b),(a,b),return)
 SDL3_SYM_RENAMED(Uint8,JoystickGetButton,GetJoystickButton,(SDL_Joystick *a, int b),(a,b),return)
 SDL3_SYM_RENAMED(void,JoystickClose,CloseJoystick,(SDL_Joystick *a),(a),)