OpenFeint iPad screen orientation on startup?

I already have my game detecting iPad orientation and rotating properly. And I have the Unity splash screen orienting to proper rotation on app startup.

But I can’t figure out how to force the OpenFeint login screen to rotate to the current orientation on app startup. It always opens according to the “Initial Dashboard Orientation” that’s set in OpenFeint settings. This means if I have the iPad in the opposite orientation (upside down) when I launch the game, the OF Login screen will be displayed upside down. This is the screen that comes up immediately before/as the game starts – apparently the login dashboard is called before any game scripts are executed so I can’t even get it to check SetDashboardOrientation() before it launches.

I’m using

OpenFeint.SetDashboardOrientation(iPhoneInput.orientation);

before launching the Dashboard from menus inside the game so that the dashboard at least gets the proper orientation. But when the OF window is up, it doesn’t rotate with the iPad.

Any thoughts on how to handle either of the above issues?

Hi,

I ended up working around this issue in AppController+OpenFeint.mm by keeping track of the UIDevice orientation property and when it differs/changes from the last time I checked it, I close the OF dashboard altogether. This doesn’t rotate the dashboard, but it will at least close it when it’s open and the orientation changes, and Apple did approve my iPad game which employed this workaround.

For example, here’s the code for an app that uses Portrait and PortraitUpsideDown (change as needed for Landscape variants):

UIDeviceOrientation origDeviceOrientation;
NSTimer *orientationTimer;

// OpenFeintDelegate //
- (void)dashboardWillAppear
{
	origDeviceOrientation = [UIDevice currentDevice].orientation;
	if (origDeviceOrientation == UIDeviceOrientationPortraitUpsideDown)
	{
		[OpenFeint setDashboardOrientation:UIInterfaceOrientationPortraitUpsideDown];
	}
	else
	{
		[OpenFeint setDashboardOrientation:UIInterfaceOrientationPortrait];
	}
	orientationTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f
            target:self selector:@selector(checkOrientation:) 
            userInfo:nil repeats:YES];
	
	unityPaused = YES;
	UnitySetAudioSessionActive(false);
	UnityPause(true);
}

- (void)dashboardDidDisappear
{
	[orientationTimer invalidate];
	unityPaused = NO;
	UnitySetAudioSessionActive(true);
	UnityPause(false);
}

- (void) checkOrientation:(NSTimer *) theTimer
{
	UIDeviceOrientation dor = [UIDevice currentDevice].orientation;
	if (dor != origDeviceOrientation  (dor == UIDeviceOrientationPortrait || dor == UIDeviceOrientationPortraitUpsideDown))
	{
		[OpenFeint dismissDashboard];
	}
}

As for launching the dashboard in the correct orientation to begin with, I also used code similar to that which you referenced, but I specifically set the orientation in it.

For example, I have the following attached to my main Camera in one of my scenes:

void FixedUpdate()
{
	if ((iPhoneInput.orientation == iPhoneOrientation.Portrait)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.Portrait))
	{
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait;
		OpenFeint.SetDashboardOrientation(iPhoneOrientation.Portrait);
	}
	else if ((iPhoneInput.orientation == iPhoneOrientation.PortraitUpsideDown)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.PortraitUpsideDown))
	{
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown;
	   OpenFeint.SetDashboardOrientation(iPhoneOrientation.PortraitUpsideDown);
	}
}

Add in the required Info.plist changes to launch in the correct orientations and the iPhoneKeyboard.autorotate* properties to prevent the outer app frame from rotating, and Apple approved the resulting behavior in my OF-enabled iPad game so although this is a workaround maybe it will also work for you.

Cheers,
Sean

Thanks, Sean! That’s just the information I needed. Everything is working better now, tho it would be nice if there were a way to rotate OF rather than just closing it. Hopefully the OF guys will figure this out.

Thanks a lot for the information, it really saved me some time!

I am having a few issues thought… I have added the following key to my Info.plist

<key>UISupportedInterfaceOrientations</key>
	<array>
	<string>UIInterfaceOrientationPortrait</string>
	<string>UIInterfaceOrientationPortraitUpsideDown</string>
	<string>UIInterfaceOrientationLandscapeLeft</string>
	<string>UIInterfaceOrientationLandscapeRight</string>
	</array>

Which gets my splash screen and initial orientation to look correct. I have also added these 2 lines to my main Start() method on my game script:

iPhoneSettings.screenOrientation = (iPhoneScreenOrientation)iPhoneInput.orientation;
OpenFeint.SetDashboardOrientation(iPhoneInput.orientation);

When the application launches the splash screen looks fine, the initial game screen looks fine, but when the OF “Welcome Back” notification pops up it is upside down and comes from the bottom (instead of the top as it should). If I click the OpenFeint button to launch the dashboard the dashboard launches fine but the OS Status bar is shown upside down on the bottom of the screen. If I close the OF dashboard and then re-launch it everything looks fine. Any suggestions?

I use the following code to make my screen flip when the device is rotated and it should also make sure that the OpenFeint Dashboard and Achievement prompts are oriented properly when they display:

function FixedUpdate() {
	if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeLeft)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeLeft)){
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeLeft;
		OpenFeint.SetDashboardOrientation(iPhoneOrientation.LandscapeLeft); 
	}
	if ((iPhoneInput.orientation == iPhoneOrientation.LandscapeRight)  (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.LandscapeRight)){
		iPhoneSettings.screenOrientation = iPhoneScreenOrientation.LandscapeRight;
		OpenFeint.SetDashboardOrientation(iPhoneOrientation.LandscapeRight);
	}
}

I’ve got it all working correctly thanks to you guys! - Except the OpenFeint.
In LandscapeRight the OpenFeint “welcome back” and “dashboard” are displayed upside down?
Any help would be greatly apprieciated…Thanks

Write the code as below and it will work…no need to close the openfient dashboard:

- (void) checkOrientation:(NSTimer *) theTimer
{
	origDeviceOrientation = [UIDevice currentDevice].orientation;
	if (origDeviceOrientation == UIDeviceOrientationPortraitUpsideDown)
	{
		[OpenFeint setDashboardOrientation:UIInterfaceOrientationPortraitUpsideDown];
	}
	else
	{
		[OpenFeint setDashboardOrientation:UIInterfaceOrientationPortrait];
	}
}

Enjoy!!!

Regards,
Prakaash

Prakaash, what file do we add this code to?

For those still interested…

Using OF SDK 2.10, just change AppController+Openfeint.mm (line 1033) to something like this:

- (void)deviceOrientationChanged:(NSNotification*)notification
{
	UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIDevice currentDevice] orientation];
	if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
		[OpenFeint setDashboardOrientation:orientation];
	}
// Original code...
//	if(orientation >= UIInterfaceOrientationPortrait  orientation <= UIInterfaceOrientationLandscapeLeft) {
//		[OpenFeint setDashboardOrientation:orientation];
//	}
}