Skip to content

Commit c8ae9e9

Browse files
committed
[iOS] Change default iPad landscape orientation from "left" to "right".
1 parent 8bf8f41 commit c8ae9e9

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</array>
5555
<key>UISupportedInterfaceOrientations~ipad</key>
5656
<array>
57-
$interface_orientations
57+
$ipad_interface_orientations
5858
</array>
5959
$additional_plist_content
6060
$plist_launch_screen_name

platform/ios/export/export_plugin.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,44 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
541541
}
542542

543543
strnew += lines[i].replace("$interface_orientations", orientations);
544+
} else if (lines[i].contains("$ipad_interface_orientations")) {
545+
String orientations;
546+
const DisplayServer::ScreenOrientation screen_orientation =
547+
DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")));
548+
549+
switch (screen_orientation) {
550+
case DisplayServer::SCREEN_LANDSCAPE:
551+
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
552+
break;
553+
case DisplayServer::SCREEN_PORTRAIT:
554+
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
555+
break;
556+
case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
557+
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
558+
break;
559+
case DisplayServer::SCREEN_REVERSE_PORTRAIT:
560+
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
561+
break;
562+
case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
563+
// Allow both landscape orientations depending on sensor direction.
564+
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
565+
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
566+
break;
567+
case DisplayServer::SCREEN_SENSOR_PORTRAIT:
568+
// Allow both portrait orientations depending on sensor direction.
569+
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
570+
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
571+
break;
572+
case DisplayServer::SCREEN_SENSOR:
573+
// Allow all screen orientations depending on sensor direction.
574+
orientations += "<string>UIInterfaceOrientationLandscapeLeft</string>\n";
575+
orientations += "<string>UIInterfaceOrientationLandscapeRight</string>\n";
576+
orientations += "<string>UIInterfaceOrientationPortrait</string>\n";
577+
orientations += "<string>UIInterfaceOrientationPortraitUpsideDown</string>\n";
578+
break;
579+
}
580+
581+
strnew += lines[i].replace("$ipad_interface_orientations", orientations);
544582
} else if (lines[i].contains("$camera_usage_description")) {
545583
String description = p_preset->get("privacy/camera_usage_description");
546584
strnew += lines[i].replace("$camera_usage_description", description) + "\n";

platform/ios/view_controller.mm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
258258
case DisplayServer::SCREEN_PORTRAIT:
259259
return UIInterfaceOrientationMaskPortrait;
260260
case DisplayServer::SCREEN_REVERSE_LANDSCAPE:
261-
return UIInterfaceOrientationMaskLandscapeRight;
261+
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
262+
return UIInterfaceOrientationMaskLandscapeLeft;
263+
} else {
264+
return UIInterfaceOrientationMaskLandscapeRight;
265+
}
262266
case DisplayServer::SCREEN_REVERSE_PORTRAIT:
263267
return UIInterfaceOrientationMaskPortraitUpsideDown;
264268
case DisplayServer::SCREEN_SENSOR_LANDSCAPE:
@@ -268,7 +272,11 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
268272
case DisplayServer::SCREEN_SENSOR:
269273
return UIInterfaceOrientationMaskAll;
270274
case DisplayServer::SCREEN_LANDSCAPE:
271-
return UIInterfaceOrientationMaskLandscapeLeft;
275+
if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
276+
return UIInterfaceOrientationMaskLandscapeRight;
277+
} else {
278+
return UIInterfaceOrientationMaskLandscapeLeft;
279+
}
272280
}
273281
}
274282

0 commit comments

Comments
 (0)