virtual joysticks: removed ball support (Bug 5028)
authorDavid Ludwig <dludwig@pobox.com>
Sun, 15 Mar 2020 13:25:49 -0400
changeset 136264377c59b636e
parent 13625 d195863f8226
child 13627 c88387a1e0e2
virtual joysticks: removed ball support (Bug 5028)
include/SDL_joystick.h
src/dynapi/SDL_dynapi_procs.h
src/joystick/SDL_joystick.c
src/joystick/virtual/SDL_sysjoystick.c
src/joystick/virtual/SDL_sysjoystick_c.h
     1.1 --- a/include/SDL_joystick.h	Sat Mar 14 17:45:00 2020 -0700
     1.2 +++ b/include/SDL_joystick.h	Sun Mar 15 13:25:49 2020 -0400
     1.3 @@ -206,7 +206,6 @@
     1.4   */
     1.5  extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
     1.6                                                        int naxes,
     1.7 -                                                      int nballs,
     1.8                                                        int nbuttons,
     1.9                                                        int nhats);
    1.10  
    1.11 @@ -226,7 +225,6 @@
    1.12   * Returns 0 on success, -1 on error.
    1.13   */
    1.14  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
    1.15 -extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
    1.16  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
    1.17  extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);
    1.18  
     2.1 --- a/src/dynapi/SDL_dynapi_procs.h	Sat Mar 14 17:45:00 2020 -0700
     2.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Sun Mar 15 13:25:49 2020 -0400
     2.3 @@ -809,11 +809,10 @@
     2.4  #endif
     2.5  SDL_DYNAPI_PROC(int,SDL_isupper,(int a),(a),return)
     2.6  SDL_DYNAPI_PROC(int,SDL_islower,(int a),(a),return)
     2.7 -SDL_DYNAPI_PROC(int,SDL_JoystickAttachVirtual,(SDL_JoystickType a, int b, int c, int d, int e),(a,b,c,d,e),return)
     2.8 +SDL_DYNAPI_PROC(int,SDL_JoystickAttachVirtual,(SDL_JoystickType a, int b, int c, int d),(a,b,c,d),return)
     2.9  SDL_DYNAPI_PROC(int,SDL_JoystickDetachVirtual,(int a),(a),return)
    2.10  SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickIsVirtual,(int a),(a),return)
    2.11  SDL_DYNAPI_PROC(int,SDL_JoystickSetVirtualAxis,(SDL_Joystick *a, int b, Sint16 c),(a,b,c),return)
    2.12 -SDL_DYNAPI_PROC(int,SDL_JoystickSetVirtualBall,(SDL_Joystick *a, int b, Sint16 c, Sint16 d),(a,b,c,d),return)
    2.13  SDL_DYNAPI_PROC(int,SDL_JoystickSetVirtualButton,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
    2.14  SDL_DYNAPI_PROC(int,SDL_JoystickSetVirtualHat,(SDL_Joystick *a, int b, Uint8 c),(a,b,c),return)
    2.15  SDL_DYNAPI_PROC(char*,SDL_GetErrorMsg,(char *a, int b),(a,b),return)
     3.1 --- a/src/joystick/SDL_joystick.c	Sat Mar 14 17:45:00 2020 -0700
     3.2 +++ b/src/joystick/SDL_joystick.c	Sun Mar 15 13:25:49 2020 -0400
     3.3 @@ -466,14 +466,12 @@
     3.4  int
     3.5  SDL_JoystickAttachVirtual(SDL_JoystickType type,
     3.6                            int naxes,
     3.7 -                          int nballs,
     3.8                            int nbuttons,
     3.9                            int nhats)
    3.10  {
    3.11  #if SDL_JOYSTICK_VIRTUAL
    3.12      return SDL_JoystickAttachVirtualInner(type,
    3.13                                            naxes,
    3.14 -                                          nballs,
    3.15                                            nbuttons,
    3.16                                            nhats);
    3.17  #else
    3.18 @@ -540,17 +538,6 @@
    3.19  
    3.20  
    3.21  int
    3.22 -SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int axis, Sint16 xrel, Sint16 yrel)
    3.23 -{
    3.24 -#if SDL_JOYSTICK_VIRTUAL
    3.25 -    return SDL_JoystickSetVirtualBallInner(joystick, axis, xrel, yrel);
    3.26 -#else
    3.27 -    return SDL_SetError("SDL not built with virtual-joystick support");
    3.28 -#endif
    3.29 -}
    3.30 -
    3.31 -
    3.32 -int
    3.33  SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value)
    3.34  {
    3.35  #if SDL_JOYSTICK_VIRTUAL
     4.1 --- a/src/joystick/virtual/SDL_sysjoystick.c	Sat Mar 14 17:45:00 2020 -0700
     4.2 +++ b/src/joystick/virtual/SDL_sysjoystick.c	Sun Mar 15 13:25:49 2020 -0400
     4.3 @@ -60,10 +60,6 @@
     4.4          SDL_free((void *)hwdata->axes);
     4.5          hwdata->axes = NULL;
     4.6      }
     4.7 -    if (hwdata->balls) {
     4.8 -        SDL_free((void *)hwdata->balls);
     4.9 -        hwdata->balls = NULL;
    4.10 -    }
    4.11      if (hwdata->buttons) {
    4.12          SDL_free((void *)hwdata->buttons);
    4.13          hwdata->buttons = NULL;
    4.14 @@ -94,7 +90,6 @@
    4.15  int
    4.16  SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    4.17                                 int naxes,
    4.18 -                               int nballs,
    4.19                                 int nbuttons,
    4.20                                 int nhats)
    4.21  {
    4.22 @@ -108,7 +103,6 @@
    4.23      }
    4.24  
    4.25      hwdata->naxes = naxes;
    4.26 -    hwdata->nballs = nballs;
    4.27      hwdata->nbuttons = nbuttons;
    4.28      hwdata->nhats = nhats;
    4.29      hwdata->name = "Virtual Joystick";
    4.30 @@ -125,13 +119,6 @@
    4.31              return SDL_OutOfMemory();
    4.32          }
    4.33      }
    4.34 -    if (nballs > 0) {
    4.35 -        hwdata->balls = SDL_calloc(nballs, sizeof(hwdata->balls[0]));
    4.36 -        if (!hwdata->balls) {
    4.37 -            VIRTUAL_FreeHWData(hwdata);
    4.38 -            return SDL_OutOfMemory();
    4.39 -        }
    4.40 -    }
    4.41      if (nbuttons > 0) {
    4.42          hwdata->buttons = SDL_calloc(nbuttons, sizeof(Uint8));
    4.43          if (!hwdata->buttons) {
    4.44 @@ -202,32 +189,6 @@
    4.45  
    4.46  
    4.47  int
    4.48 -SDL_JoystickSetVirtualBallInner(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel)
    4.49 -{
    4.50 -    joystick_hwdata *hwdata;
    4.51 -
    4.52 -    SDL_LockJoysticks();
    4.53 -
    4.54 -    if (!joystick || !joystick->hwdata) {
    4.55 -        SDL_UnlockJoysticks();
    4.56 -        return SDL_SetError("Invalid joystick");
    4.57 -    }
    4.58 -
    4.59 -    hwdata = (joystick_hwdata *)joystick->hwdata;
    4.60 -    if (ball < 0 || ball >= hwdata->nbuttons) {
    4.61 -        SDL_UnlockJoysticks();
    4.62 -        return SDL_SetError("Invalid ball index");
    4.63 -    }
    4.64 -
    4.65 -    hwdata->balls[ball].xrel = xrel;
    4.66 -    hwdata->balls[ball].yrel = yrel;
    4.67 -
    4.68 -    SDL_UnlockJoysticks();
    4.69 -    return 0;
    4.70 -}
    4.71 -
    4.72 -
    4.73 -int
    4.74  SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value)
    4.75  {
    4.76      joystick_hwdata *hwdata;
    4.77 @@ -364,7 +325,6 @@
    4.78      joystick->instance_id = hwdata->instance_id;
    4.79      joystick->hwdata = hwdata;
    4.80      joystick->naxes = hwdata->naxes;
    4.81 -    joystick->nballs = hwdata->nballs;
    4.82      joystick->nbuttons = hwdata->nbuttons;
    4.83      joystick->nhats = hwdata->nhats;
    4.84      hwdata->opened = SDL_TRUE;
    4.85 @@ -396,9 +356,6 @@
    4.86      for (int i = 0; i < hwdata->naxes; ++i) {
    4.87          SDL_PrivateJoystickAxis(joystick, i, hwdata->axes[i]);
    4.88      }
    4.89 -    for (int i = 0; i < hwdata->nballs; ++i) {
    4.90 -        SDL_PrivateJoystickBall(joystick, i, hwdata->balls[i].xrel, hwdata->balls[i].yrel);
    4.91 -    }
    4.92      for (int i = 0; i < hwdata->nbuttons; ++i) {
    4.93          SDL_PrivateJoystickButton(joystick, i, hwdata->buttons[i]);
    4.94      }
     5.1 --- a/src/joystick/virtual/SDL_sysjoystick_c.h	Sat Mar 14 17:45:00 2020 -0700
     5.2 +++ b/src/joystick/virtual/SDL_sysjoystick_c.h	Sun Mar 15 13:25:49 2020 -0400
     5.3 @@ -38,11 +38,6 @@
     5.4      SDL_JoystickGUID guid;
     5.5      int naxes;
     5.6      Sint16 *axes;
     5.7 -    int nballs;
     5.8 -    struct {
     5.9 -        Sint16 xrel;
    5.10 -        Sint16 yrel;
    5.11 -    } *balls;
    5.12      int nbuttons;
    5.13      Uint8 *buttons;
    5.14      int nhats;
    5.15 @@ -54,14 +49,12 @@
    5.16  
    5.17  int SDL_JoystickAttachVirtualInner(SDL_JoystickType type,
    5.18                                     int naxes,
    5.19 -                                   int nballs,
    5.20                                     int nbuttons,
    5.21                                     int nhats);
    5.22  
    5.23  int SDL_JoystickDetachVirtualInner(int device_index);
    5.24  
    5.25  int SDL_JoystickSetVirtualAxisInner(SDL_Joystick * joystick, int axis, Sint16 value);
    5.26 -int SDL_JoystickSetVirtualBallInner(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
    5.27  int SDL_JoystickSetVirtualButtonInner(SDL_Joystick * joystick, int button, Uint8 value);
    5.28  int SDL_JoystickSetVirtualHatInner(SDL_Joystick * joystick, int hat, Uint8 value);
    5.29