src/video/uikit/SDL_uikitviewcontroller.m
author Sam Lantinga <slouken@libsdl.org>
Sun, 23 Sep 2012 03:46:49 -0700
changeset 6451 52e5a05ca795
parent 6440 f0ca76958984
child 6452 1895319021e4
permissions -rwxr-xr-x
Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
     1
/*
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     2
  Simple DirectMedia Layer
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6093
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
     4
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     5
  This software is provided 'as-is', without any express or implied
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     7
  arising from the use of this software.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     8
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    11
  freely, subject to the following restrictions:
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    12
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    14
     claim that you wrote the original software. If you use this software
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    16
     appreciated but is not required.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    18
     misrepresented as being the original software.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    20
*/
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    21
#include "SDL_config.h"
6001
3ae3d1e58d59 Cleanup out trailing whitespace in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 5640
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
    23
#if SDL_VIDEO_DRIVER_UIKIT
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    24
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    25
#include "SDL_video.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    26
#include "SDL_assert.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    27
#include "SDL_hints.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    28
#include "../SDL_sysvideo.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    29
#include "../../events/SDL_events_c.h"
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    30
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    31
#include "SDL_uikitwindow.h"
6093
a8696b259e09 Another iOS 3.1 compatibility fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 6079
diff changeset
    32
#include "SDL_uikitviewcontroller.h"
a8696b259e09 Another iOS 3.1 compatibility fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 6079
diff changeset
    33
#include "SDL_uikitvideo.h"
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    34
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    35
@implementation SDL_uikitviewcontroller
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    36
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    37
@synthesize window;
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    38
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    39
- (id)initWithSDLWindow:(SDL_Window *)_window
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    40
{
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    41
    self = [self init];
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    42
    if (self == nil) {
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    43
        return nil;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    44
    }
6011
83a21d3bd5c1 Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents: 6003
diff changeset
    45
    self.window = _window;
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    46
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    47
    return self;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    48
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    49
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    50
- (void)loadView
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    51
{
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    52
    // do nothing.
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    53
}
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    54
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    55
- (void)viewDidLayoutSubviews
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    56
{
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    57
    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    58
        SDL_WindowData *data = self->window->driverdata;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    59
        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    60
        SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    61
        const CGSize size = data->view.bounds.size;
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    62
        int w, h;
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    63
        
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    64
        w = (int)(size.width * displaymodedata->scale);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    65
        h = (int)(size.height * displaymodedata->scale);
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    66
        
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    67
        SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    68
    }
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    69
}
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
    70
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    71
- (NSUInteger)supportedInterfaceOrientations
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
    72
{
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    73
    NSUInteger orientationMask = 0;
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    74
    
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    75
    const char *orientationsCString;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    76
    if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    77
        BOOL rotate = NO;
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    78
        NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    79
                                                            encoding:NSUTF8StringEncoding];
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    80
        NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    81
                                 [NSCharacterSet characterSetWithCharactersInString:@" "]];
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    82
        
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    83
        if ([orientations containsObject:@"LandscapeLeft"]) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    84
            orientationMask |= UIInterfaceOrientationMaskLandscapeLeft;
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    85
        }
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    86
        if ([orientations containsObject:@"LandscapeRight"]) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    87
            orientationMask |= UIInterfaceOrientationMaskLandscapeRight;
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    88
        }
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    89
        if ([orientations containsObject:@"Portrait"]) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    90
            orientationMask |= UIInterfaceOrientationMaskPortrait;
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
    91
        }
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    92
        if ([orientations containsObject:@"PortraitUpsideDown"]) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    93
            orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    94
        }
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    95
        
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    96
    } else if (self->window->flags & SDL_WINDOW_RESIZABLE) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    97
        orientationMask = UIInterfaceOrientationMaskAll;  // any orientation is okay.
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    98
    } else {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
    99
        if (self->window->w >= self->window->h) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   100
            orientationMask |= UIInterfaceOrientationMaskLandscape;
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   101
        }
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   102
        if (self->window->h >= self->window->w) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   103
            orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   104
        }
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   105
    }
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   106
    
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   107
    // Don't allow upside-down orientation on the phone, so answering calls is in the natural orientation
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   108
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   109
        orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown;
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   110
    }
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   111
    return orientationMask;
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   112
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   113
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   114
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient
6003
fddf81967e2d Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents: 6001
diff changeset
   115
{
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   116
    NSUInteger orientationMask = [self supportedInterfaceOrientations];
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   117
    return (orientationMask & (1 << orient));
5640
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   118
}
04b5b11985c8 Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff changeset
   119
6451
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   120
@end
52e5a05ca795 Fixed autorotate / resize support on iOS 6.0, tested with iPad and iPhone simulators with iOS 5.1 and 6.0
Sam Lantinga <slouken@libsdl.org>
parents: 6440
diff changeset
   121
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
   122
#endif /* SDL_VIDEO_DRIVER_UIKIT */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 6011
diff changeset
   123
6440
f0ca76958984 Generate resize event when the status bar changes size (e.g. call in progress, etc.)
Sam Lantinga <slouken@libsdl.org>
parents: 6438
diff changeset
   124
/* vi: set ts=4 sw=4 expandtab: */