23 #if SDL_VIDEO_DRIVER_UIKIT
25 #include "../SDL_sysvideo.h"
33 #include "../../events/SDL_events_c.h"
39 static int forward_argc;
40 static char **forward_argv;
41 static int exit_status;
42 static UIWindow *launch_window;
44 int main(
int argc,
char **argv)
47 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
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;
62 for (i = 0; i < forward_argc; i++) {
63 free(forward_argv[i]);
72 SDL_IdleTimerDisabledChanged(
void *userdata,
const char *
name,
const char *oldValue,
const char *hint)
74 BOOL disable = (hint && *hint !=
'0');
75 [UIApplication sharedApplication].idleTimerDisabled = disable;
78 @interface SDL_splashviewcontroller : UIViewController {
80 UIImage *splashPortrait;
81 UIImage *splashLandscape;
84 - (
void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation;
87 @implementation SDL_splashviewcontroller
96 self->splash = [[UIImageView alloc] init];
97 [
self setView:self->splash];
99 CGSize
size = [UIScreen mainScreen].bounds.size;
101 self->splashPortrait = [UIImage imageNamed:[NSString stringWithFormat:@"Default-%dh.png", (int)height]];
102 if (!self->splashPortrait) {
103 self->splashPortrait = [UIImage imageNamed:@"Default.png"];
105 self->splashLandscape = [UIImage imageNamed:@"Default-Landscape.png"];
106 if (!self->splashLandscape && self->splashPortrait) {
107 self->splashLandscape = [[UIImage alloc] initWithCGImage: self->splashPortrait.CGImage
109 orientation: UIImageOrientationRight];
111 if (self->splashPortrait) {
112 [
self->splashPortrait retain];
114 if (self->splashLandscape) {
115 [
self->splashLandscape retain];
118 [
self updateSplashImage:[[UIApplication sharedApplication] statusBarOrientation]];
123 - (NSUInteger)supportedInterfaceOrientations
128 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
131 return orientationMask;
134 - (
BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
136 NSUInteger orientationMask = [
self supportedInterfaceOrientations];
137 return (orientationMask & (1 << orient));
140 - (
void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
142 [
self updateSplashImage:interfaceOrientation];
145 - (
void)updateSplashImage:(UIInterfaceOrientation)interfaceOrientation
149 if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
150 image =
self->splashLandscape;
152 image =
self->splashPortrait;
156 splash.image =
image;
169 return [[UIApplication sharedApplication] delegate];
176 return @"SDLUIKitDelegate";
185 - (
void)postFinishLaunch
189 exit_status =
SDL_main(forward_argc, forward_argv);
194 [launch_window release];
195 launch_window =
NULL;
205 - (
BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
208 launch_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
210 UIViewController *splashViewController = [[SDL_splashviewcontroller alloc] init];
211 launch_window.rootViewController = splashViewController;
212 [launch_window addSubview:splashViewController.view];
213 [launch_window makeKeyAndVisible];
216 [[NSFileManager defaultManager] changeCurrentDirectoryPath: [[NSBundle mainBundle] resourcePath]];
220 SDL_IdleTimerDisabledChanged,
NULL);
223 [
self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0];
228 - (
void)applicationWillTerminate:(UIApplication *)application
233 - (
void)applicationDidReceiveMemoryWarning:(UIApplication *)application
238 - (
void) applicationWillResignActive:(UIApplication*)application
243 for (window = _this->
windows; window != nil; window = window->
next) {
251 - (
void) applicationDidEnterBackground:(UIApplication*)application
256 - (
void) applicationWillEnterForeground:(UIApplication*)application
261 - (
void) applicationDidBecomeActive:(UIApplication*)application
268 for (window = _this->
windows; window != nil; window = window->
next) {
275 - (
BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(
id)annotation
277 NSURL *fileURL = [url filePathURL];
278 if (fileURL != nil) {
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
int main(int argc, char **argv)
DECLSPEC void SDL_SetMainReady(void)
static void init(struct bs2b *bs2b)
EGLSurface EGLint EGLint EGLint EGLint height
EGLImageKHR EGLint * name
DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
GLsizei const GLchar *const * path
static SDL_VideoDevice * _this
NSString * getAppDelegateClassName()
#define SDL_HINT_IDLE_TIMER_DISABLED
A variable controlling whether the idle timer is disabled on iOS.
C_LINKAGE int SDL_main(int argc, char *argv[])
int SDL_SendDropFile(const char *file)
SDL_VideoDevice * SDL_GetVideoDevice(void)
int SDL_SendAppEvent(SDL_EventType eventType)
typedef BOOL(WINAPI *PFNWGLSETSTEREOEMITTERSTATE3DLPROC)(HDC hDC