cmake: Fix building with -DSDL_HAPTIC=Off
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 33d5055..1bbe2b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -404,6 +404,7 @@ file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/dynapi/*.c
${SDL2_SOURCE_DIR}/src/events/*.c
${SDL2_SOURCE_DIR}/src/file/*.c
+ ${SDL2_SOURCE_DIR}/src/haptic/*.c
${SDL2_SOURCE_DIR}/src/libm/*.c
${SDL2_SOURCE_DIR}/src/locale/*.c
${SDL2_SOURCE_DIR}/src/power/*.c
@@ -878,8 +879,6 @@ if(SDL_HAPTIC)
# Haptic requires some private functions from the joystick subsystem.
message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
endif()
- file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
- set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
endif()
diff --git a/src/haptic/windows/SDL_windowshaptic_c.h b/src/haptic/windows/SDL_windowshaptic_c.h
index 5f00b7e..9048663 100644
--- a/src/haptic/windows/SDL_windowshaptic_c.h
+++ b/src/haptic/windows/SDL_windowshaptic_c.h
@@ -50,6 +50,7 @@ struct haptic_hwdata
/*
* Haptic system effect data.
*/
+#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
struct haptic_hweffect
{
#if SDL_HAPTIC_DINPUT
@@ -60,6 +61,7 @@ struct haptic_hweffect
XINPUT_VIBRATION vibration;
#endif
};
+#endif
/*
* List of available haptic devices.
diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c
index 1b016f2..b008dbc 100644
--- a/src/joystick/windows/SDL_windowsjoystick.c
+++ b/src/joystick/windows/SDL_windowsjoystick.c
@@ -359,9 +359,13 @@ WINDOWS_JoystickDetect(void)
JoyStick_DeviceData *pListNext = NULL;
if (pCurList->bXInputDevice) {
+#if SDL_HAPTIC_XINPUT
SDL_XINPUT_MaybeRemoveDevice(pCurList->XInputUserId);
+#endif
} else {
+#if SDL_HAPTIC_DINPUT
SDL_DINPUT_MaybeRemoveDevice(&pCurList->dxdevice);
+#endif
}
SDL_PrivateJoystickRemoved(pCurList->nInstanceID);
@@ -380,9 +384,13 @@ WINDOWS_JoystickDetect(void)
while (pNewJoystick) {
if (pNewJoystick->send_add_event) {
if (pNewJoystick->bXInputDevice) {
+#if SDL_HAPTIC_XINPUT
SDL_XINPUT_MaybeAddDevice(pNewJoystick->XInputUserId);
+#endif
} else {
+#if SDL_HAPTIC_DINPUT
SDL_DINPUT_MaybeAddDevice(&pNewJoystick->dxdevice);
+#endif
}
SDL_PrivateJoystickAdded(pNewJoystick->nInstanceID);