diff options
author | Memphiz <memphis@machzwo.de> | 2014-01-04 13:25:19 +0100 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2014-01-05 23:10:47 +0100 |
commit | f444d23bbb8f73c599ced6378806a63e21960218 (patch) | |
tree | df0b59509f89fdcd02ada7fe8dd113accadd4d27 | |
parent | 7859dd49fa5947beeccb168a3263bfb494864b0c (diff) |
[ios] - fix tvout orientation (don't make assumptions about deprecated APIs which result in 90 degree rotated tvout since ios7 - but just reset the angle to 0 when going to the external screen)
-rw-r--r-- | xbmc/osx/IOSScreenManager.h | 2 | ||||
-rw-r--r-- | xbmc/osx/IOSScreenManager.mm | 13 | ||||
-rw-r--r-- | xbmc/osx/atv2/XBMCController.h | 2 | ||||
-rw-r--r-- | xbmc/osx/atv2/XBMCController.mm | 6 | ||||
-rw-r--r-- | xbmc/osx/ios/XBMCController.h | 2 | ||||
-rw-r--r-- | xbmc/osx/ios/XBMCController.mm | 31 |
6 files changed, 42 insertions, 14 deletions
diff --git a/xbmc/osx/IOSScreenManager.h b/xbmc/osx/IOSScreenManager.h index 2aee7ca8ca..92b7870c74 100644 --- a/xbmc/osx/IOSScreenManager.h +++ b/xbmc/osx/IOSScreenManager.h @@ -36,10 +36,12 @@ bool _externalScreen; IOSEAGLView *_glView; IOSExternalTouchController *_externalTouchController; + UIInterfaceOrientation _lastTouchControllerOrientation; } @property unsigned int _screenIdx; @property (readonly, getter=isExternalScreen)bool _externalScreen; @property (assign, setter=setView:) IOSEAGLView *_glView; +@property UIInterfaceOrientation _lastTouchControllerOrientation; // init the screenmanager with our eaglview //- (id) initWithView:(IOSEAGLView *)view; diff --git a/xbmc/osx/IOSScreenManager.mm b/xbmc/osx/IOSScreenManager.mm index bbb4d4766d..1fe7f7a90b 100644 --- a/xbmc/osx/IOSScreenManager.mm +++ b/xbmc/osx/IOSScreenManager.mm @@ -53,6 +53,7 @@ static CEvent screenChangeEvent; @synthesize _screenIdx; @synthesize _externalScreen; @synthesize _glView; +@synthesize _lastTouchControllerOrientation; //-------------------------------------------------------------- - (void) fadeFromBlack:(CGFloat) delaySecs @@ -90,7 +91,16 @@ static CEvent screenChangeEvent; [_glView setScreen:newScreen withFrameBufferResize:TRUE];//will also resize the framebuffer - [g_xbmcController activateScreen:newScreen];// will attach the screen to xbmc mainwindow + if (toExternal) + { + // portrait on external screen means its landscape for xbmc + [g_xbmcController activateScreen:newScreen withOrientation:UIInterfaceOrientationPortrait];// will attach the screen to xbmc mainwindow + } + else + { + // switching back to internal - use same orientation as we used for the touch controller + [g_xbmcController activateScreen:newScreen withOrientation:_lastTouchControllerOrientation];// will attach the screen to xbmc mainwindow + } if(toExternal)//changing the external screen might need some time ... { @@ -142,6 +152,7 @@ static CEvent screenChangeEvent; if([self willSwitchToInternal:screenIdx] && _externalTouchController != nil) { + _lastTouchControllerOrientation = [_externalTouchController interfaceOrientation]; [_externalTouchController release]; _externalTouchController = nil; } diff --git a/xbmc/osx/atv2/XBMCController.h b/xbmc/osx/atv2/XBMCController.h index c410b707c9..29614141ad 100644 --- a/xbmc/osx/atv2/XBMCController.h +++ b/xbmc/osx/atv2/XBMCController.h @@ -57,7 +57,7 @@ - (void) startAnimation; - (void) stopAnimation; - (bool) changeScreen: (unsigned int)screenIdx withMode:(UIScreenMode *)mode; -- (void) activateScreen: (UIScreen *)screen; +- (void) activateScreen: (UIScreen *)screen withOrientation:(UIInterfaceOrientation)newOrientation; - (id) glView; - (void) setGlView:(id)view; - (BOOL) ATVClientEventFromBREvent:(id)event Repeatable:(bool *)isRepeatable ButtonState:(bool *)isPressed Result:(int *)xbmc_ir_key; diff --git a/xbmc/osx/atv2/XBMCController.mm b/xbmc/osx/atv2/XBMCController.mm index 4c2e8827f5..0ad21356f5 100644 --- a/xbmc/osx/atv2/XBMCController.mm +++ b/xbmc/osx/atv2/XBMCController.mm @@ -1333,7 +1333,7 @@ static bool XBMCController$changeScreen(XBMCController* self, SEL _cmd, unsigned return [[IOSScreenManager sharedInstance] changeScreen: screenIdx withMode: mode]; } //-------------------------------------------------------------- -static void XBMCController$activateScreen(XBMCController* self, SEL _cmd, UIScreen * screen) +static void XBMCController$activateScreen(XBMCController* self, SEL _cmd, UIScreen * screen, UIInterfaceOrientation newOrientation) { } @@ -1500,9 +1500,11 @@ static __attribute__((constructor)) void initControllerRuntimeClasses() i += 1; memcpy(_typeEncoding + i, @encode(UIScreen *), strlen(@encode(UIScreen *))); i += strlen(@encode(UIScreen *)); + _typeEncoding[i] = 'I'; + i += 1; _typeEncoding[i] = '\0'; // XBMCController::activateScreen$ - class_addMethod(XBMCControllerCls, @selector(activateScreen:), (IMP)&XBMCController$activateScreen, _typeEncoding); + class_addMethod(XBMCControllerCls, @selector(activateScreen:withOrientation:), (IMP)&XBMCController$activateScreen, _typeEncoding); // and hook up our methods (implementation of the base class methods) // XBMCController::brEventAction diff --git a/xbmc/osx/ios/XBMCController.h b/xbmc/osx/ios/XBMCController.h index 549dd5a729..80c67893f1 100644 --- a/xbmc/osx/ios/XBMCController.h +++ b/xbmc/osx/ios/XBMCController.h @@ -98,7 +98,7 @@ typedef enum - (void) disableScreenSaver; - (void) enableScreenSaver; - (bool) changeScreen: (unsigned int)screenIdx withMode:(UIScreenMode *)mode; -- (void) activateScreen: (UIScreen *)screen; +- (void) activateScreen: (UIScreen *)screen withOrientation:(UIInterfaceOrientation)newOrientation; - (id) initWithFrame:(CGRect)frame withScreen:(UIScreen *)screen; @end diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 25da688ded..a4c278b2c7 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -956,17 +956,30 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL; return ret; } //-------------------------------------------------------------- -- (void) activateScreen: (UIScreen *)screen +- (void) activateScreen: (UIScreen *)screen withOrientation:(UIInterfaceOrientation)newOrientation { - //this is the only way for making ios call the - //shouldAutorotateToInterfaceOrientation of the controller - //this is needed because at least with my vga adapter - //the orientation on the external screen is messed up by 90° - //so we need to hard force the orientation to Portrait for - //getting the correct display on external screen + // Since ios7 we have to handle the orientation manually + // it differs by 90 degree between internal and external screen + float angle = 0; UIView *view = [m_window.subviews objectAtIndex:0]; - [view removeFromSuperview]; - [m_window addSubview:view]; + switch(newOrientation) + { + case UIInterfaceOrientationPortrait: + angle = 0; + break; + case UIInterfaceOrientationPortraitUpsideDown: + angle = M_PI; + break; + case UIInterfaceOrientationLandscapeLeft: + angle = -M_PI_2; + break; + case UIInterfaceOrientationLandscapeRight: + angle = M_PI_2; + break; + } + // reset the rotation of the view + view.layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0); + [view setFrame:m_window.frame]; m_window.screen = screen; } //-------------------------------------------------------------- |