|
@@ -41,65 +41,53 @@
|
|
|
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
|
|
-@implementation SDL_uikitwindow
|
|
|
|
|
|
-- (void)layoutSubviews
|
|
|
-{
|
|
|
- [super layoutSubviews];
|
|
|
-
|
|
|
- /* This seems to be needed on iOS 8, otherwise the window's frame is put in
|
|
|
- * an unexpected position when the screen or device is rotated.
|
|
|
- * FIXME: is there a better solution to that problem than this ugly hack?
|
|
|
- */
|
|
|
- self.frame = self.screen.bounds;
|
|
|
-}
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@implementation SDL_WindowData
|
|
|
-
|
|
|
-@synthesize uiwindow;
|
|
|
-@synthesize view;
|
|
|
-@synthesize viewcontroller;
|
|
|
|
|
|
-@end
|
|
|
|
|
|
-
|
|
|
-static int SetupWindowData(_THIS, SDL_Window *window, SDL_uikitwindow *uiwindow, SDL_bool created)
|
|
|
+static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
|
|
|
{
|
|
|
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
|
|
- SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata;
|
|
|
+ SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
|
|
+ SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
|
|
+ SDL_WindowData *data;
|
|
|
|
|
|
/* Allocate the window data */
|
|
|
- SDL_WindowData *data = [[SDL_WindowData alloc] init];
|
|
|
+ data = (SDL_WindowData *)SDL_malloc(sizeof(*data));
|
|
|
if (!data) {
|
|
|
return SDL_OutOfMemory();
|
|
|
}
|
|
|
-
|
|
|
- data.uiwindow = uiwindow;
|
|
|
+ data->uiwindow = uiwindow;
|
|
|
+ data->viewcontroller = nil;
|
|
|
+ data->view = nil;
|
|
|
|
|
|
/* Fill in the SDL window with the window data */
|
|
|
{
|
|
|
- CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen);
|
|
|
+ window->x = 0;
|
|
|
+ window->y = 0;
|
|
|
|
|
|
- /* Get frame dimensions */
|
|
|
- int width = (int) frame.size.width;
|
|
|
- int height = (int) frame.size.height;
|
|
|
+ CGRect bounds;
|
|
|
+ if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
|
|
+ bounds = [displaydata->uiscreen bounds];
|
|
|
+ } else {
|
|
|
+ bounds = [displaydata->uiscreen applicationFrame];
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Get frame dimensions in pixels */
|
|
|
+ int width = (int)(bounds.size.width * displaymodedata->scale);
|
|
|
+ int height = (int)(bounds.size.height * displaymodedata->scale);
|
|
|
|
|
|
/* Make sure the width/height are oriented correctly */
|
|
|
- if (UIKit_IsDisplayLandscape(displaydata.uiscreen) != (width > height)) {
|
|
|
+ if (UIKit_IsDisplayLandscape(displaydata->uiscreen) != (width > height)) {
|
|
|
int temp = width;
|
|
|
width = height;
|
|
|
height = temp;
|
|
|
}
|
|
|
|
|
|
- window->x = 0;
|
|
|
- window->y = 0;
|
|
|
window->w = width;
|
|
|
window->h = height;
|
|
|
}
|
|
|
|
|
|
- window->driverdata = (void *) CFBridgingRetain(data);
|
|
|
+ window->driverdata = data;
|
|
|
|
|
|
/* only one window on iOS, always shown */
|
|
|
window->flags &= ~SDL_WINDOW_HIDDEN;
|
|
@@ -108,7 +96,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, SDL_uikitwindow *uiwindow,
|
|
|
* This is only set if the window is on the main screen. Other screens
|
|
|
* just force the window to have the borderless flag.
|
|
|
*/
|
|
|
- if (displaydata.uiscreen == [UIScreen mainScreen]) {
|
|
|
+ if (displaydata->uiscreen == [UIScreen mainScreen]) {
|
|
|
window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */
|
|
|
|
|
|
/* This was setup earlier for our window, and in iOS 7 is controlled by the view, not the application
|
|
@@ -128,8 +116,10 @@ static int SetupWindowData(_THIS, SDL_Window *window, SDL_uikitwindow *uiwindow,
|
|
|
* device orientation changes. This will trigger resize events, if
|
|
|
* appropriate.
|
|
|
*/
|
|
|
- data.viewcontroller = [[SDL_uikitviewcontroller alloc] initWithSDLWindow:window];
|
|
|
- data.viewcontroller.title = @"SDL App"; /* !!! FIXME: hook up SDL_SetWindowTitle() */
|
|
|
+ SDL_uikitviewcontroller *controller;
|
|
|
+ controller = [SDL_uikitviewcontroller alloc];
|
|
|
+ data->viewcontroller = [controller initWithSDLWindow:window];
|
|
|
+ [data->viewcontroller setTitle:@"SDL App"]; /* !!! FIXME: hook up SDL_SetWindowTitle() */
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -137,118 +127,105 @@ static int SetupWindowData(_THIS, SDL_Window *window, SDL_uikitwindow *uiwindow,
|
|
|
int
|
|
|
UIKit_CreateWindow(_THIS, SDL_Window *window)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
|
|
- SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
|
|
|
- const BOOL external = ([UIScreen mainScreen] != data.uiscreen);
|
|
|
- const CGSize origsize = [[data.uiscreen currentMode] size];
|
|
|
-
|
|
|
- /* SDL currently puts this window at the start of display's linked list. We rely on this. */
|
|
|
- SDL_assert(_this->windows == window);
|
|
|
-
|
|
|
- /* We currently only handle a single window per display on iOS */
|
|
|
- if (window->next != NULL) {
|
|
|
- return SDL_SetError("Only one window allowed per display.");
|
|
|
- }
|
|
|
-
|
|
|
- /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the
|
|
|
- * user, so it's in standby), try to force the display to a resolution
|
|
|
- * that most closely matches the desired window size.
|
|
|
- */
|
|
|
- if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
|
|
|
- if (display->num_display_modes == 0) {
|
|
|
- _this->GetDisplayModes(_this, display);
|
|
|
- }
|
|
|
+ SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
|
|
+ SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
|
|
|
+ const BOOL external = ([UIScreen mainScreen] != data->uiscreen);
|
|
|
+ const CGSize origsize = [[data->uiscreen currentMode] size];
|
|
|
|
|
|
- int i;
|
|
|
- const SDL_DisplayMode *bestmode = NULL;
|
|
|
- for (i = display->num_display_modes; i >= 0; i--) {
|
|
|
- const SDL_DisplayMode *mode = &display->display_modes[i];
|
|
|
- if ((mode->w >= window->w) && (mode->h >= window->h))
|
|
|
- bestmode = mode;
|
|
|
- }
|
|
|
+ /* SDL currently puts this window at the start of display's linked list. We rely on this. */
|
|
|
+ SDL_assert(_this->windows == window);
|
|
|
|
|
|
- if (bestmode) {
|
|
|
- SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)bestmode->driverdata;
|
|
|
- [data.uiscreen setCurrentMode:modedata.uiscreenmode];
|
|
|
+ /* We currently only handle a single window per display on iOS */
|
|
|
+ if (window->next != NULL) {
|
|
|
+ return SDL_SetError("Only one window allowed per display.");
|
|
|
+ }
|
|
|
|
|
|
- /* desktop_mode doesn't change here (the higher level will
|
|
|
- * use it to set all the screens back to their defaults
|
|
|
- * upon window destruction, SDL_Quit(), etc.
|
|
|
- */
|
|
|
- display->current_mode = *bestmode;
|
|
|
- }
|
|
|
+ /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the
|
|
|
+ * user, so it's in standby), try to force the display to a resolution
|
|
|
+ * that most closely matches the desired window size.
|
|
|
+ */
|
|
|
+ if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
|
|
|
+ if (display->num_display_modes == 0) {
|
|
|
+ _this->GetDisplayModes(_this, display);
|
|
|
}
|
|
|
|
|
|
- if (data.uiscreen == [UIScreen mainScreen]) {
|
|
|
- NSUInteger orientations = UIKit_GetSupportedOrientations(window);
|
|
|
- UIApplication *app = [UIApplication sharedApplication];
|
|
|
+ int i;
|
|
|
+ const SDL_DisplayMode *bestmode = NULL;
|
|
|
+ for (i = display->num_display_modes; i >= 0; i--) {
|
|
|
+ const SDL_DisplayMode *mode = &display->display_modes[i];
|
|
|
+ if ((mode->w >= window->w) && (mode->h >= window->h))
|
|
|
+ bestmode = mode;
|
|
|
+ }
|
|
|
|
|
|
- if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
|
|
- app.statusBarHidden = YES;
|
|
|
- } else {
|
|
|
- app.statusBarHidden = NO;
|
|
|
- }
|
|
|
+ if (bestmode) {
|
|
|
+ SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)bestmode->driverdata;
|
|
|
+ [data->uiscreen setCurrentMode:modedata->uiscreenmode];
|
|
|
|
|
|
- /* Make sure the screen is using a supported orientation. We do it
|
|
|
- * now so that SetupWindowData assigns the properly oriented width
|
|
|
- * and height to the window's w and h variables.
|
|
|
+ /* desktop_mode doesn't change here (the higher level will
|
|
|
+ * use it to set all the screens back to their defaults
|
|
|
+ * upon window destruction, SDL_Quit(), etc.
|
|
|
*/
|
|
|
- if (UIKit_IsDisplayLandscape(data.uiscreen)) {
|
|
|
- if (!(orientations & UIInterfaceOrientationMaskLandscape)) {
|
|
|
- [app setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!(orientations & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown))) {
|
|
|
- UIInterfaceOrientation orient = UIInterfaceOrientationLandscapeLeft;
|
|
|
-
|
|
|
- if (orientations & UIInterfaceOrientationMaskLandscapeRight) {
|
|
|
- orient = UIInterfaceOrientationLandscapeRight;
|
|
|
- }
|
|
|
-
|
|
|
- [app setStatusBarOrientation:orient animated:NO];
|
|
|
- }
|
|
|
- }
|
|
|
+ display->current_mode = *bestmode;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- /* ignore the size user requested, and make a fullscreen window */
|
|
|
- /* !!! FIXME: can we have a smaller view? */
|
|
|
- SDL_uikitwindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
|
|
|
-
|
|
|
- /* put the window on an external display if appropriate. This implicitly
|
|
|
- * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
|
|
|
- * main display, where we land by default, as that would eat the
|
|
|
- * status bar real estate.
|
|
|
- */
|
|
|
- if (external) {
|
|
|
- [uiwindow setScreen:data.uiscreen];
|
|
|
+ if (data->uiscreen == [UIScreen mainScreen]) {
|
|
|
+ if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
|
|
|
+ [UIApplication sharedApplication].statusBarHidden = YES;
|
|
|
+ } else {
|
|
|
+ [UIApplication sharedApplication].statusBarHidden = NO;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
|
|
|
- return -1;
|
|
|
+ if (!(window->flags & SDL_WINDOW_RESIZABLE)) {
|
|
|
+ if (window->w > window->h) {
|
|
|
+ if (!UIKit_IsDisplayLandscape(data->uiscreen)) {
|
|
|
+ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
|
|
|
+ }
|
|
|
+ } else if (window->w < window->h) {
|
|
|
+ if (UIKit_IsDisplayLandscape(data->uiscreen)) {
|
|
|
+ [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ /* ignore the size user requested, and make a fullscreen window */
|
|
|
+ /* !!! FIXME: can we have a smaller view? */
|
|
|
+ UIWindow *uiwindow = [UIWindow alloc];
|
|
|
+ uiwindow = [uiwindow initWithFrame:[data->uiscreen bounds]];
|
|
|
+
|
|
|
+ /* put the window on an external display if appropriate. This implicitly
|
|
|
+ * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
|
|
|
+ * main display, where we land by default, as that would eat the
|
|
|
+ * status bar real estate.
|
|
|
+ */
|
|
|
+ if (external) {
|
|
|
+ [uiwindow setScreen:data->uiscreen];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
|
|
|
+ [uiwindow release];
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void
|
|
|
UIKit_ShowWindow(_THIS, SDL_Window * window)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- UIWindow *uiwindow = ((__bridge SDL_WindowData *) window->driverdata).uiwindow;
|
|
|
- [uiwindow makeKeyAndVisible];
|
|
|
- }
|
|
|
+ UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
|
|
|
+
|
|
|
+ [uiwindow makeKeyAndVisible];
|
|
|
}
|
|
|
|
|
|
void
|
|
|
UIKit_HideWindow(_THIS, SDL_Window * window)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- UIWindow *uiwindow = ((__bridge SDL_WindowData *) window->driverdata).uiwindow;
|
|
|
- uiwindow.hidden = YES;
|
|
|
- }
|
|
|
+ UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
|
|
|
+
|
|
|
+ uiwindow.hidden = YES;
|
|
|
}
|
|
|
|
|
|
void
|
|
@@ -262,153 +239,91 @@ UIKit_RaiseWindow(_THIS, SDL_Window * window)
|
|
|
_this->GL_MakeCurrent(_this, _this->current_glwin, _this->current_glctx);
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
-UIKit_UpdateWindowBorder(_THIS, SDL_Window * window)
|
|
|
+void
|
|
|
+UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
|
|
{
|
|
|
- SDL_WindowData *windowdata = (__bridge SDL_WindowData *) window->driverdata;
|
|
|
- SDL_uikitviewcontroller *viewcontroller = windowdata.viewcontroller;
|
|
|
- CGRect frame;
|
|
|
+ SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
|
|
|
+ SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
|
|
|
+ UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
|
|
|
|
|
|
- if (windowdata.uiwindow.screen == [UIScreen mainScreen]) {
|
|
|
- if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
|
|
|
- [UIApplication sharedApplication].statusBarHidden = YES;
|
|
|
- } else {
|
|
|
- [UIApplication sharedApplication].statusBarHidden = NO;
|
|
|
- }
|
|
|
-
|
|
|
- /* iOS 7+ won't update the status bar until we tell it to. */
|
|
|
- if ([viewcontroller respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
|
|
|
- [viewcontroller setNeedsStatusBarAppearanceUpdate];
|
|
|
- }
|
|
|
+ if (fullscreen) {
|
|
|
+ [UIApplication sharedApplication].statusBarHidden = YES;
|
|
|
+ } else {
|
|
|
+ [UIApplication sharedApplication].statusBarHidden = NO;
|
|
|
}
|
|
|
|
|
|
- /* Update the view's frame to account for the status bar change. */
|
|
|
- frame = UIKit_ComputeViewFrame(window, windowdata.uiwindow.screen);
|
|
|
-
|
|
|
- windowdata.view.frame = frame;
|
|
|
- [windowdata.view setNeedsLayout];
|
|
|
- [windowdata.view layoutIfNeeded];
|
|
|
+ CGRect bounds;
|
|
|
+ if (fullscreen) {
|
|
|
+ bounds = [displaydata->uiscreen bounds];
|
|
|
+ } else {
|
|
|
+ bounds = [displaydata->uiscreen applicationFrame];
|
|
|
+ }
|
|
|
|
|
|
- /* Get frame dimensions */
|
|
|
- int width = (int) frame.size.width;
|
|
|
- int height = (int) frame.size.height;
|
|
|
+ /* Get frame dimensions in pixels */
|
|
|
+ int width = (int)(bounds.size.width * displaymodedata->scale);
|
|
|
+ int height = (int)(bounds.size.height * displaymodedata->scale);
|
|
|
|
|
|
/* We can pick either width or height here and we'll rotate the
|
|
|
- screen to match, so we pick the closest to what we wanted.
|
|
|
+ screen to match, so we pick the closest to what we wanted.
|
|
|
*/
|
|
|
if (window->w >= window->h) {
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, SDL_max(width, height), SDL_min(width, height));
|
|
|
+ if (width > height) {
|
|
|
+ window->w = width;
|
|
|
+ window->h = height;
|
|
|
+ } else {
|
|
|
+ window->w = height;
|
|
|
+ window->h = width;
|
|
|
+ }
|
|
|
} else {
|
|
|
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, SDL_min(width, height), SDL_max(width, height));
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void
|
|
|
-UIKit_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
|
|
|
-{
|
|
|
- @autoreleasepool {
|
|
|
- UIKit_UpdateWindowBorder(_this, window);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void
|
|
|
-UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
|
|
-{
|
|
|
- @autoreleasepool {
|
|
|
- UIKit_UpdateWindowBorder(_this, window);
|
|
|
+ if (width > height) {
|
|
|
+ window->w = height;
|
|
|
+ window->h = width;
|
|
|
+ } else {
|
|
|
+ window->w = width;
|
|
|
+ window->h = height;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void
|
|
|
UIKit_DestroyWindow(_THIS, SDL_Window * window)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- if (window->driverdata != NULL) {
|
|
|
- CFRelease(window->driverdata);
|
|
|
- }
|
|
|
- }
|
|
|
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
|
|
|
|
|
+ if (data) {
|
|
|
+ [data->viewcontroller release];
|
|
|
+ [data->uiwindow release];
|
|
|
+ SDL_free(data);
|
|
|
+ }
|
|
|
window->driverdata = NULL;
|
|
|
}
|
|
|
|
|
|
SDL_bool
|
|
|
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- UIWindow *uiwindow = ((__bridge SDL_WindowData *) window->driverdata).uiwindow;
|
|
|
+ UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
|
|
|
|
|
|
- if (info->version.major <= SDL_MAJOR_VERSION) {
|
|
|
- info->subsystem = SDL_SYSWM_UIKIT;
|
|
|
- info->info.uikit.window = uiwindow;
|
|
|
- return SDL_TRUE;
|
|
|
- } else {
|
|
|
- SDL_SetError("Application not compiled with SDL %d.%d\n",
|
|
|
- SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
|
|
- return SDL_FALSE;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-NSUInteger
|
|
|
-UIKit_GetSupportedOrientations(SDL_Window * window)
|
|
|
-{
|
|
|
- const char *hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
|
|
|
- NSUInteger orientationMask = 0;
|
|
|
-
|
|
|
- @autoreleasepool {
|
|
|
- if (hint != NULL) {
|
|
|
- NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
|
|
|
-
|
|
|
- if ([orientations containsObject:@"LandscapeLeft"]) {
|
|
|
- orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
|
|
|
- }
|
|
|
- if ([orientations containsObject:@"LandscapeRight"]) {
|
|
|
- orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
|
|
|
- }
|
|
|
- if ([orientations containsObject:@"Portrait"]) {
|
|
|
- orientationMask |= UIInterfaceOrientationMaskPortrait;
|
|
|
- }
|
|
|
- if ([orientations containsObject:@"PortraitUpsideDown"]) {
|
|
|
- orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (orientationMask == 0 && (window->flags & SDL_WINDOW_RESIZABLE)) {
|
|
|
- /* any orientation is okay. */
|
|
|
- orientationMask = UIInterfaceOrientationMaskAll;
|
|
|
- }
|
|
|
-
|
|
|
- if (orientationMask == 0) {
|
|
|
- if (window->w >= window->h) {
|
|
|
- orientationMask |= UIInterfaceOrientationMaskLandscape;
|
|
|
- }
|
|
|
- if (window->h >= window->w) {
|
|
|
- orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /* Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation */
|
|
|
- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
|
|
- orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
|
|
|
- }
|
|
|
+ if (info->version.major <= SDL_MAJOR_VERSION) {
|
|
|
+ info->subsystem = SDL_SYSWM_UIKIT;
|
|
|
+ info->info.uikit.window = uiwindow;
|
|
|
+ return SDL_TRUE;
|
|
|
+ } else {
|
|
|
+ SDL_SetError("Application not compiled with SDL %d.%d\n",
|
|
|
+ SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
|
|
+ return SDL_FALSE;
|
|
|
}
|
|
|
-
|
|
|
- return orientationMask;
|
|
|
}
|
|
|
|
|
|
int
|
|
|
SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam)
|
|
|
{
|
|
|
- @autoreleasepool {
|
|
|
- SDL_WindowData *data = window ? (__bridge SDL_WindowData *)window->driverdata : nil;
|
|
|
-
|
|
|
- if (!data || !data.view) {
|
|
|
- return SDL_SetError("Invalid window or view not set");
|
|
|
- }
|
|
|
+ SDL_WindowData *data = window ? (SDL_WindowData *)window->driverdata : NULL;
|
|
|
|
|
|
- [data.view setAnimationCallback:interval callback:callback callbackParam:callbackParam];
|
|
|
+ if (!data || !data->view) {
|
|
|
+ return SDL_SetError("Invalid window or view not set");
|
|
|
}
|
|
|
|
|
|
+ [data->view setAnimationCallback:interval callback:callback callbackParam:callbackParam];
|
|
|
return 0;
|
|
|
}
|
|
|
|