mirror of https://github.com/encounter/SDL.git
cmake: Detect SDL_JOYSTICK_MFI for macOS
This commit is contained in:
parent
d5813776db
commit
bc409163a8
|
@ -1825,8 +1825,9 @@ elseif(APPLE)
|
|||
endif()
|
||||
|
||||
if(SDL_JOYSTICK)
|
||||
file(GLOB MFI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m)
|
||||
if(IOS OR TVOS)
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
|
||||
set(SDL_JOYSTICK_MFI 1)
|
||||
if(IOS)
|
||||
set(SDL_FRAMEWORK_COREMOTION 1)
|
||||
|
@ -1835,13 +1836,37 @@ elseif(APPLE)
|
|||
set(SDL_FRAMEWORK_COREHAPTICS 1)
|
||||
set(HAVE_SDL_SENSORS 1)
|
||||
else()
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m)
|
||||
# FIXME: add checks for SDL_JOYSTICK_MFI???
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
|
||||
set_source_files_properties(${MFI_JOYSTICK_SOURCES} PROPERTIES COMPILE_FLAGS -fobjc-weak)
|
||||
check_objc_source_compiles("
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <GameController/GameController.h>
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
|
||||
#error GameController framework doesn't work on this configuration
|
||||
#endif
|
||||
#if TARGET_CPU_X86
|
||||
#error GameController framework doesn't work on this configuration
|
||||
#endif
|
||||
int main() {}" HAVE_FRAMEWORK_GAMECONTROLLER)
|
||||
check_objc_source_compiles("
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreHaptics/CoreHaptics.h>
|
||||
int main() {}" HAVE_FRAMEWORK_COREHAPTICS)
|
||||
if(HAVE_FRAMEWORK_GAMECONTROLLER AND HAVE_FRAMEWORK_COREHAPTICS)
|
||||
# Only enable MFI if we also have CoreHaptics to ensure rumble works
|
||||
set(SDL_JOYSTICK_MFI 1)
|
||||
set(SDL_FRAMEWORK_GAMECONTROLLER 1)
|
||||
set(SDL_FRAMEWORK_COREHAPTICS 1)
|
||||
endif()
|
||||
set(SDL_JOYSTICK_IOKIT 1)
|
||||
set(SDL_FRAMEWORK_IOKIT 1)
|
||||
set(SDL_FRAMEWORK_FF 1)
|
||||
endif()
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES} ${MFI_JOYSTICK_SOURCES})
|
||||
set(HAVE_SDL_JOYSTICK TRUE)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue