From 09dc8295d6a16a2e7ef794613bb71dd9d14a1cd0 Mon Sep 17 00:00:00 2001 From: meancoot Date: Fri, 20 Dec 2013 19:20:01 -0500 Subject: [PATCH] (iOS) Fix issues with orientation locking. --- apple/common/RAGameView.m | 24 ++++++++++++++++++++++++ apple/iOS/platform.h | 4 +++- apple/iOS/platform.m | 34 +++------------------------------- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index 14db01cacc..a9ed62f492 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -192,6 +192,30 @@ static bool g_is_syncing = true; ]; } +// NOTE: This version only runs on iOS6 +- (NSUInteger)supportedInterfaceOrientations +{ + return apple_frontend_settings.orientation_flags; +} + +// NOTE: This version runs on iOS2-iOS5, but not iOS6 +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + switch (interfaceOrientation) + { + case UIInterfaceOrientationPortrait: + return (apple_frontend_settings.orientation_flags & UIInterfaceOrientationMaskPortrait); + case UIInterfaceOrientationPortraitUpsideDown: + return (apple_frontend_settings.orientation_flags & UIInterfaceOrientationMaskPortraitUpsideDown); + case UIInterfaceOrientationLandscapeLeft: + return (apple_frontend_settings.orientation_flags & UIInterfaceOrientationMaskLandscapeLeft); + case UIInterfaceOrientationLandscapeRight: + return (apple_frontend_settings.orientation_flags & UIInterfaceOrientationMaskLandscapeRight); + } + + return YES; +} + void event_process_camera_frame(void* pixelBufferPtr) { CVPixelBufferRef pixelBuffer = (CVPixelBufferRef)pixelBufferPtr; diff --git a/apple/iOS/platform.h b/apple/iOS/platform.h index 36d2e3917d..d52d0f5245 100644 --- a/apple/iOS/platform.h +++ b/apple/iOS/platform.h @@ -23,7 +23,9 @@ typedef struct { - char orientations[32]; + char orientations[32]; + unsigned orientation_flags; + bool logging_enabled; char bluetooth_mode[64]; diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 6cd58e52ab..a24fe79be2 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -175,8 +175,6 @@ static void handle_touch_event(NSArray* touches) { UIWindow* _window; NSString* _path; - - uint32_t _enabledOrientations; } + (RetroArch_iOS*)get @@ -265,32 +263,6 @@ static void handle_touch_event(NSArray* touches) [self refreshSystemConfig]; } -// NOTE: This version only runs on iOS6 -- (NSUInteger)supportedInterfaceOrientations -{ - return g_extern.is_paused ? _enabledOrientations - : UIInterfaceOrientationMaskAll; -} - -// NOTE: This version runs on iOS2-iOS5, but not iOS6 -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - if (!g_extern.is_paused) - switch (interfaceOrientation) - { - case UIInterfaceOrientationPortrait: - return (_enabledOrientations & UIInterfaceOrientationMaskPortrait); - case UIInterfaceOrientationPortraitUpsideDown: - return (_enabledOrientations & UIInterfaceOrientationMaskPortraitUpsideDown); - case UIInterfaceOrientationLandscapeLeft: - return (_enabledOrientations & UIInterfaceOrientationMaskLandscapeLeft); - case UIInterfaceOrientationLandscapeRight: - return (_enabledOrientations & UIInterfaceOrientationMaskLandscapeRight); - } - - return YES; -} - - (void)showGameView { [self popToRootViewControllerAnimated:NO]; @@ -329,12 +301,12 @@ static void handle_touch_event(NSArray* touches) - (void)refreshSystemConfig { // Get enabled orientations - _enabledOrientations = UIInterfaceOrientationMaskAll; + apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskAll; if (strcmp(apple_frontend_settings.orientations, "landscape") == 0) - _enabledOrientations = UIInterfaceOrientationMaskLandscape; + apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskLandscape; else if (strcmp(apple_frontend_settings.orientations, "portrait") == 0) - _enabledOrientations = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; + apple_frontend_settings.orientation_flags = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; // Set bluetooth mode ios_set_bluetooth_mode(BOXSTRING(apple_frontend_settings.bluetooth_mode));