src/video/uikit/SDL_uikitwindow.m
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 May 2015 06:27:46 -0700
changeset 9619 b94b6d0bff0f
parent 9585 8339700453c6
child 9727 b845f659e015
permissions -rw-r--r--
Updated the copyright year to 2015
slouken@2765
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
slouken@2765
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2765
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2765
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2765
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@2765
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_UIKIT
slouken@6044
    24
slouken@5056
    25
#include "SDL_syswm.h"
slouken@2765
    26
#include "SDL_video.h"
slouken@2765
    27
#include "SDL_mouse.h"
icculus@4446
    28
#include "SDL_assert.h"
tim@5554
    29
#include "SDL_hints.h"
slouken@2765
    30
#include "../SDL_sysvideo.h"
slouken@2765
    31
#include "../SDL_pixels_c.h"
slouken@2765
    32
#include "../../events/SDL_events_c.h"
slouken@2765
    33
slouken@2765
    34
#include "SDL_uikitvideo.h"
slouken@2765
    35
#include "SDL_uikitevents.h"
slouken@6518
    36
#include "SDL_uikitmodes.h"
slouken@2765
    37
#include "SDL_uikitwindow.h"
slouken@2765
    38
#import "SDL_uikitappdelegate.h"
slouken@2765
    39
slime73@9532
    40
#import "SDL_uikitview.h"
slime73@9540
    41
#import "SDL_uikitopenglview.h"
slouken@2765
    42
slouken@2765
    43
#include <Foundation/Foundation.h>
slouken@2765
    44
slime73@9510
    45
@implementation SDL_WindowData
slime73@9510
    46
slime73@9510
    47
@synthesize uiwindow;
slime73@9510
    48
@synthesize viewcontroller;
slime73@9532
    49
@synthesize views;
slime73@9532
    50
slime73@9532
    51
- (instancetype)init
slime73@9532
    52
{
slime73@9532
    53
    if ((self = [super init])) {
slime73@9532
    54
        views = [NSMutableArray new];
slime73@9532
    55
    }
slime73@9532
    56
slime73@9532
    57
    return self;
slime73@9532
    58
}
slime73@9532
    59
slime73@9532
    60
@end
slime73@9532
    61
slime73@9532
    62
@interface SDL_uikitwindow : UIWindow
slime73@9532
    63
slime73@9532
    64
- (void)layoutSubviews;
slime73@9532
    65
slime73@9532
    66
@end
slime73@9532
    67
slime73@9532
    68
@implementation SDL_uikitwindow
slime73@9532
    69
slime73@9532
    70
- (void)layoutSubviews
slime73@9532
    71
{
slime73@9532
    72
    /* Workaround to fix window orientation issues in iOS 8+. */
slime73@9532
    73
    self.frame = self.screen.bounds;
slime73@9532
    74
    [super layoutSubviews];
slime73@9532
    75
}
slime73@9510
    76
slime73@9510
    77
@end
slime73@9510
    78
slime73@9505
    79
slime73@9528
    80
static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
icculus@4446
    81
{
slouken@5246
    82
    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
slime73@9510
    83
    SDL_DisplayData *displaydata = (__bridge SDL_DisplayData *) display->driverdata;
slime73@9532
    84
    SDL_uikitview *view;
slime73@9532
    85
slime73@9532
    86
    CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen);
slime73@9532
    87
    int width  = (int) frame.size.width;
slime73@9532
    88
    int height = (int) frame.size.height;
kees@6001
    89
slime73@9510
    90
    SDL_WindowData *data = [[SDL_WindowData alloc] init];
slouken@2765
    91
    if (!data) {
icculus@7037
    92
        return SDL_OutOfMemory();
slouken@2765
    93
    }
slime73@9510
    94
slime73@9532
    95
    window->driverdata = (void *) CFBridgingRetain(data);
slime73@9532
    96
slime73@9510
    97
    data.uiwindow = uiwindow;
slouken@3685
    98
slime73@9532
    99
    /* only one window on iOS, always shown */
slime73@9532
   100
    window->flags &= ~SDL_WINDOW_HIDDEN;
slouken@6437
   101
slime73@9532
   102
    if (displaydata.uiscreen == [UIScreen mainScreen]) {
slime73@9532
   103
        window->flags |= SDL_WINDOW_INPUT_FOCUS;  /* always has input focus */
slime73@9532
   104
    } else {
slime73@9532
   105
        window->flags &= ~SDL_WINDOW_RESIZABLE;  /* window is NEVER resizable */
slime73@9532
   106
        window->flags &= ~SDL_WINDOW_INPUT_FOCUS;  /* never has input focus */
slime73@9532
   107
        window->flags |= SDL_WINDOW_BORDERLESS;  /* never has a status bar. */
slime73@9532
   108
    }
slime73@9532
   109
slime73@9532
   110
    if (displaydata.uiscreen == [UIScreen mainScreen]) {
slime73@9532
   111
        NSUInteger orients = UIKit_GetSupportedOrientations(window);
slime73@9532
   112
        BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0;
slime73@9532
   113
        BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0;
slouken@6520
   114
slouken@7191
   115
        /* Make sure the width/height are oriented correctly */
slime73@9532
   116
        if ((width > height && !supportsLandscape) || (height > width && !supportsPortrait)) {
slouken@6520
   117
            int temp = width;
slouken@6520
   118
            width = height;
slouken@6520
   119
            height = temp;
slouken@6077
   120
        }
slouken@2765
   121
    }
kees@6001
   122
slime73@9532
   123
    window->x = 0;
slime73@9532
   124
    window->y = 0;
slime73@9532
   125
    window->w = width;
slime73@9532
   126
    window->h = height;
icculus@5520
   127
slime73@9532
   128
    /* The View Controller will handle rotating the view when the device
slime73@9532
   129
     * orientation changes. This will trigger resize events, if appropriate. */
slime73@9532
   130
    data.viewcontroller = [[SDL_uikitviewcontroller alloc] initWithSDLWindow:window];
slouken@2765
   131
slime73@9532
   132
    /* The window will initially contain a generic view so resizes, touch events,
slime73@9532
   133
     * etc. can be handled without an active OpenGL view/context. */
slime73@9532
   134
    view = [[SDL_uikitview alloc] initWithFrame:frame];
slime73@9532
   135
slime73@9532
   136
    /* Sets this view as the controller's view, and adds the view to the window
slime73@9532
   137
     * heirarchy. */
slime73@9532
   138
    [view setSDLWindow:window];
slime73@9532
   139
slime73@9532
   140
    /* Make this window the current mouse focus for touch input */
slime73@9510
   141
    if (displaydata.uiscreen == [UIScreen mainScreen]) {
slime73@9532
   142
        SDL_SetMouseFocus(window);
slime73@9532
   143
        SDL_SetKeyboardFocus(window);
slouken@6511
   144
    }
icculus@5518
   145
slouken@2765
   146
    return 0;
slouken@2765
   147
}
slouken@2765
   148
slouken@5056
   149
int
slouken@5246
   150
UIKit_CreateWindow(_THIS, SDL_Window *window)
slouken@5246
   151
{
slime73@9506
   152
    @autoreleasepool {
slime73@9506
   153
        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
slime73@9510
   154
        SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
slime73@9532
   155
        const CGSize origsize = data.uiscreen.currentMode.size;
icculus@4446
   156
slime73@9506
   157
        /* SDL currently puts this window at the start of display's linked list. We rely on this. */
slime73@9506
   158
        SDL_assert(_this->windows == window);
icculus@4446
   159
slime73@9506
   160
        /* We currently only handle a single window per display on iOS */
slime73@9506
   161
        if (window->next != NULL) {
slime73@9506
   162
            return SDL_SetError("Only one window allowed per display.");
slouken@8891
   163
        }
icculus@4446
   164
slime73@9506
   165
        /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the
slime73@9506
   166
         * user, so it's in standby), try to force the display to a resolution
slime73@9532
   167
         * that most closely matches the desired window size. */
slime73@9506
   168
        if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) {
slime73@9506
   169
            if (display->num_display_modes == 0) {
slime73@9506
   170
                _this->GetDisplayModes(_this, display);
slime73@9506
   171
            }
slime73@9506
   172
slime73@9506
   173
            int i;
slime73@9506
   174
            const SDL_DisplayMode *bestmode = NULL;
slime73@9506
   175
            for (i = display->num_display_modes; i >= 0; i--) {
slime73@9506
   176
                const SDL_DisplayMode *mode = &display->display_modes[i];
slime73@9532
   177
                if ((mode->w >= window->w) && (mode->h >= window->h)) {
slime73@9506
   178
                    bestmode = mode;
slime73@9532
   179
                }
slime73@9506
   180
            }
slime73@9506
   181
slime73@9506
   182
            if (bestmode) {
slime73@9510
   183
                SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)bestmode->driverdata;
slime73@9510
   184
                [data.uiscreen setCurrentMode:modedata.uiscreenmode];
slime73@9506
   185
slime73@9506
   186
                /* desktop_mode doesn't change here (the higher level will
slime73@9506
   187
                 * use it to set all the screens back to their defaults
slime73@9532
   188
                 * upon window destruction, SDL_Quit(), etc. */
slime73@9506
   189
                display->current_mode = *bestmode;
slime73@9506
   190
            }
slouken@8891
   191
        }
icculus@4446
   192
slime73@9510
   193
        if (data.uiscreen == [UIScreen mainScreen]) {
slime73@9506
   194
            if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
slime73@9584
   195
                [UIApplication sharedApplication].statusBarHidden = YES;
slime73@9506
   196
            } else {
slime73@9584
   197
                [UIApplication sharedApplication].statusBarHidden = NO;
slouken@6520
   198
            }
slime73@9506
   199
        }
kees@6001
   200
slime73@9506
   201
        /* ignore the size user requested, and make a fullscreen window */
slime73@9506
   202
        /* !!! FIXME: can we have a smaller view? */
slime73@9532
   203
        UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds];
slouken@7862
   204
slime73@9532
   205
        /* put the window on an external display if appropriate. */
slime73@9532
   206
        if (data.uiscreen != [UIScreen mainScreen]) {
slime73@9510
   207
            [uiwindow setScreen:data.uiscreen];
slime73@9506
   208
        }
slime73@9506
   209
slime73@9506
   210
        if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) {
slime73@9506
   211
            return -1;
slime73@9506
   212
        }
kees@6001
   213
    }
kees@6001
   214
slouken@3685
   215
    return 1;
slouken@2765
   216
}
slouken@2765
   217
slouken@5056
   218
void
slime73@9529
   219
UIKit_SetWindowTitle(_THIS, SDL_Window * window)
slime73@9529
   220
{
slime73@9529
   221
    @autoreleasepool {
slime73@9532
   222
        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slime73@9537
   223
        data.viewcontroller.title = @(window->title);
slime73@9529
   224
    }
slime73@9529
   225
}
slime73@9529
   226
slime73@9529
   227
void
slouken@6379
   228
UIKit_ShowWindow(_THIS, SDL_Window * window)
slouken@6379
   229
{
slime73@9506
   230
    @autoreleasepool {
slime73@9532
   231
        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slime73@9532
   232
        [data.uiwindow makeKeyAndVisible];
slime73@9506
   233
    }
slouken@6379
   234
}
slouken@6379
   235
slouken@6379
   236
void
slouken@6379
   237
UIKit_HideWindow(_THIS, SDL_Window * window)
slouken@6379
   238
{
slime73@9506
   239
    @autoreleasepool {
slime73@9532
   240
        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slime73@9532
   241
        data.uiwindow.hidden = YES;
slime73@9506
   242
    }
slouken@6379
   243
}
slouken@6379
   244
slouken@6379
   245
void
icculus@6419
   246
UIKit_RaiseWindow(_THIS, SDL_Window * window)
icculus@6419
   247
{
slouken@7191
   248
    /* We don't currently offer a concept of "raising" the SDL window, since
slime73@9532
   249
     * we only allow one per display, in the iOS fashion.
slouken@7191
   250
     * However, we use this entry point to rebind the context to the view
slime73@9532
   251
     * during OnWindowRestored processing. */
icculus@6419
   252
    _this->GL_MakeCurrent(_this, _this->current_glwin, _this->current_glctx);
icculus@6419
   253
}
icculus@6419
   254
slime73@9505
   255
static void
slime73@9505
   256
UIKit_UpdateWindowBorder(_THIS, SDL_Window * window)
slouken@6073
   257
{
slime73@9532
   258
    SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slime73@9532
   259
    SDL_uikitviewcontroller *viewcontroller = data.viewcontroller;
slouken@6073
   260
slime73@9532
   261
    if (data.uiwindow.screen == [UIScreen mainScreen]) {
slime73@9505
   262
        if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) {
slime73@9505
   263
            [UIApplication sharedApplication].statusBarHidden = YES;
slime73@9505
   264
        } else {
slime73@9505
   265
            [UIApplication sharedApplication].statusBarHidden = NO;
slime73@9505
   266
        }
slouken@6437
   267
slime73@9505
   268
        /* iOS 7+ won't update the status bar until we tell it to. */
slime73@9505
   269
        if ([viewcontroller respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
slime73@9505
   270
            [viewcontroller setNeedsStatusBarAppearanceUpdate];
slime73@9505
   271
        }
slime73@9491
   272
    }
slime73@9491
   273
slime73@9497
   274
    /* Update the view's frame to account for the status bar change. */
slime73@9532
   275
    viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen);
slime73@9585
   276
slime73@9585
   277
#ifdef SDL_IPHONE_KEYBOARD
slime73@9585
   278
    /* Make sure the view is offset correctly when the keyboard is visible. */
slime73@9585
   279
    [viewcontroller updateKeyboard];
slime73@9585
   280
#endif
slime73@9585
   281
slime73@9532
   282
    [viewcontroller.view setNeedsLayout];
slime73@9532
   283
    [viewcontroller.view layoutIfNeeded];
slouken@6073
   284
}
slouken@6073
   285
slouken@6073
   286
void
slime73@9505
   287
UIKit_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
slime73@9505
   288
{
slime73@9506
   289
    @autoreleasepool {
slime73@9506
   290
        UIKit_UpdateWindowBorder(_this, window);
slime73@9506
   291
    }
slime73@9505
   292
}
slime73@9505
   293
slime73@9505
   294
void
slime73@9505
   295
UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
slime73@9505
   296
{
slime73@9506
   297
    @autoreleasepool {
slime73@9506
   298
        UIKit_UpdateWindowBorder(_this, window);
slime73@9506
   299
    }
slime73@9505
   300
}
slime73@9505
   301
slime73@9505
   302
void
kees@6003
   303
UIKit_DestroyWindow(_THIS, SDL_Window * window)
kees@6003
   304
{
slime73@9506
   305
    @autoreleasepool {
slime73@9510
   306
        if (window->driverdata != NULL) {
slime73@9532
   307
            SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata);
slime73@9532
   308
            [data.viewcontroller stopAnimation];
slime73@9506
   309
        }
slouken@3685
   310
    }
slouken@8978
   311
    window->driverdata = NULL;
slouken@2765
   312
}
slouken@2765
   313
slouken@5056
   314
SDL_bool
slouken@5056
   315
UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
slouken@5056
   316
{
slime73@9506
   317
    @autoreleasepool {
slime73@9532
   318
        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slouken@5056
   319
slime73@9506
   320
        if (info->version.major <= SDL_MAJOR_VERSION) {
slime73@9540
   321
            int versionnum = SDL_VERSIONNUM(info->version.major, info->version.minor, info->version.patch);
slime73@9540
   322
slime73@9506
   323
            info->subsystem = SDL_SYSWM_UIKIT;
slime73@9532
   324
            info->info.uikit.window = data.uiwindow;
slime73@9540
   325
slime73@9540
   326
            /* These struct members were added in SDL 2.0.4. */
slime73@9540
   327
            if (versionnum >= SDL_VERSIONNUM(2,0,4)) {
slime73@9540
   328
                if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) {
slime73@9540
   329
                    SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view;
slime73@9540
   330
                    info->info.uikit.framebuffer = glview.drawableFramebuffer;
slime73@9540
   331
                    info->info.uikit.colorbuffer = glview.drawableRenderbuffer;
slime73@9540
   332
                } else {
slime73@9540
   333
                    info->info.uikit.framebuffer = 0;
slime73@9540
   334
                    info->info.uikit.colorbuffer = 0;
slime73@9540
   335
                }
slime73@9540
   336
            }
slime73@9540
   337
slime73@9506
   338
            return SDL_TRUE;
slime73@9506
   339
        } else {
slime73@9506
   340
            SDL_SetError("Application not compiled with SDL %d.%d\n",
slime73@9506
   341
                         SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
slime73@9506
   342
            return SDL_FALSE;
slime73@9506
   343
        }
slouken@5056
   344
    }
slouken@5056
   345
}
slouken@5056
   346
slime73@9523
   347
NSUInteger
slime73@9523
   348
UIKit_GetSupportedOrientations(SDL_Window * window)
slime73@9523
   349
{
slime73@9523
   350
    const char *hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
slime73@9584
   351
    NSUInteger validOrientations = UIInterfaceOrientationMaskAll;
slime73@9523
   352
    NSUInteger orientationMask = 0;
slime73@9523
   353
slime73@9523
   354
    @autoreleasepool {
slime73@9584
   355
        SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
slime73@9584
   356
        UIApplication *app = [UIApplication sharedApplication];
slime73@9584
   357
slime73@9584
   358
        /* Get all possible valid orientations. If the app delegate doesn't tell
slime73@9584
   359
         * us, we get the orientations from Info.plist via UIApplication. */
slime73@9584
   360
        if ([app.delegate respondsToSelector:@selector(application:supportedInterfaceOrientationsForWindow:)]) {
slime73@9584
   361
            validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow];
slime73@9584
   362
        } else if ([app respondsToSelector:@selector(supportedInterfaceOrientationsForWindow:)]) {
slime73@9584
   363
            validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow];
slime73@9584
   364
        }
slime73@9584
   365
slime73@9523
   366
        if (hint != NULL) {
slime73@9523
   367
            NSArray *orientations = [@(hint) componentsSeparatedByString:@" "];
slime73@9523
   368
slime73@9523
   369
            if ([orientations containsObject:@"LandscapeLeft"]) {
slime73@9523
   370
                orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
slime73@9523
   371
            }
slime73@9523
   372
            if ([orientations containsObject:@"LandscapeRight"]) {
slime73@9523
   373
                orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
slime73@9523
   374
            }
slime73@9523
   375
            if ([orientations containsObject:@"Portrait"]) {
slime73@9523
   376
                orientationMask |= UIInterfaceOrientationMaskPortrait;
slime73@9523
   377
            }
slime73@9523
   378
            if ([orientations containsObject:@"PortraitUpsideDown"]) {
slime73@9523
   379
                orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
slime73@9523
   380
            }
slime73@9523
   381
        }
slime73@9523
   382
slime73@9523
   383
        if (orientationMask == 0 && (window->flags & SDL_WINDOW_RESIZABLE)) {
slime73@9523
   384
            /* any orientation is okay. */
slime73@9523
   385
            orientationMask = UIInterfaceOrientationMaskAll;
slime73@9523
   386
        }
slime73@9523
   387
slime73@9523
   388
        if (orientationMask == 0) {
slime73@9523
   389
            if (window->w >= window->h) {
slime73@9523
   390
                orientationMask |= UIInterfaceOrientationMaskLandscape;
slime73@9523
   391
            }
slime73@9523
   392
            if (window->h >= window->w) {
slime73@9523
   393
                orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
slime73@9523
   394
            }
slime73@9523
   395
        }
slime73@9523
   396
slime73@9584
   397
        /* Don't allow upside-down orientation on phones, so answering calls is in the natural orientation */
slime73@9532
   398
        if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
slime73@9523
   399
            orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
slime73@9523
   400
        }
slime73@9584
   401
slime73@9584
   402
        /* If none of the specified orientations are actually supported by the
slime73@9584
   403
         * app, we'll revert to what the app supports. An exception would be
slime73@9584
   404
         * thrown by the system otherwise. */
slime73@9584
   405
        if ((validOrientations & orientationMask) == 0) {
slime73@9584
   406
            orientationMask = validOrientations;
slime73@9584
   407
        }
slime73@9523
   408
    }
slime73@9523
   409
slime73@9523
   410
    return orientationMask;
slime73@9523
   411
}
slime73@9523
   412
slouken@6342
   413
int
slouken@6342
   414
SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam)
slouken@6342
   415
{
slime73@9532
   416
    if (!window || !window->driverdata) {
slime73@9532
   417
        return SDL_SetError("Invalid window");
slime73@9532
   418
    }
slime73@9532
   419
slime73@9510
   420
    @autoreleasepool {
slime73@9532
   421
        SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
slime73@9532
   422
        [data.viewcontroller setAnimationCallback:interval
slime73@9532
   423
                                         callback:callback
slime73@9532
   424
                                    callbackParam:callbackParam];
slime73@9506
   425
    }
slime73@9506
   426
slouken@6342
   427
    return 0;
slouken@6342
   428
}
slouken@6342
   429
slouken@6044
   430
#endif /* SDL_VIDEO_DRIVER_UIKIT */
slouken@6044
   431
slouken@2765
   432
/* vi: set ts=4 sw=4 expandtab: */