Skip to content

Commit

Permalink
Enable AppleMomentumScrollSupported on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Benau committed Nov 12, 2023
1 parent bd245e1 commit 8cd6a23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/irrlicht/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
5 changes: 5 additions & 0 deletions lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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())
{
Expand Down
6 changes: 6 additions & 0 deletions lib/irrlicht/source/Irrlicht/MacOS.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <AppKit/AppKit.h>

extern "C" void enable_momentum_scroll()
{
[[NSUserDefaults standardUserDefaults] setBool: YES forKey: @"AppleMomentumScrollSupported"];
}

0 comments on commit 8cd6a23

Please sign in to comment.