UPSIDEDOWN mode?

Hi, I’m very new to OF.

I’m making an iPad app, so I have to make it to run in “all orientations”. And I tried to use

  
ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_PORTRAIT);  

but only

  
ofxiPhoneSetOrientation(OFXIPHONE_ORIENTATION_UPSIDEDOWN);  

didn’t work. It’s No image on the screen. Why??
How can I get UPSIDEDOWN mode on iPad.

I tried both Xcode 3.2.2 and 3.2.3, SDK 3.2 and 4. and 0061 FAT.

THX.

i ran into the same issue.
I changed the following in ofAppiPhoneWindow.mm

  
	case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
				glRotatef(180, 0, 0, 1);  
				break;  
  

TO

  
	case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
				glScalef(-1, 1, 1);          
				glTranslatef(-w,0, 0);  
				break;  
  

also if you want your splash Default.png to be upside down on launch, add the stuff below to your ofxiphone-Info.plist

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

the ofxiPhoneKeyboard still doesn’t work UpsideDown… any idea how to solve this?

found this in ofxiPhoneKeyboard but didn’t manage to figure out how to fix it:

  
case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
/*  
_textField.transform = CGAffineTransformMakeRotation(M_PI / 2.0);  
 */  

  
case OFXIPHONE_ORIENTATION_PORTRAIT:  
case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
	_textField.transform = CGAffineTransformMakeRotation(0.0f);  
  

thanks

managed to fix ofxiPhoneKeyboard for UpsideDown Orientation!

the methods I changed in ofxiPhoneKeyboard.mm:

  
- (id) init:(int)x y:(int)y width:(int)w height:(int)h  
{  
	if(self = [super init])  
	{			  
		_textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, w, h)];  
		  
		switch (ofxiPhoneGetOrientation())   
		{  
			case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
				_textField.transform = CGAffineTransformMakeRotation(-M_PI_2);  
				break;  
				  
			case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
				  
				_textField.transform = CGAffineTransformMakeRotation(M_PI_2);  
				break;  
				  
			case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
				_textField.transform = CGAffineTransformMakeRotation(M_PI_2 * 2.0);  
				break;  
				  
			default:  
				break;  
		}  
  
(...)  

  
- (void) updateOrientation  
{  
	_textField.transform = CGAffineTransformMakeRotation(0.0f);  
	[self setFrame:CGRectMake(0,0,_w,_h)];  
	  
	switch (ofxiPhoneGetOrientation())   
	{  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
			_textField.transform = CGAffineTransformMakeRotation(-M_PI_2);  
			break;  
			  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
			  
			_textField.transform = CGAffineTransformMakeRotation(M_PI_2);  
			break;  
			  
		case OFXIPHONE_ORIENTATION_PORTRAIT:  
			_textField.transform = CGAffineTransformMakeRotation(0.0f);  
			break;  
		case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
			_textField.transform = CGAffineTransformMakeRotation(M_PI_2 *2);  
			break;  
		default:  
			break;  
	}  
(...)  

  
- (void) setFrame: (CGRect) rect  
{  
	  
	CGSize s = [[[UIApplication sharedApplication] keyWindow] bounds].size;		  
	  
	switch (ofxiPhoneGetOrientation())   
	{  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
			[_textField setFrame: CGRectMake(rect.origin.y-rect.size.height, s.height-rect.size.width-rect.origin.x, rect.size.height, rect.size.width)];  
			break;  
			  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
			[_textField setFrame: CGRectMake(s.width-rect.origin.y , rect.origin.x, rect.size.height, rect.size.width)];  
			break;  
			  
		case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
			[_textField setFrame: CGRectMake(s.width-rect.origin.x-rect.size.width , s.height-rect.origin.y, rect.size.width, rect.size.height)];  
			 break;  
			  
		default:  
			[_textField setFrame: CGRectMake(rect.origin.x , rect.origin.y-rect.size.height, rect.size.width, rect.size.height)];  
			break;  
	}  
}  
  

It seems like 0.07 ofxiPhoneKeyboard isn’t working right with OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT or OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT; it’s drawing way off from where it should be, and is not oriented correctly.

Here’s another iteration on ofxiPhoneKeyboard.mm changes, at 3 places in that file:

  
- (id) init:(int)x y:(int)y width:(int)w height:(int)h  
{  
	if(self = [super init])  
	{			  
		_textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, w, h)];  
		  
		switch (ofxiPhoneGetOrientation())   
		{  
			case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
				_textField.transform = CGAffineTransformMakeRotation(M_PI_2);  
				break;  
				  
			case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
				_textField.transform = CGAffineTransformMakeRotation(-M_PI_2);  
				break;  
				  
			case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
				_textField.transform = CGAffineTransformMakeRotation(M_PI);    
				 break;  
				  
			default:  
				break;  
		}  
(...)   
  

  
- (void) updateOrientation  
{  
	_textField.transform = CGAffineTransformMakeRotation(0.0f);  
	[self setFrame:CGRectMake(0,0,_w,_h)];  
	  
	switch (ofxiPhoneGetOrientation())   
	{  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
			_textField.transform = CGAffineTransformMakeRotation(M_PI_2);  
			break;  
			  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
			_textField.transform = CGAffineTransformMakeRotation(-M_PI_2);  
			break;  
			  
		case OFXIPHONE_ORIENTATION_PORTRAIT:  
			_textField.transform = CGAffineTransformMakeRotation(0.0f);  
			break;  
			  
		case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
			_textField.transform = CGAffineTransformMakeRotation(M_PI);    
			break;  
			  
		default:  
			break;  
	}  
(...)  
  

  
- (void) setFrame: (CGRect) rect  
{  
	  
	CGSize s = [[[UIApplication sharedApplication] keyWindow] bounds].size;		  
	  
	switch (ofxiPhoneGetOrientation())   
	{  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_LEFT:  
			[_textField setFrame: CGRectMake(s.width - rect.origin.y - rect.size.height, rect.origin.x, rect.size.height, rect.size.width)];  
			break;  
			  
		case OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT:  
			[_textField setFrame: CGRectMake(rect.origin.y, s.height - rect.origin.x - rect.size.width, rect.size.height, rect.size.width)];  
			break;  
			  
		case OFXIPHONE_ORIENTATION_UPSIDEDOWN:  
			[_textField setFrame: CGRectMake(s.width - rect.origin.x - rect.size.width, s.height - rect.origin.y - rect.size.height, rect.size.width, rect.size.height)];    
			break;  
			  
		default:  
			[_textField setFrame: CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];  
	}  
}  
  

This works for me in all 4 orientations. An easy way to test it is to set the orientation in KeyboardExample and see if it still draws in the upper-left of the screen.

In KeyboardExample’s testapp.mm:

  
void testApp::setup(){	  
	// register touch events  
	ofRegisterTouchEvents(this);  
	  
	iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);  
  
(...)  
  

I would also suggest changing the KeyboardExample keyboard values to something like:

  
	keyboard = new ofxiPhoneKeyboard(0,20,320,32);  

The 0.07 ofxiPhoneKeyboard.mm is for some reason setting the top of the rect to the requested y + height instead of just y, which seemed strange. The ofxiPhoneKeyboard.mm changes above fix this.