From e538771d4ff886778efe58bbb231f3a96b4991fc Mon Sep 17 00:00:00 2001 From: Zach Coleman Date: Tue, 1 Nov 2022 21:37:01 -0400 Subject: [PATCH] [3.x] Add ProMotion Support to iOS Exports --- doc/classes/ProjectSettings.xml | 3 +++ main/main.cpp | 1 + misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist | 1 + platform/iphone/godot_view.mm | 12 ++++++------ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index a763558056d..8313bbb6cbd 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -480,6 +480,9 @@ The default screen orientation to use on mobile devices. [b]Note:[/b] When set to a portrait orientation, this project setting does not flip the project resolution's width and height automatically. Instead, you have to set [member display/window/size/width] and [member display/window/size/height] accordingly. + + If [code]true[/code], iOS devices that support high refresh rate/"ProMotion" will be allowed to render at up to 120 frames per second. + If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button. diff --git a/main/main.cpp b/main/main.cpp index f241f7fe15d..8e27f0c37a6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1280,6 +1280,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_delta_smoothing(GLOBAL_GET("application/run/delta_smoothing")); } + GLOBAL_DEF("display/window/ios/allow_high_refresh_rate", true); GLOBAL_DEF("display/window/ios/hide_home_indicator", true); GLOBAL_DEF("input_devices/pointing/ios/touch_delay", 0.15); ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pointing/ios/touch_delay", diff --git a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist index e9d22f6b4d8..b88dfae5b28 100644 --- a/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist +++ b/misc/dist/ios_xcode/godot_ios/godot_ios-Info.plist @@ -58,5 +58,6 @@ $additional_plist_content $plist_launch_screen_name + CADisableMinimumFrameDurationOnPhone diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm index 5cf914176d0..c10f1ccddf2 100644 --- a/platform/iphone/godot_view.mm +++ b/platform/iphone/godot_view.mm @@ -176,16 +176,16 @@ static const int max_touches = 8; if (self.useCADisplayLink) { self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)]; - // Approximate frame rate - // assumes device refreshes at 60 fps - int displayFPS = (NSInteger)(1.0 / self.renderingInterval); - - self.displayLink.preferredFramesPerSecond = displayFPS; + if (GLOBAL_GET("display/window/ios/allow_high_refresh_rate")) { + self.displayLink.preferredFramesPerSecond = 120; + } else { + self.displayLink.preferredFramesPerSecond = 60; + } // Setup DisplayLink in main thread [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } else { - self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:self.renderingInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; + self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 60) target:self selector:@selector(drawView) userInfo:nil repeats:YES]; } }