diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-19 10:43:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-19 10:43:15 +0300 |
commit | ba425fa4038580fa71bb944e55fedb04238d7197 (patch) | |
tree | a51cb6cb1bcdcb455719799cfc3f448d643f5249 | |
parent | 4b7d2f8978881b8a01f4b37ce33486dfa6484d1c (diff) |
iOS: Updated SDL patch
The SDL patch now contains the macOS scroll event change and, as a new addition, iOS status bar appearance control via the SDL view controller.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | sdl2-macos-ios.diff | 85 | ||||
-rw-r--r-- | sdl2-macos-mouse-scrolling.diff | 36 |
3 files changed, 86 insertions, 37 deletions
@@ -73,7 +73,7 @@ When using OpenSSL 1.1.1 from Homebrew, you must add its pkgconfig path to your | |||
73 | 73 | ||
74 | export PKG_CONFIG_PATH=/opt/homebrew/Cellar/openssl@1.1/1.1.1i/lib/pkgconfig | 74 | export PKG_CONFIG_PATH=/opt/homebrew/Cellar/openssl@1.1/1.1.1i/lib/pkgconfig |
75 | 75 | ||
76 | Also, SDL's trackpad scrolling behavior on macOS is not optimal for regular GUI apps because it emulates a physical mouse wheel. This may change in a future release of SDL, but at least in 2.0.14 (and earlier) a [small patch](https://git.skyjake.fi/gemini/lagrange/raw/branch/dev/sdl2-macos-mouse-scrolling.diff) is required to allow momentum scrolling to come through as single-pixel mouse wheel events. Note that SDL comes with an Xcode project; use the "Shared Library" target and check that you are doing a Release build. | 76 | Also, SDL's trackpad scrolling behavior on macOS is not optimal for regular GUI apps because it emulates a physical mouse wheel. This may change in a future release of SDL, but at least in 2.0.14 (and earlier) a [small patch](https://git.skyjake.fi/gemini/lagrange/raw/branch/dev/sdl2-macos-ios.diff) is required to allow momentum scrolling to come through as single-pixel mouse wheel events. Note that SDL comes with an Xcode project; use the "Shared Library" target and check that you are doing a Release build. |
77 | 77 | ||
78 | ### Compiling on Windows | 78 | ### Compiling on Windows |
79 | 79 | ||
diff --git a/sdl2-macos-ios.diff b/sdl2-macos-ios.diff new file mode 100644 index 00000000..04d0f2e5 --- /dev/null +++ b/sdl2-macos-ios.diff | |||
@@ -0,0 +1,85 @@ | |||
1 | Only in SDL2-2.0.14/src: .DS_Store | ||
2 | diff -ru SDL2-2.0.14-original/src/events/SDL_mouse.c SDL2-2.0.14/src/events/SDL_mouse.c | ||
3 | --- SDL2-2.0.14-original/src/events/SDL_mouse.c 2020-12-21 19:44:36.000000000 +0200 | ||
4 | +++ SDL2-2.0.14/src/events/SDL_mouse.c 2021-01-06 18:31:18.000000000 +0200 | ||
5 | @@ -647,8 +647,8 @@ | ||
6 | event.wheel.preciseX = x; | ||
7 | event.wheel.preciseY = y; | ||
8 | #endif | ||
9 | - event.wheel.x = integral_x; | ||
10 | - event.wheel.y = integral_y; | ||
11 | + event.wheel.x = x; //integral_x; | ||
12 | + event.wheel.y = y; //integral_y; | ||
13 | event.wheel.direction = (Uint32)direction; | ||
14 | posted = (SDL_PushEvent(&event) > 0); | ||
15 | } | ||
16 | Only in SDL2-2.0.14/src/video: .DS_Store | ||
17 | diff -ru SDL2-2.0.14-original/src/video/cocoa/SDL_cocoamouse.m SDL2-2.0.14/src/video/cocoa/SDL_cocoamouse.m | ||
18 | --- SDL2-2.0.14-original/src/video/cocoa/SDL_cocoamouse.m 2020-12-21 19:44:36.000000000 +0200 | ||
19 | +++ SDL2-2.0.14/src/video/cocoa/SDL_cocoamouse.m 2021-01-06 18:31:18.000000000 +0200 | ||
20 | @@ -423,10 +423,16 @@ | ||
21 | } | ||
22 | |||
23 | SDL_MouseID mouseID = mouse->mouseID; | ||
24 | - CGFloat x = -[event deltaX]; | ||
25 | - CGFloat y = [event deltaY]; | ||
26 | + CGFloat x = -[event scrollingDeltaX]; | ||
27 | + CGFloat y = [event scrollingDeltaY]; | ||
28 | SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL; | ||
29 | |||
30 | + /* HACK: Make a distinction between precise and imprecise scrolling. | ||
31 | + Trackpad seems to be mouseID 0. */ | ||
32 | + if (![event hasPreciseScrollingDeltas]) { | ||
33 | + mouseID = 1; | ||
34 | + } | ||
35 | + | ||
36 | if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) { | ||
37 | if ([event isDirectionInvertedFromDevice] == YES) { | ||
38 | direction = SDL_MOUSEWHEEL_FLIPPED; | ||
39 | Only in SDL2-2.0.14/src/video/cocoa: SDL_cocoamouse.m.orig | ||
40 | diff -ru SDL2-2.0.14-original/src/video/uikit/SDL_uikitviewcontroller.h SDL2-2.0.14/src/video/uikit/SDL_uikitviewcontroller.h | ||
41 | --- SDL2-2.0.14-original/src/video/uikit/SDL_uikitviewcontroller.h 2020-12-21 19:44:36.000000000 +0200 | ||
42 | +++ SDL2-2.0.14/src/video/uikit/SDL_uikitviewcontroller.h 2021-05-17 13:11:13.000000000 +0300 | ||
43 | @@ -58,10 +58,13 @@ | ||
44 | #if !TARGET_OS_TV | ||
45 | - (NSUInteger)supportedInterfaceOrientations; | ||
46 | - (BOOL)prefersStatusBarHidden; | ||
47 | +- (void)setStatusStyle:(UIStatusBarStyle)style; | ||
48 | +- (UIStatusBarStyle)preferredStatusBarStyle; | ||
49 | - (BOOL)prefersHomeIndicatorAutoHidden; | ||
50 | - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures; | ||
51 | |||
52 | @property (nonatomic, assign) int homeIndicatorHidden; | ||
53 | +@property (nonatomic, assign) UIStatusBarStyle statusBarStyle; | ||
54 | #endif | ||
55 | |||
56 | #if SDL_IPHONE_KEYBOARD | ||
57 | diff -ru SDL2-2.0.14-original/src/video/uikit/SDL_uikitviewcontroller.m SDL2-2.0.14/src/video/uikit/SDL_uikitviewcontroller.m | ||
58 | --- SDL2-2.0.14-original/src/video/uikit/SDL_uikitviewcontroller.m 2020-12-21 19:44:36.000000000 +0200 | ||
59 | +++ SDL2-2.0.14/src/video/uikit/SDL_uikitviewcontroller.m 2021-05-17 13:11:58.000000000 +0300 | ||
60 | @@ -104,6 +104,7 @@ | ||
61 | #endif | ||
62 | |||
63 | #if !TARGET_OS_TV | ||
64 | + self.statusBarStyle = UIStatusBarStyleDefault; | ||
65 | SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, | ||
66 | SDL_HideHomeIndicatorHintChanged, | ||
67 | (__bridge void *) self); | ||
68 | @@ -229,6 +230,17 @@ | ||
69 | return hidden; | ||
70 | } | ||
71 | |||
72 | +- (void)setStatusStyle:(UIStatusBarStyle)style | ||
73 | +{ | ||
74 | + self.statusBarStyle = style; | ||
75 | + [self setNeedsStatusBarAppearanceUpdate]; | ||
76 | +} | ||
77 | + | ||
78 | +- (UIStatusBarStyle)preferredStatusBarStyle | ||
79 | +{ | ||
80 | + return self.statusBarStyle; | ||
81 | +} | ||
82 | + | ||
83 | - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures | ||
84 | { | ||
85 | if (self.homeIndicatorHidden >= 0) { | ||
diff --git a/sdl2-macos-mouse-scrolling.diff b/sdl2-macos-mouse-scrolling.diff deleted file mode 100644 index e2f30c24..00000000 --- a/sdl2-macos-mouse-scrolling.diff +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | diff -r 4f06c06b6d19 src/events/SDL_mouse.c | ||
2 | --- a/src/events/SDL_mouse.c Wed Aug 05 15:28:51 2020 +0200 | ||
3 | +++ b/src/events/SDL_mouse.c Tue Nov 10 12:16:06 2020 +0200 | ||
4 | @@ -642,8 +642,8 @@ | ||
5 | event.wheel.preciseX = x; | ||
6 | event.wheel.preciseY = y; | ||
7 | #endif | ||
8 | - event.wheel.x = integral_x; | ||
9 | - event.wheel.y = integral_y; | ||
10 | + event.wheel.x = x; //integral_x; | ||
11 | + event.wheel.y = y; //integral_y; | ||
12 | event.wheel.direction = (Uint32)direction; | ||
13 | posted = (SDL_PushEvent(&event) > 0); | ||
14 | } | ||
15 | diff -r 4f06c06b6d19 src/video/cocoa/SDL_cocoamouse.m | ||
16 | --- a/src/video/cocoa/SDL_cocoamouse.m Wed Aug 05 15:28:51 2020 +0200 | ||
17 | +++ b/src/video/cocoa/SDL_cocoamouse.m Tue Nov 10 12:16:06 2020 +0200 | ||
18 | @@ -424,10 +424,16 @@ | ||
19 | } | ||
20 | |||
21 | SDL_MouseID mouseID = mouse->mouseID; | ||
22 | - CGFloat x = -[event deltaX]; | ||
23 | - CGFloat y = [event deltaY]; | ||
24 | + CGFloat x = -[event scrollingDeltaX]; | ||
25 | + CGFloat y = [event scrollingDeltaY]; | ||
26 | SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL; | ||
27 | |||
28 | + /* HACK: Make a distinction between precise and imprecise scrolling. | ||
29 | + Trackpad seems to be mouseID 0. */ | ||
30 | + if (![event hasPreciseScrollingDeltas]) { | ||
31 | + mouseID = 1; | ||
32 | + } | ||
33 | + | ||
34 | if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) { | ||
35 | if ([event isDirectionInvertedFromDevice] == YES) { | ||
36 | direction = SDL_MOUSEWHEEL_FLIPPED; | ||