We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4276

Summary: No way to detect orientation flip on iOS
Product: SDL Reporter: Ryan David Sheasby <ryan27968>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: API change    
Priority: P2 CC: ryan27968
Version: don't know   
Hardware: iPhone/iPod touch   
OS: iOS 9   

Description Ryan David Sheasby 2018-09-27 13:04:21 UTC
Hi team. I've run into a problem with Love2d(based on SDL obviously) on iOS. When you do an orientation flip(not a rotation from portrait to landscape, a flip from portrait to upside-down portrait or something like that), there is no event triggered from SDL. The only orientation-based event is SDL_WINDOWEVENT_RESIZED which is only triggered when changing dimensions i.e. portrait <-> landscape. This is a crucial missing functionality. This is especially problematic due to the fact that accelerometer data is constant meaning it does not get inverted when you flip the device. Hence an accelerometer-based driving game for example would have to be locked to a single orientation as wheen you flip the device the steering would be inverted.
Comment 1 Sam Lantinga 2018-09-27 21:51:36 UTC
In SDL 2.0.9 you use the function SDL_GetDisplayOrientation(), and watch for the event SDL_DISPLAYEVENT to detect changes.

You can get a prerelease version here:
http://www.libsdl.org/tmp/SDL-2.0.zip

Cheers!