author | Sam Lantinga <slouken@libsdl.org> |
Sun, 23 Sep 2012 17:01:58 -0700 | |
changeset 6452 | 1895319021e4 |
parent 6451 | 52e5a05ca795 |
child 6453 | f71e3fdba072 |
permissions | -rwxr-xr-x |
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 | 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 |
|
6452
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
35 |
#ifndef __IPHONE_6_0 |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
36 |
// This enum isn't available in older SDKs, but we use it for our own purposes on iOS 5.1 and for the system on iOS 6.0 |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
37 |
enum UIInterfaceOrientationMask) { |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
38 |
UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
39 |
UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
40 |
UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
41 |
UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
42 |
UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
43 |
UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
44 |
UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
45 |
}; |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
46 |
#endif // !__IPHONE_6_0 |
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
47 |
|
1895319021e4
Added UIInterfaceOrientationMask for building with older iOS SDKs
Sam Lantinga <slouken@libsdl.org>
parents:
6451
diff
changeset
|
48 |
|
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
49 |
@implementation SDL_uikitviewcontroller |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
50 |
|
6011
83a21d3bd5c1
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents:
6003
diff
changeset
|
51 |
@synthesize window; |
83a21d3bd5c1
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents:
6003
diff
changeset
|
52 |
|
6003
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
53 |
- (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
|
54 |
{ |
6011
83a21d3bd5c1
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents:
6003
diff
changeset
|
55 |
self = [self init]; |
83a21d3bd5c1
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents:
6003
diff
changeset
|
56 |
if (self == nil) { |
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
57 |
return nil; |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
58 |
} |
6011
83a21d3bd5c1
Make SDL_uikitviewcontroller.window a real Objective-C property and synthesize
Kees Bakker <kees@ijzerbout.nl>
parents:
6003
diff
changeset
|
59 |
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
|
60 |
|
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
61 |
return self; |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
62 |
} |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
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 |
- (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
|
65 |
{ |
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
|
66 |
// 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
|
67 |
} |
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 |
|
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
|
69 |
- (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
|
70 |
{ |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
|
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
|
78 |
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
|
79 |
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
|
80 |
|
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
|
81 |
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
|
82 |
} |
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
|
83 |
} |
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
|
84 |
|
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
|
85 |
- (NSUInteger)supportedInterfaceOrientations |
6003
fddf81967e2d
Use a consistent source code format in src/video/uikit
Kees Bakker <kees@ijzerbout.nl>
parents:
6001
diff
changeset
|
86 |
{ |
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
|
87 |
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
|
88 |
|
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
89 |
const char *orientationsCString; |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
90 |
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
|
91 |
BOOL rotate = NO; |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
92 |
NSString *orientationsNSString = [NSString stringWithCString:orientationsCString |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
93 |
encoding:NSUTF8StringEncoding]; |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
94 |
NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet: |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
95 |
[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
|
96 |
|
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 |
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
|
98 |
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
|
99 |
} |
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 |
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
|
101 |
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
|
102 |
} |
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 |
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
|
104 |
orientationMask |= UIInterfaceOrientationMaskPortrait; |
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 |
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
|
107 |
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
|
108 |
} |
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 |
|
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
|
110 |
} 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
|
111 |
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
|
112 |
} 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
|
113 |
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
|
114 |
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
|
115 |
} |
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 |
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
|
117 |
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
|
118 |
} |
5640
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 |
|
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 |
// 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
|
122 |
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
|
123 |
orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown; |
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
124 |
} |
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
|
125 |
return orientationMask; |
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
126 |
} |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
127 |
|
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
|
128 |
- (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
|
129 |
{ |
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
|
130 |
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
|
131 |
return (orientationMask & (1 << orient)); |
5640
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
132 |
} |
04b5b11985c8
Split off SDL_uikitviewcontroller in its own module
Kees Bakker <kees@tweeler.com>
parents:
diff
changeset
|
133 |
|
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
|
134 |
@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
|
135 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
6011
diff
changeset
|
136 |
#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
|
137 |
|
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
|
138 |
/* vi: set ts=4 sw=4 expandtab: */ |