[atv2/ios5.1] - don't add our window to the BRWindow list as a BRControl - iOS 5...
authorMemphiz <memphis@machzwo.de>
Sat, 31 Mar 2012 18:52:08 +0000 (20:52 +0200)
committerMemphiz <memphis@machzwo.de>
Sat, 31 Mar 2012 18:53:21 +0000 (20:53 +0200)
xbmc/osx/atv2/XBMCController.mm

index 8b86d43..3a837d4 100644 (file)
@@ -25,6 +25,7 @@
 #import "WinEventsIOS.h"
 #import "XBMC_events.h"
 #include "utils/log.h"
+#include "osx/DarwinUtils.h"
 #undef BOOL
 
 #import <Foundation/Foundation.h>
 #import "XBMCEAGLView.h"
 #import "XBMCDebugHelpers.h"
 
+// This is defined in Math.h
+#define M_PI   3.14159265358979323846264338327950288   /* pi */
+// Our conversion definition
+#define DEGREES_TO_RADIANS(angle) (angle / 180.0 * M_PI)
+
 //start repeating after 0.5s
 #define REPEATED_KEYPRESS_DELAY_S     0.5
 //pause 0.01s (10ms) between keypresses
@@ -307,6 +314,24 @@ int           m_systemsleepTimeout;
   [super dealloc];
 }
 
+- (void)rotateView:(UIView *)view duration:(NSTimeInterval)duration 
+       curve:(UIViewAnimationCurve)curve degrees:(CGFloat)degrees
+{
+  // Setup the animation
+  [UIView beginAnimations:nil context:NULL];
+  [UIView setAnimationDuration:duration];
+  [UIView setAnimationCurve:curve];
+  [UIView setAnimationBeginsFromCurrentState:YES];
+  // The transform matrix
+  CGAffineTransform transform = 
+      CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
+  view.transform = transform;
+  // Commit the changes
+  [UIView commitAnimations];
+}
+
 - (void)controlWasActivated
 {
   //NSLog(@"%s", __PRETTY_FUNCTION__);
@@ -316,7 +341,18 @@ int           m_systemsleepTimeout;
   [self disableSystemSleep];
   [self disableScreenSaver];
   [m_window makeKeyAndVisible];
-  [[[[BRWindow windowList] objectAtIndex:0] content] addControl: m_window];
+
+  //atv2 ios5.1 doesn't like to get our window added as a BRControl
+  //so we better leave it there...
+  if( GetIOSVersion() < (float)5.1 )
+  {
+    [[[[BRWindow windowList] objectAtIndex:0] content] addControl: m_window];
+  }
+  else//instead on ios 5.1 we rotate our window 90degrees ourself (remember ios is portrait based overall)
+  {
+    [self rotateView:m_window duration:0 
+      curve:UIViewAnimationCurveEaseIn degrees:90];
+  }
 
   [m_glView startAnimation];
 }