From 8cd6a231ccdd33dda2a8d297ce1201f0a46ce406 Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 12 Nov 2023 12:56:28 +0800 Subject: [PATCH] Enable AppleMomentumScrollSupported on macOS --- lib/irrlicht/CMakeLists.txt | 10 ++++++++++ lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp | 5 +++++ lib/irrlicht/source/Irrlicht/MacOS.mm | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 lib/irrlicht/source/Irrlicht/MacOS.mm diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt index e7f84cfe8..456886322 100644 --- a/lib/irrlicht/CMakeLists.txt +++ b/lib/irrlicht/CMakeLists.txt @@ -550,6 +550,16 @@ if(IOS) set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES LANGUAGE C) endif() +if (NOT SERVER_ONLY AND APPLE AND NOT IOS) + set(IRRLICHT_SOURCES + ${IRRLICHT_SOURCES} + source/Irrlicht/MacOS.mm) + + set_source_files_properties(source/Irrlicht/MacOS.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti") + set_source_files_properties(source/Irrlicht/MacOS.mm PROPERTIES LANGUAGE C) + +endif() + add_library(stkirrlicht STATIC ${IRRLICHT_SOURCES}) target_link_libraries(stkirrlicht ${ZLIB_LIBRARY}) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index 3cc4abd8a..dd71d0cc5 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -52,6 +52,7 @@ namespace irr } // end namespace irr extern "C" void init_objc(SDL_SysWMinfo* info, float* top, float* bottom, float* left, float* right); +extern "C" void enable_momentum_scroll(); extern "C" int handle_app_event(void* userdata, SDL_Event* event); extern "C" void Android_initDisplayCutout(float* top, float* bottom, float* left, float* right, int* initial_orientation); extern "C" int Android_disablePadding(); @@ -122,6 +123,10 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) // create window if (CreationParams.DriverType != video::EDT_NULL) { +#if defined(_IRR_OSX_PLATFORM_) && !defined(IOS_STK) + enable_momentum_scroll(); +#endif + // create the window, only if we do not use the null device if (!Close && createWindow()) { diff --git a/lib/irrlicht/source/Irrlicht/MacOS.mm b/lib/irrlicht/source/Irrlicht/MacOS.mm new file mode 100644 index 000000000..be6645b45 --- /dev/null +++ b/lib/irrlicht/source/Irrlicht/MacOS.mm @@ -0,0 +1,6 @@ +#import + +extern "C" void enable_momentum_scroll() +{ + [[NSUserDefaults standardUserDefaults] setBool: YES forKey: @"AppleMomentumScrollSupported"]; +}