Skip to content

Commit

Permalink
Fixed SDL_HINT_ORIENTATIONS to properly allow disabling custom orient…
Browse files Browse the repository at this point in the history
…ations if the hint is set with no valid orientations.
  • Loading branch information
slime73 committed Jul 17, 2014
1 parent b21544c commit b55be6e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/video/uikit/SDL_uikitviewcontroller.m
Expand Up @@ -69,13 +69,12 @@ - (void)viewDidLayoutSubviews
- (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"]) {
Expand All @@ -90,14 +89,17 @@ - (NSUInteger)supportedInterfaceOrientations
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);
}
}
Expand All @@ -117,7 +119,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient

- (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;
Expand All @@ -129,7 +131,7 @@ - (UIStatusBarStyle)preferredStatusBarStyle
#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
}
Expand Down

0 comments on commit b55be6e

Please sign in to comment.