21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_UIKIT
25 #include "../SDL_sysvideo.h"
34 #include "../../events/SDL_events_c.h"
41 static int forward_argc;
42 static char **forward_argv;
43 static int exit_status;
50 forward_main = mainFunction;
52 forward_argv = (
char **)
malloc((argc+1) *
sizeof(
char *));
53 for (
i = 0;
i < argc;
i++) {
54 forward_argv[i] =
malloc( (strlen(argv[
i])+1) *
sizeof(
char));
55 strcpy(forward_argv[
i], argv[
i]);
57 forward_argv[i] =
NULL;
61 UIApplicationMain(argc, argv, nil, [
SDLUIKitDelegate getAppDelegateClassName]);
65 for (
i = 0;
i < forward_argc;
i++) {
66 free(forward_argv[
i]);
74 SDL_IdleTimerDisabledChanged(
void *userdata,
const char *
name,
const char *oldValue,
const char *hint)
76 BOOL disable = (hint && *hint !=
'0');
77 [UIApplication sharedApplication].idleTimerDisabled = disable;
83 SDL_LoadLaunchImageNamed(NSString *
name,
int screenh)
85 UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
86 UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom;
89 if (idiom == UIUserInterfaceIdiomPhone && screenh == 568) {
91 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-568h", name]];
92 }
else if (idiom == UIUserInterfaceIdiomPad) {
94 if (UIInterfaceOrientationIsLandscape(curorient)) {
95 if (curorient == UIInterfaceOrientationLandscapeLeft) {
96 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeLeft", name]];
98 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeRight", name]];
101 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Landscape", name]];
104 if (curorient == UIInterfaceOrientationPortraitUpsideDown) {
105 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-PortraitUpsideDown", name]];
108 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Portrait", name]];
114 image = [UIImage imageNamed:name];
124 - (NSUInteger)supportedInterfaceOrientations;
133 return [
self initWithNibName:nil bundle:[NSBundle mainBundle]];
136 - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
138 if (!(
self = [super initWithNibName:nil bundle:nil])) {
142 NSString *screenname = nibNameOrNil;
143 NSBundle *bundle = nibBundleOrNil;
147 if (screenname && atleastiOS8) {
149 self.view = [bundle loadNibNamed:screenname owner:self options:nil][0];
151 @catch (NSException *exception) {
159 NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"];
160 NSString *imagename = nil;
161 UIImage *
image = nil;
163 int screenw = (
int)([UIScreen mainScreen].bounds.size.width + 0.5);
164 int screenh = (
int)([UIScreen mainScreen].bounds.size.height + 0.5);
167 UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
170 if (screenw > screenh) {
179 for (NSDictionary *dict
in launchimages) {
180 NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
181 NSString *sizestring = dict[@"UILaunchImageSize"];
190 CGSize
size = CGSizeFromString(sizestring);
191 if ((
int)(
size.width + 0.5) != screenw || (
int)(
size.height + 0.5) != screenh) {
197 UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
198 NSString *orientstring = dict[@"UILaunchImageOrientation"];
201 if ([orientstring isEqualToString:
@"PortraitUpsideDown"]) {
202 orientmask = UIInterfaceOrientationMaskPortraitUpsideDown;
203 }
else if ([orientstring isEqualToString:
@"Landscape"]) {
204 orientmask = UIInterfaceOrientationMaskLandscape;
205 }
else if ([orientstring isEqualToString:
@"LandscapeLeft"]) {
206 orientmask = UIInterfaceOrientationMaskLandscapeLeft;
207 }
else if ([orientstring isEqualToString:
@"LandscapeRight"]) {
208 orientmask = UIInterfaceOrientationMaskLandscapeRight;
213 if ((orientmask & (1 << curorient)) == 0) {
218 imagename = dict[@"UILaunchImageName"];
222 image = [UIImage imageNamed:imagename];
227 imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
230 image = SDL_LoadLaunchImageNamed(imagename, screenh);
234 image = SDL_LoadLaunchImageNamed(
@"Default", screenh);
240 UIImageView *view = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
241 UIImageOrientation imageorient = UIImageOrientationUp;
245 if (UIInterfaceOrientationIsLandscape(curorient)) {
246 if (atleastiOS8 &&
image.size.width <
image.size.height) {
251 if (curorient == UIInterfaceOrientationLandscapeLeft) {
252 imageorient = UIImageOrientationRight;
253 }
else if (curorient == UIInterfaceOrientationLandscapeRight) {
254 imageorient = UIImageOrientationLeft;
256 }
else if (!atleastiOS8 &&
image.size.width >
image.size.height) {
260 if (curorient == UIInterfaceOrientationLandscapeLeft) {
261 imageorient = UIImageOrientationLeft;
262 }
else if (curorient == UIInterfaceOrientationLandscapeRight) {
263 imageorient = UIImageOrientationRight;
270 view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient];
285 - (BOOL)shouldAutorotate
291 - (NSUInteger)supportedInterfaceOrientations
296 return UIInterfaceOrientationMaskAll;
303 UIWindow *launchWindow;
307 + (
id)sharedAppDelegate
311 return [UIApplication sharedApplication].delegate;
314 + (NSString *)getAppDelegateClassName
319 return @"SDLUIKitDelegate";
322 - (
void)hideLaunchScreen
324 UIWindow *
window = launchWindow;
333 [UIView animateWithDuration:0.2 animations:^{
335 } completion:^(BOOL finished) {
337 UIKit_ForceUpdateHomeIndicator();
341 - (
void)postFinishLaunch
345 [
self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0];
349 exit_status = forward_main(forward_argc, forward_argv);
353 launchWindow.hidden = YES;
363 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
365 NSBundle *bundle = [NSBundle mainBundle];
367 #if SDL_IPHONE_LAUNCHSCREEN
374 UIViewController *vc = nil;
375 NSString *screenname = nil;
379 screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
386 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:screenname bundle:bundle];
387 vc = [storyboard instantiateInitialViewController];
389 @catch (NSException *exception) {
400 launchWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
404 launchWindow.windowLevel = UIWindowLevelNormal + 1.0;
408 launchWindow.hidden = NO;
410 launchWindow.rootViewController = vc;
415 [[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]];
419 SDL_IdleTimerDisabledChanged,
NULL);
422 [
self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
435 return data.uiwindow;
442 - (
void)setWindow:(UIWindow *)window
448 - (
void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
454 - (
void)applicationWillTerminate:(UIApplication *)application
459 - (
void)applicationDidReceiveMemoryWarning:(UIApplication *)application
464 - (
void)applicationWillResignActive:(UIApplication*)application
469 - (
void)applicationDidEnterBackground:(UIApplication*)application
474 - (
void)applicationWillEnterForeground:(UIApplication*)application
479 - (
void)applicationDidBecomeActive:(UIApplication*)application
484 - (
void)sendDropFileForURL:(NSURL *)url
486 NSURL *fileURL = url.filePathURL;
487 if (fileURL != nil) {
495 #if TARGET_OS_TV || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0)
497 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,
id> *)options
500 [
self sendDropFileForURL:url];
506 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(
id)annotation
508 [
self sendDropFileForURL:url];
int SDL_SendDropFile(SDL_Window *window, const char *file)
int SDL_SendDropComplete(SDL_Window *window)
#define SDL_OnApplicationDidReceiveMemoryWarning
#define SDL_OnApplicationDidChangeStatusBarOrientation
#define SDL_iPhoneSetEventPump
#define SDL_OnApplicationDidEnterBackground
#define SDL_OnApplicationWillResignActive
#define SDL_OnApplicationDidBecomeActive
#define SDL_OnApplicationWillEnterForeground
#define SDL_AddHintCallback
#define SDL_OnApplicationWillTerminate
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_HINT_IDLE_TIMER_DISABLED
A variable controlling whether the idle timer is disabled on iOS.
int(* SDL_main_func)(int argc, char *argv[])
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei width
GLuint const GLchar * name
SDL_VideoDevice * SDL_GetVideoDevice(void)
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
static SDL_VideoDevice * _this
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
EGLSurface EGLNativeWindowType * window
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld init[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1 beq endif SRC MASK if dst_r_bpp DST_R else add endif PF add sub src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head pixblock_size cache_preload_simple process_pixblock_tail pixinterleave dst_w_basereg irp beq endif process_pixblock_tail_head tst beq irp if pixblock_size chunk_size tst beq pixld_src SRC pixld MASK if DST_R else pixld DST_R endif if src_basereg pixdeinterleave mask_basereg pixdeinterleave dst_r_basereg process_pixblock_head if pixblock_size cache_preload_simple endif process_pixblock_tail pixinterleave dst_w_basereg irp if pixblock_size chunk_size tst beq if DST_W else pixst DST_W else mov ORIG_W endif add lsl if lsl endif if lsl endif lsl endif lsl endif lsl endif subs mov DST_W if regs_shortage str endif bge start_of_loop_label endm macro generate_composite_function
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
The type used to identify a window.
typedef int(__stdcall *FARPROC)()