Fixed SDL_HINT_ORIENTATIONS to properly allow disabling custom orientations if the hint is set with no valid orientations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index 433b91b..52737a3 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -69,13 +69,12 @@
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger orientationMask = 0;
+ const char *orientationsHint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
- const char *orientationsCString;
- if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) {
- BOOL rotate = NO;
- NSString *orientationsNSString = [NSString stringWithCString:orientationsCString
- encoding:NSUTF8StringEncoding];
- NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet:
+ if (orientationsHint != NULL) {
+ NSString *orientationsString = [NSString stringWithCString:orientationsHint
+ encoding:NSUTF8StringEncoding];
+ NSArray *orientations = [orientationsString componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@" "]];
if ([orientations containsObject:@"LandscapeLeft"]) {
@@ -90,14 +89,17 @@
if ([orientations containsObject:@"PortraitUpsideDown"]) {
orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown;
}
+ }
- } else if (self->window->flags & SDL_WINDOW_RESIZABLE) {
+ if (orientationMask == 0 && window->flags & SDL_WINDOW_RESIZABLE) {
orientationMask = UIInterfaceOrientationMaskAll; /* any orientation is okay. */
- } else {
- if (self->window->w >= self->window->h) {
+ }
+
+ if (orientationMask == 0) {
+ if (window->w >= window->h) {
orientationMask |= UIInterfaceOrientationMaskLandscape;
}
- if (self->window->h >= self->window->w) {
+ if (window->h >= window->w) {
orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
}
@@ -117,7 +119,7 @@
- (BOOL)prefersStatusBarHidden
{
- if (self->window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
+ if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
return YES;
} else {
return NO;
@@ -129,7 +131,7 @@
#ifdef __IPHONE_7_0
return UIStatusBarStyleLightContent;
#else
- /* This is only called in iOS 7+, so the return value isn't important. */
+ /* This method is only used in iOS 7+, so the return value here isn't important. */
return UIStatusBarStyleBlackTranslucent;
#endif
}