iPhone screen orientation hint (patch included)

For a title I’m developing, the default behaviour of allowing either
both portrait orientations or both landscape orientatins doesn’t really
work to the point where it makes the game unplayable. Setting
SDL_WINDOW_RESIZABLE and enabling all rotations makes the problem worse.
Really what I want to do is restrict which orientations are allowable.
I’ve banged together a patch (attached) to do this using the hint API.
In my particular case I want portrait only:

SDL_SetHint( “SDL_HINT_ORIENTATIONS”, “Portrait” );

The second parameter is a space delimited list of the orientations
required. If you wanted all orientations then you would call:

SDL_SetHint( “SDL_HINT_ORIENTATIONS”, “Portrait PortraitUpsideDown
LandscapeLeft LandscapeRight” );

I think this is a fairly important bit of functionality to have, so it
would be nice to see it committed at some point. Does anybody have any
comments/objections/suggestions? If not I’ll punt it into bugzilla…
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: sdl-1.3-iphone-screen-orientation-hint.diff
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110601/5a870225/attachment.asc

SDL_SetHint( “SDL_HINT_ORIENTATIONS”, “Portrait” );

The second parameter is a space delimited list of the orientations
required. If you wanted all orientations then you would call:

SDL_SetHint( “SDL_HINT_ORIENTATIONS”, “Portrait PortraitUpsideDown
LandscapeLeft LandscapeRight” );

I think this is a fairly important bit of functionality to have, so it
would be nice to see it committed at some point. Does anybody have any
comments/objections/suggestions? If not I’ll punt it into bugzilla…

Great patch!

I’ve applied this patch and the Armin one about rotations & screen
sensitivity and now I have a fully usable SDL version for my purposes. In my
option both patches should be committed to the official repository, the
Armin one is a bit rough (but fixes a critical bug), and this one using
SDL_SetHint it seems to me very reasonable (SDL_SetHint is born for similar
issues…).–
Bye,
Gabry

For a title I’m developing, the default behaviour of allowing either
both portrait orientations or both landscape orientatins doesn’t really
work to the point where it makes the game unplayable. Setting
SDL_WINDOW_RESIZABLE and enabling all rotations makes the problem worse.
Really what I want to do is restrict which orientations are allowable.
I’ve banged together a patch (attached) to do this using the hint API.
In my particular case I want portrait only:

Is the problem that SDL’s rotation code is buggy, or should your game
really never change orientation (even between portrait and upside-down
portrait) under any circumstances?

There are still big bugs in SDL’s orientation code which need fixing in
any case, but generally the iOS attitude is that you should be allowed
to hold the device upside down if you want (say, if the headphone jack
is in the way for how you hold it and flipping the device upside down is
more comfortable).

–ryan.

The latter. I don’t have any particular problem with the default of
flipping the view, I just think you should have the option to disable
it if you don’t want that. In my particular situation it’s an
accelerometer based game where having the view flip fundamentally
breaks the core game play mechanic.On Fri, 03 Jun 2011 16:09:24 -0400 Ryan wrote:

Is the problem that SDL’s rotation code is buggy, or should your game
really never change orientation (even between portrait and
upside-down portrait) under any circumstances?

The latter. I don’t have any particular problem with the default of
flipping the view, I just think you should have the option to disable
it if you don’t want that. In my particular situation it’s an
accelerometer based game where having the view flip fundamentally
breaks the core game play mechanic.

Ok, that makes sense. Kick the patch into Bugzilla if you will, I’ll
take a look at it this weekend.

–ryan.