21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_UIKIT 25 #include "../SDL_sysvideo.h" 35 #include "../../events/SDL_events_c.h" 41 static int forward_argc;
42 static char **forward_argv;
43 static int exit_status;
45 int main(
int argc,
char **argv)
51 forward_argv = (
char **)
malloc((argc+1) *
sizeof(
char *));
52 for (i = 0; i < argc; i++) {
53 forward_argv[i] =
malloc( (strlen(argv[i])+1) *
sizeof(
char));
54 strcpy(forward_argv[i], argv[i]);
56 forward_argv[i] =
NULL;
64 for (i = 0; i < forward_argc; i++) {
65 free(forward_argv[i]);
73 SDL_IdleTimerDisabledChanged(
void *userdata,
const char *
name,
const char *oldValue,
const char *hint)
75 BOOL disable = (hint && *hint !=
'0');
76 [UIApplication sharedApplication].idleTimerDisabled = disable;
82 SDL_LoadLaunchImageNamed(NSString *
name,
int screenh)
84 UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
85 UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom;
88 if (idiom == UIUserInterfaceIdiomPhone && screenh == 568) {
90 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-568h", name]];
91 }
else if (idiom == UIUserInterfaceIdiomPad) {
93 if (UIInterfaceOrientationIsLandscape(curorient)) {
94 if (curorient == UIInterfaceOrientationLandscapeLeft) {
95 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeLeft", name]];
97 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeRight", name]];
100 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Landscape", name]];
103 if (curorient == UIInterfaceOrientationPortraitUpsideDown) {
104 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-PortraitUpsideDown", name]];
107 image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Portrait", name]];
113 image = [UIImage imageNamed:name];
123 - (NSUInteger)supportedInterfaceOrientations;
132 return [
self initWithNibName:nil bundle:[NSBundle mainBundle]];
135 - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
137 if (!(
self = [super initWithNibName:nil bundle:nil])) {
141 NSString *screenname = nibNameOrNil;
142 NSBundle *bundle = nibBundleOrNil;
146 if (screenname && atleastiOS8) {
148 self.view = [bundle loadNibNamed:screenname owner:self options:nil][0];
150 @catch (NSException *exception) {
158 NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"];
159 NSString *imagename = nil;
160 UIImage *image = nil;
162 int screenw = (int)([UIScreen mainScreen].bounds.size.width + 0.5);
163 int screenh = (int)([UIScreen mainScreen].bounds.size.height + 0.5);
166 UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation;
169 if (screenw > screenh) {
178 for (NSDictionary *dict
in launchimages) {
179 NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"];
180 NSString *sizestring = dict[@"UILaunchImageSize"];
189 CGSize
size = CGSizeFromString(sizestring);
190 if ((
int)(size.width + 0.5) != screenw || (
int)(size.height + 0.5) != screenh) {
196 UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
197 NSString *orientstring = dict[@"UILaunchImageOrientation"];
200 if ([orientstring isEqualToString:
@"PortraitUpsideDown"]) {
201 orientmask = UIInterfaceOrientationMaskPortraitUpsideDown;
202 }
else if ([orientstring isEqualToString:
@"Landscape"]) {
203 orientmask = UIInterfaceOrientationMaskLandscape;
204 }
else if ([orientstring isEqualToString:
@"LandscapeLeft"]) {
205 orientmask = UIInterfaceOrientationMaskLandscapeLeft;
206 }
else if ([orientstring isEqualToString:
@"LandscapeRight"]) {
207 orientmask = UIInterfaceOrientationMaskLandscapeRight;
212 if ((orientmask & (1 << curorient)) == 0) {
217 imagename = dict[@"UILaunchImageName"];
221 image = [UIImage imageNamed:imagename];
226 imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"];
229 image = SDL_LoadLaunchImageNamed(imagename, screenh);
233 image = SDL_LoadLaunchImageNamed(
@"Default", screenh);
239 UIImageView *view = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
240 UIImageOrientation imageorient = UIImageOrientationUp;
244 if (UIInterfaceOrientationIsLandscape(curorient)) {
245 if (atleastiOS8 && image.size.width < image.size.height) {
250 if (curorient == UIInterfaceOrientationLandscapeLeft) {
251 imageorient = UIImageOrientationRight;
252 }
else if (curorient == UIInterfaceOrientationLandscapeRight) {
253 imageorient = UIImageOrientationLeft;
255 }
else if (!atleastiOS8 && image.size.width > image.size.height) {
259 if (curorient == UIInterfaceOrientationLandscapeLeft) {
260 imageorient = UIImageOrientationLeft;
261 }
else if (curorient == UIInterfaceOrientationLandscapeRight) {
262 imageorient = UIImageOrientationRight;
269 view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient];
284 - (BOOL)shouldAutorotate
290 - (NSUInteger)supportedInterfaceOrientations
295 return UIInterfaceOrientationMaskAll;
302 UIWindow *launchWindow;
310 return [UIApplication sharedApplication].delegate;
318 return @"SDLUIKitDelegate";
323 UIWindow *
window = launchWindow;
325 if (!window || window.hidden) {
332 [UIView animateWithDuration:0.2 animations:^{
334 } completion:^(BOOL finished) {
339 - (
void)postFinishLaunch
343 [
self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0];
347 exit_status =
SDL_main(forward_argc, forward_argv);
351 launchWindow.hidden = YES;
361 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
363 NSBundle *bundle = [NSBundle mainBundle];
365 #if SDL_IPHONE_LAUNCHSCREEN 372 UIViewController *vc = nil;
373 NSString *screenname = nil;
377 screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"];
384 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:screenname bundle:bundle];
385 vc = [storyboard instantiateInitialViewController];
387 @catch (NSException *exception) {
398 launchWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
402 launchWindow.windowLevel = UIWindowLevelNormal + 1.0;
406 launchWindow.hidden = NO;
408 launchWindow.rootViewController = vc;
413 [[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]];
417 SDL_IdleTimerDisabledChanged,
NULL);
420 [
self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
440 - (
void)setWindow:(UIWindow *)window
446 - (
void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation
452 - (
void)applicationWillTerminate:(UIApplication *)application
457 - (
void)applicationDidReceiveMemoryWarning:(UIApplication *)application
462 - (
void)applicationWillResignActive:(UIApplication*)application
467 - (
void)applicationDidEnterBackground:(UIApplication*)application
472 - (
void)applicationWillEnterForeground:(UIApplication*)application
477 - (
void)applicationDidBecomeActive:(UIApplication*)application
482 - (
void)sendDropFileForURL:(NSURL *)url
484 NSURL *fileURL = url.filePathURL;
485 if (fileURL != nil) {
493 #if TARGET_OS_TV || (defined(__IPHONE_9_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) 495 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,
id> *)options
498 [
self sendDropFileForURL:url];
504 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(
id)annotation
506 [
self sendDropFileForURL:url];
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
void SDL_OnApplicationWillTerminate(void)
void SDL_OnApplicationDidEnterBackground(void)
int SDL_SendDropFile(SDL_Window *window, const char *file)
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void SDL_OnApplicationDidBecomeActive(void)
int SDL_SendDropComplete(SDL_Window *window)
GLuint const GLchar * name
GLint GLint GLsizei width
static SDL_VideoDevice * _this
void SDL_OnApplicationDidReceiveMemoryWarning(void)
NSString * getAppDelegateClassName()
#define SDL_HINT_IDLE_TIMER_DISABLED
A variable controlling whether the idle timer is disabled on iOS.
void SDL_OnApplicationWillResignActive(void)
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
C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])
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
The type used to identify a 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 local 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
#define SDL_AddHintCallback
SDL_VideoDevice * SDL_GetVideoDevice(void)
#define SDL_iPhoneSetEventPump
void SDL_OnApplicationDidChangeStatusBarOrientation(void)
void SDL_OnApplicationWillEnterForeground(void)