You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// All supported formats/dimensions for this device.
@@ -167,13 +167,18 @@ struct SDL_Camera
167
167
structSDL_PrivateCameraData*hidden;
168
168
};
169
169
170
+
171
+
// Note that for AcquireFrame, `rotation` is degrees, with positive values rotating clockwise. This is the amount to rotate an image so it would be right-side up.
172
+
// Rotations should be in 90 degree increments at this time (landscape to portrait, or upside down to right side up, etc).
173
+
// Most platforms won't care about this, but mobile devices might need to deal with the device itself being physically rotated, causing the fixed-orientation camera to be presenting sideways images.
// As of this writing, all known iOS devices provide portrait orientation camera data, so we just need to know how to rotate between that and the current device orientation.
230
+
// macOS currently assumes you don't ever rotate images because the camera is always positioned right-side up (for now).
if (!UIDeviceOrientationIsValidInterfaceOrientation(device_orientation)) {
234
+
device_orientation = hidden.last_device_orientation; // possible the phone is laying flat or something went wrong, just stay with the last known-good orientation.
235
+
} else {
236
+
hidden.last_device_orientation = device_orientation; // update the last known-good orientation for later.
237
+
}
238
+
239
+
switch (device_orientation) {
240
+
case UIDeviceOrientationPortrait: *rotation = 0; break;
241
+
case UIDeviceOrientationPortraitUpsideDown: *rotation = 180; break;
242
+
case UIDeviceOrientationLandscapeRight: *rotation = 90; break; // !!! FIXME: might be backwards.
243
+
case UIDeviceOrientationLandscapeLeft: *rotation = 270; break; // !!! FIXME: might be backwards.
case UIInterfaceOrientationPortrait: hidden.last_device_orientation = UIDeviceOrientationPortrait; break;
405
+
case UIInterfaceOrientationPortraitUpsideDown: hidden.last_device_orientation = UIDeviceOrientationPortraitUpsideDown; break;
406
+
case UIInterfaceOrientationLandscapeLeft: hidden.last_device_orientation = UIDeviceOrientationLandscapeRight; break; // Apple docs say UI and device orientations are reversed in landscape.
407
+
case UIInterfaceOrientationLandscapeRight: hidden.last_device_orientation = UIDeviceOrientationLandscapeLeft; break;
0 commit comments