sdl2-compat: joystick: Add stubs for joystick ball functions, removed from SDL3.

From 5503f74c292f64d7e8f1e62c5e9b59bcdd5311ad Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 11 Dec 2022 23:28:14 -0500
Subject: [PATCH] joystick: Add stubs for joystick ball functions, removed from
 SDL3.

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

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 161cf9b..ba50b07 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -922,6 +922,25 @@ SDL_GetWindowWMInfo(SDL_Window *window, SDL_SysWMinfo *wminfo)
     return SDL_FALSE;
 }
 
+/* this API was removed from SDL3 since nothing supported it. Just report 0. */
+DECLSPEC int SDLCALL
+SDL_JoystickNumBalls(SDL_Joystick *joystick)
+{
+    if (SDL3_JoystickNumAxes(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_JoystickNumAxes(joystick) == -1) {
+        return -1;  /* just to call JOYSTICK_CHECK_MAGIC on `joystick`. */
+    }
+    return SDL3_SetError("Joystick only has 0 balls");
+}
 
 #ifdef __cplusplus
 }
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 7e903cc..00ee76d 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -226,14 +226,12 @@ SDL3_SYM_PASSTHROUGH(SDL_JoystickGUID,JoystickGetGUIDFromString,(const char *a),
 SDL3_SYM_PASSTHROUGH(SDL_bool,JoystickGetAttached,(SDL_Joystick *a),(a),return)
 SDL3_SYM_PASSTHROUGH(SDL_JoystickID,JoystickInstanceID,(SDL_Joystick *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,JoystickNumAxes,(SDL_Joystick *a),(a),return)
-SDL3_SYM_PASSTHROUGH(int,JoystickNumBalls,(SDL_Joystick *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,JoystickNumHats,(SDL_Joystick *a),(a),return)
 SDL3_SYM_PASSTHROUGH(int,JoystickNumButtons,(SDL_Joystick *a),(a),return)
 SDL3_SYM_PASSTHROUGH(void,JoystickUpdate,(void),(),)
 SDL3_SYM_PASSTHROUGH(int,JoystickEventState,(int a),(a),return)
 SDL3_SYM_PASSTHROUGH(Sint16,JoystickGetAxis,(SDL_Joystick *a, int b),(a,b),return)
 SDL3_SYM_PASSTHROUGH(Uint8,JoystickGetHat,(SDL_Joystick *a, int b),(a,b),return)
-SDL3_SYM_PASSTHROUGH(int,JoystickGetBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return)
 SDL3_SYM_PASSTHROUGH(Uint8,JoystickGetButton,(SDL_Joystick *a, int b),(a,b),return)
 SDL3_SYM_PASSTHROUGH(void,JoystickClose,(SDL_Joystick *a),(a),)
 SDL3_SYM_PASSTHROUGH(SDL_Window*,GetKeyboardFocus,(void),(),return)