From 5eb7b023b338125eb519b3b7addee18f31b9923a Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 21 Apr 2020 10:11:41 +0800 Subject: [PATCH] Add SDL2 to iOS --- CMakeLists.txt | 2 +- cmake/Toolchain-ios-xcode.cmake | 8 +++++++- cmake/Toolchain-ios.cmake | 1 + src/input/input_manager.cpp | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94c853d60..16f3f291a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -654,7 +654,7 @@ if(NOT SERVER_ONLY) if(NOT USE_GLES2) target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES}) elseif (IOS) - target_link_libraries(supertuxkart "-framework OpenGLES -framework UIKit -framework CoreMotion -framework Foundation -framework GLKit") + target_link_libraries(supertuxkart "-framework QuartzCore -framework CoreGraphics -framework AVFoundation -framework AudioToolbox -framework Metal -framework GameController -framework OpenGLES -framework UIKit -framework CoreAudio -framework CoreMotion -framework Foundation -framework GLKit") else() target_link_libraries(supertuxkart GLESv2) endif() diff --git a/cmake/Toolchain-ios-xcode.cmake b/cmake/Toolchain-ios-xcode.cmake index 36c27ff22..71b7eb5a7 100644 --- a/cmake/Toolchain-ios-xcode.cmake +++ b/cmake/Toolchain-ios-xcode.cmake @@ -7,7 +7,7 @@ # You can also use -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=xxxxxxxxxx to specify team # Increase every upload to App store -SET(IOS_BUILD_VERSION 10) +SET(IOS_BUILD_VERSION 13) # Get SDK path execute_process(COMMAND xcodebuild -version -sdk iphoneos Path @@ -56,6 +56,8 @@ set(CURL_INCLUDE_DIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING "" set(OPENSSL_CRYPTO_LIBRARY ${DEPS_PATH}/ios_arm64/dependencies/lib/libcrypto.a;${DEPS_PATH}/ios_simulator64/dependencies/lib/libcrypto.a CACHE STRING "") set(OPENSSL_INCLUDE_DIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING "") set(LIBRESOLV_LIBRARY ${CMAKE_OSX_SYSROOT_IOS}/usr/lib/libresolv.tbd;${CMAKE_OSX_SYSROOT_SIMULATOR}/usr/lib/libresolv.tbd CACHE STRING "") +set(SDL2_LIBRARY ${DEPS_PATH}/ios_arm64/dependencies/lib/libSDL2.a;${DEPS_PATH}/ios_simulator64/dependencies/lib/libSDL2.a CACHE STRING "") +set(SDL2_INCLUDEDIR ${DEPS_PATH}/ios_arm64/dependencies/include CACHE STRING "") # Standard config set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "") @@ -92,6 +94,10 @@ set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") +# For archive +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode") + # Fixed variables in iOS STK set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE YES CACHE INTERNAL "") set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO CACHE INTERNAL "") diff --git a/cmake/Toolchain-ios.cmake b/cmake/Toolchain-ios.cmake index 86452cf87..77a4dacd1 100644 --- a/cmake/Toolchain-ios.cmake +++ b/cmake/Toolchain-ios.cmake @@ -20,6 +20,7 @@ SET(CMAKE_FIND_ROOT_PATH ${PROJECT_SOURCE_DIR}/dependencies-ios ${CCTOOLS_PREFIX set(FREETYPE_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/dependencies-ios/include/freetype2) set(CURL_LIBRARY "${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libcurl.a;${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libssl.a") set(PNG_LIBRARY ${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libpng16.a) +set(SDL2_LIBRARY ${PROJECT_SOURCE_DIR}/dependencies-ios/lib/libSDL2.a) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 104b55f75..912847f52 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -88,7 +88,9 @@ InputManager::InputManager() : m_mode(BOOTSTRAP), m_master_player_only = false; m_timer = 0; #ifndef SERVER_ONLY + SDL_SetMainReady(); SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); + SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); if (SDL_Init(SDL_INIT_GAMECONTROLLER) != 0) { Log::error("InputManager", "Unable to initialize SDL: %s",