Probable fix for compile errors on Mac OS and (non-VS) Win32
authorJimb Esser <wasteland@gmail.com>
Fri, 20 Mar 2020 19:49:19 -0700
changeset 1365599fb2d227d8a
parent 13654 b51e7317fdfc
child 13656 498eabc38df8
Probable fix for compile errors on Mac OS and (non-VS) Win32
configure.ac
src/joystick/windows/SDL_rawinputjoystick.c
     1.1 --- a/configure.ac	Fri Mar 20 19:49:15 2020 -0700
     1.2 +++ b/configure.ac	Fri Mar 20 19:49:19 2020 -0700
     1.3 @@ -3291,6 +3291,10 @@
     1.4          *-*-*bsd* )
     1.5              onlylibusb=yes
     1.6              ;;
     1.7 +        # RAWINPUT is only available on Win32, but can be enabled if HIDAPI is
     1.8 +        *-*-cygwin* | *-*-mingw32*)
     1.9 +            userawinput=yes
    1.10 +            ;;
    1.11      esac
    1.12  
    1.13      AC_ARG_ENABLE(hidapi,
    1.14 @@ -3316,7 +3320,9 @@
    1.15  
    1.16          if test x$hidapi_support = xyes; then
    1.17              AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
    1.18 -            AC_DEFINE(SDL_JOYSTICK_RAWINPUT, 1, [ ])
    1.19 +            if test x$userawinput = xyes; then
    1.20 +                AC_DEFINE(SDL_JOYSTICK_RAWINPUT, 1, [ ])
    1.21 +            fi
    1.22              EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
    1.23              SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
    1.24              SOURCES="$SOURCES $srcdir/src/hidapi/SDL_hidapi.c"
     2.1 --- a/src/joystick/windows/SDL_rawinputjoystick.c	Fri Mar 20 19:49:15 2020 -0700
     2.2 +++ b/src/joystick/windows/SDL_rawinputjoystick.c	Fri Mar 20 19:49:19 2020 -0700
     2.3 @@ -241,6 +241,7 @@
     2.4  RAWINPUT_GetDeviceDriver(SDL_RAWINPUT_Device *device)
     2.5  {
     2.6      int i;
     2.7 +    SDL_GameControllerType type;
     2.8  
     2.9      if (SDL_ShouldIgnoreJoystick(device->name, device->guid)) {
    2.10          return NULL;
    2.11 @@ -253,7 +254,7 @@
    2.12          return NULL;
    2.13      }
    2.14  
    2.15 -    SDL_GameControllerType type = SDL_GetJoystickGameControllerType("", device->vendor_id, device->product_id, -1, 0, 0, 0);
    2.16 +    type = SDL_GetJoystickGameControllerType("", device->vendor_id, device->product_id, -1, 0, 0, 0);
    2.17  
    2.18      for (i = 0; i < SDL_arraysize(SDL_RAWINPUT_drivers); ++i) {
    2.19          SDL_HIDAPI_DeviceDriver *driver = SDL_RAWINPUT_drivers[i];
    2.20 @@ -365,6 +366,7 @@
    2.21      SDL_RAWINPUT_Device *curr, *last;
    2.22      for (curr = SDL_RAWINPUT_devices, last = NULL; curr; last = curr, curr = curr->next) {
    2.23          if (curr == device) {
    2.24 +            SDL_Joystick *joystick;
    2.25              if (last) {
    2.26                  last->next = curr->next;
    2.27              } else {
    2.28 @@ -372,7 +374,7 @@
    2.29              }
    2.30              --SDL_RAWINPUT_numjoysticks;
    2.31  
    2.32 -            SDL_Joystick *joystick = device->joystick;
    2.33 +            joystick = device->joystick;
    2.34              if (joystick) {
    2.35                  /* Detach from joystick */
    2.36                  RAWINPUT_JoystickClose(joystick);