-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
sdl2.26-macos-ios.diff
276 lines (251 loc) · 9.68 KB
/
sdl2.26-macos-ios.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index 6db16eb4c..41cb509bf 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -206,7 +206,7 @@
#define SDL_POWER_UIKIT 1
/* enable iPhone keyboard support */
-#define SDL_IPHONE_KEYBOARD 1
+#define SDL_IPHONE_KEYBOARD 0
/* enable iOS extended launch screen */
#define SDL_IPHONE_LAUNCHSCREEN 1
diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 994b6a6db..b332e1332 100644
--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -887,8 +887,8 @@ SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, S
event.type = SDL_MOUSEWHEEL;
event.wheel.windowID = mouse->focus ? mouse->focus->id : 0;
event.wheel.which = mouseID;
- event.wheel.x = integral_x;
- event.wheel.y = integral_y;
+ event.wheel.x = x; //integral_x;
+ event.wheel.y = y; //integral_y;
event.wheel.preciseX = x;
event.wheel.preciseY = y;
event.wheel.direction = (Uint32)direction;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 0809706c2..6a39fe81c 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -3180,6 +3180,23 @@ void
SDL_OnWindowFocusGained(SDL_Window * window)
{
SDL_Mouse *mouse = SDL_GetMouse();
+
+ /* Move the window to the end of the list of windows so it'll be activated/restored
+ last when restoring app to foreground. */
+ if (window->next) {
+ window->next->prev = window->prev;
+ }
+ if (window->prev) {
+ window->prev->next = window->next;
+ } else {
+ _this->windows = window->next;
+ }
+ window->next = _this->windows;
+ if (_this->windows) {
+ _this->windows->prev = window;
+ }
+ _this->windows = window;
+ window->prev = NULL;
if (window->gamma && _this->SetWindowGammaRamp) {
_this->SetWindowGammaRamp(_this, window, window->gamma);
diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c
index 3424a8254..08ae827dc 100644
--- a/src/video/android/SDL_androidevents.c
+++ b/src/video/android/SDL_androidevents.c
@@ -176,10 +176,12 @@ Android_PumpEvents_Blocking(_THIS)
}
}
+ /* Doesn't actually seem to work ??
if ( aaudio_DetectBrokenPlayState() ) {
aaudio_PauseDevices();
aaudio_ResumeDevices();
}
+ */
}
void
diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m
index da5ffac69..a1a63d6ba 100644
--- a/src/video/cocoa/SDL_cocoamouse.m
+++ b/src/video/cocoa/SDL_cocoamouse.m
@@ -520,10 +520,16 @@ + (NSCursor *)invisibleCursor
}
mouseID = mouse->mouseID;
- x = -[event deltaX];
- y = [event deltaY];
+ x = -[event scrollingDeltaX];
+ y = [event scrollingDeltaY];
direction = SDL_MOUSEWHEEL_NORMAL;
+ /* HACK: Make a distinction between precise and imprecise scrolling.
+ Trackpad seems to be mouseID 0. */
+ if (![event hasPreciseScrollingDeltas]) {
+ mouseID = 1;
+ }
+
if ([event isDirectionInvertedFromDevice] == YES) {
direction = SDL_MOUSEWHEEL_FLIPPED;
}
diff --git a/src/video/cocoa/SDL_cocoawindow.h b/src/video/cocoa/SDL_cocoawindow.h
index 18f7d8587..1329a90ab 100644
--- a/src/video/cocoa/SDL_cocoawindow.h
+++ b/src/video/cocoa/SDL_cocoawindow.h
@@ -115,6 +115,8 @@ typedef enum
/* Touch event handling */
-(void) handleTouches:(NSTouchPhase) phase withEvent:(NSEvent*) theEvent;
+-(void) syncMouseButtonAndKeyboardModifierState;
+
@end
/* *INDENT-ON* */
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index c73827656..786f288a2 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1273,6 +1273,25 @@ - (void)otherMouseDown:(NSEvent *)theEvent
[self mouseDown:theEvent];
}
+- (void)syncMouseButtonAndKeyboardModifierState {
+ SDL_Mouse *mouse = SDL_GetMouse();
+ if (mouse) {
+ for (int i = 0; i < mouse->num_sources; i++) {
+ if (mouse->sources[i].mouseID == mouse->mouseID) {
+ mouse->sources[i].buttonstate = 0;
+ }
+ }
+ }
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT);
+ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT);
+}
+
- (void)mouseUp:(NSEvent *)theEvent
{
SDL_Mouse *mouse = SDL_GetMouse();
diff --git a/src/video/uikit/SDL_uikitappdelegate.h b/src/video/uikit/SDL_uikitappdelegate.h
index ee2b5b6a8..8a7f81f62 100644
--- a/src/video/uikit/SDL_uikitappdelegate.h
+++ b/src/video/uikit/SDL_uikitappdelegate.h
@@ -34,6 +34,7 @@
+ (id)sharedAppDelegate;
+ (NSString *)getAppDelegateClassName;
+- (NSString *)getLaunchOptionsURL;
- (void)hideLaunchScreen;
/* This property is marked as optional, and is only intended to be used when
diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m
index 3186cc6e8..dfa6c9307 100644
--- a/src/video/uikit/SDL_uikitappdelegate.m
+++ b/src/video/uikit/SDL_uikitappdelegate.m
@@ -25,6 +25,7 @@
#include "../SDL_sysvideo.h"
#include "SDL_hints.h"
#include "SDL_system.h"
+#include "SDL_timer.h"
#include "SDL_main.h"
#import "SDL_uikitappdelegate.h"
@@ -181,6 +182,8 @@ - (NSUInteger)supportedInterfaceOrientations;
@end
+static NSString *launchOptionsURL;
+
@implementation SDLLaunchScreenController
- (instancetype)init
@@ -364,6 +367,11 @@ + (NSString *)getAppDelegateClassName
return @"SDLUIKitDelegate";
}
+- (NSString *)getLaunchOptionsURL
+{
+ return launchOptionsURL;
+}
+
- (void)hideLaunchScreen
{
UIWindow *window = launchWindow;
@@ -387,7 +395,7 @@ - (void)postFinishLaunch
{
/* Hide the launch screen the next time the run loop is run. SDL apps will
* have a chance to load resources while the launch screen is still up. */
- [self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0];
+ //[self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0];
/* run the user's application, passing argc and argv */
SDL_iPhoneSetEventPump(SDL_TRUE);
@@ -421,6 +429,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
/* tvOS only uses a plain launch image. */
#if !TARGET_OS_TV
+
+ NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
+ if (url != nil) {
+ launchOptionsURL = [url absoluteString];
+ }
+
screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
if (screenname) {
@@ -428,7 +442,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
/* The launch storyboard is actually a nib in some older versions of
* Xcode. We'll try to load it as a storyboard first, as it's more
* modern. */
- UIStoryboard *storyboard = [UIStoryboard storyboardWithName:screenname bundle:bundle];
+ UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:bundle];
__auto_type storyboardVc = [storyboard instantiateInitialViewController];
vc = [[SDLLaunchStoryboardViewController alloc] initWithStoryboardViewController:storyboardVc];
}
diff --git a/src/video/uikit/SDL_uikitviewcontroller.h b/src/video/uikit/SDL_uikitviewcontroller.h
index 2e64a5279..256be3073 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.h
+++ b/src/video/uikit/SDL_uikitviewcontroller.h
@@ -58,10 +58,13 @@
#if !TARGET_OS_TV
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)prefersStatusBarHidden;
+- (void)setStatusStyle:(UIStatusBarStyle)style;
+- (UIStatusBarStyle)preferredStatusBarStyle;
- (BOOL)prefersHomeIndicatorAutoHidden;
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures;
@property (nonatomic, assign) int homeIndicatorHidden;
+@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
#endif
#if SDL_IPHONE_KEYBOARD
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index ee7ee83b0..f3cda52c8 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -101,6 +101,7 @@ - (instancetype)initWithSDLWindow:(SDL_Window *)_window
#endif
#if !TARGET_OS_TV
+ self.statusBarStyle = UIStatusBarStyleDefault;
SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR,
SDL_HideHomeIndicatorHintChanged,
(__bridge void *) self);
@@ -219,6 +220,17 @@ - (BOOL)prefersHomeIndicatorAutoHidden
return hidden;
}
+- (void)setStatusStyle:(UIStatusBarStyle)style
+{
+ self.statusBarStyle = style;
+ [self setNeedsStatusBarAppearanceUpdate];
+}
+
+- (UIStatusBarStyle)preferredStatusBarStyle
+{
+ return self.statusBarStyle;
+}
+
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
if (self.homeIndicatorHidden >= 0) {
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index 7b8dfff56..dc3c4810f 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -295,7 +295,7 @@ - (void)layoutSubviews
viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen);
#endif /* !TARGET_OS_TV */
-#ifdef SDL_IPHONE_KEYBOARD
+#if SDL_IPHONE_KEYBOARD
/* Make sure the view is offset correctly when the keyboard is visible. */
[viewcontroller updateKeyboard];
#endif