cmake: Fix building with -DSDL_HAPTIC=Off
authorstfx <stfx@hotmail.de>
Wed, 08 Jul 2020 17:28:34 +0200
changeset 13944b8c8ce11efc7
parent 13943 2eec032757ce
child 13945 465afae5eb7e
cmake: Fix building with -DSDL_HAPTIC=Off
CMakeLists.txt
src/haptic/windows/SDL_windowshaptic_c.h
src/joystick/windows/SDL_windowsjoystick.c
     1.1 --- a/CMakeLists.txt	Sun Jul 05 22:33:10 2020 +0300
     1.2 +++ b/CMakeLists.txt	Wed Jul 08 17:28:34 2020 +0200
     1.3 @@ -404,6 +404,7 @@
     1.4    ${SDL2_SOURCE_DIR}/src/dynapi/*.c
     1.5    ${SDL2_SOURCE_DIR}/src/events/*.c
     1.6    ${SDL2_SOURCE_DIR}/src/file/*.c
     1.7 +  ${SDL2_SOURCE_DIR}/src/haptic/*.c
     1.8    ${SDL2_SOURCE_DIR}/src/libm/*.c
     1.9    ${SDL2_SOURCE_DIR}/src/locale/*.c
    1.10    ${SDL2_SOURCE_DIR}/src/power/*.c
    1.11 @@ -878,8 +879,6 @@
    1.12      # Haptic requires some private functions from the joystick subsystem.
    1.13      message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
    1.14    endif()
    1.15 -  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
    1.16 -  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
    1.17  endif()
    1.18  
    1.19  
     2.1 --- a/src/haptic/windows/SDL_windowshaptic_c.h	Sun Jul 05 22:33:10 2020 +0300
     2.2 +++ b/src/haptic/windows/SDL_windowshaptic_c.h	Wed Jul 08 17:28:34 2020 +0200
     2.3 @@ -50,6 +50,7 @@
     2.4  /*
     2.5   * Haptic system effect data.
     2.6   */
     2.7 +#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
     2.8  struct haptic_hweffect
     2.9  {
    2.10  #if SDL_HAPTIC_DINPUT
    2.11 @@ -60,6 +61,7 @@
    2.12      XINPUT_VIBRATION vibration;
    2.13  #endif
    2.14  };
    2.15 +#endif
    2.16  
    2.17  /*
    2.18  * List of available haptic devices.
     3.1 --- a/src/joystick/windows/SDL_windowsjoystick.c	Sun Jul 05 22:33:10 2020 +0300
     3.2 +++ b/src/joystick/windows/SDL_windowsjoystick.c	Wed Jul 08 17:28:34 2020 +0200
     3.3 @@ -359,9 +359,13 @@
     3.4          JoyStick_DeviceData *pListNext = NULL;
     3.5  
     3.6          if (pCurList->bXInputDevice) {
     3.7 +#if SDL_HAPTIC_XINPUT
     3.8              SDL_XINPUT_MaybeRemoveDevice(pCurList->XInputUserId);
     3.9 +#endif
    3.10          } else {
    3.11 +#if SDL_HAPTIC_DINPUT
    3.12              SDL_DINPUT_MaybeRemoveDevice(&pCurList->dxdevice);
    3.13 +#endif
    3.14          }
    3.15  
    3.16          SDL_PrivateJoystickRemoved(pCurList->nInstanceID);
    3.17 @@ -380,9 +384,13 @@
    3.18          while (pNewJoystick) {
    3.19              if (pNewJoystick->send_add_event) {
    3.20                  if (pNewJoystick->bXInputDevice) {
    3.21 +#if SDL_HAPTIC_XINPUT
    3.22                      SDL_XINPUT_MaybeAddDevice(pNewJoystick->XInputUserId);
    3.23 +#endif
    3.24                  } else {
    3.25 +#if SDL_HAPTIC_DINPUT
    3.26                      SDL_DINPUT_MaybeAddDevice(&pNewJoystick->dxdevice);
    3.27 +#endif
    3.28                  }
    3.29  
    3.30                  SDL_PrivateJoystickAdded(pNewJoystick->nInstanceID);