Skip to content

Commit

Permalink
cmake: Fix building with -DSDL_HAPTIC=Off
Browse files Browse the repository at this point in the history
  • Loading branch information
DomGries committed Jul 8, 2020
1 parent fe97f01 commit b162629
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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()


Expand Down
2 changes: 2 additions & 0 deletions src/haptic/windows/SDL_windowshaptic_c.h
Expand Up @@ -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
Expand All @@ -60,6 +61,7 @@ struct haptic_hweffect
XINPUT_VIBRATION vibration;
#endif
};
#endif

/*
* List of available haptic devices.
Expand Down
8 changes: 8 additions & 0 deletions src/joystick/windows/SDL_windowsjoystick.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit b162629

Please sign in to comment.