Skip to content

Commit

Permalink
Add project setting to hide home indicator on iOS
Browse files Browse the repository at this point in the history
On iOS devices without a physical home button iOS
shows a home indicator instead. This is often in the
way of the UI or the game.
Added a project setting to disable hidden home indicator.
The default value is to hide the home indicator
  • Loading branch information
NoFr1ends authored and Jonas Bernemann committed Dec 13, 2019
1 parent 7380fbb commit 4d61118
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@
<member name="display/window/vsync/vsync_via_compositor" type="bool" setter="" getter="" default="false">
If [code]Use Vsync[/code] is enabled and this setting is [code]true[/code], enables vertical synchronization via the operating system's window compositor when in windowed mode and the compositor is enabled. This will prevent stutter in certain situations. (Windows only.)
</member>
<member name="display/window/ios/hide_home_indicator" type="bool" setter="" getter="" default="true">
If [code]true[/code], the home indicator is hidden automatically. This only affects iOS devices without a physical home button.
</member>
<member name="editor/script_templates_search_path" type="String" setter="" getter="" default="&quot;res://script_templates&quot;">
</member>
<member name="editor/search_in_file_extensions" type="PoolStringArray" setter="" getter="" default="PoolStringArray( &quot;gd&quot;, &quot;shader&quot; )">
Expand Down
2 changes: 2 additions & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(GLOBAL_DEF("application/run/low_processor_mode_sleep_usec", 6900)); // Roughly 144 FPS
ProjectSettings::get_singleton()->set_custom_property_info("application/run/low_processor_mode_sleep_usec", PropertyInfo(Variant::INT, "application/run/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "0,33200,1,or_greater")); // No negative numbers

GLOBAL_DEF("display/window/ios/hide_home_indicator", true);

Engine::get_singleton()->set_frame_delay(frame_delay);

message_queue = memnew(MessageQueue);
Expand Down
2 changes: 2 additions & 0 deletions platform/iphone/view_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@

- (BOOL)prefersStatusBarHidden;

- (BOOL)prefersHomeIndicatorAutoHidden;

@end
10 changes: 10 additions & 0 deletions platform/iphone/view_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "os_iphone.h"

#include "core/project_settings.h"

extern "C" {

int add_path(int, char **);
Expand Down Expand Up @@ -129,6 +131,14 @@ - (BOOL)prefersStatusBarHidden {
return YES;
}

- (BOOL)prefersHomeIndicatorAutoHidden {
if (GLOBAL_GET("display/window/ios/hide_home_indicator")) {
return YES;
} else {
return NO;
}
}

#ifdef GAME_CENTER_ENABLED
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController {
//[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone
Expand Down

1 comment on commit 4d61118

@Distace84
Copy link

@Distace84 Distace84 commented on 4d61118 Jul 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @NoFr1ends is it possible that you can do this functionality also with the status bar? Because at the moment it's not possible to show the status bar in any way.

Please sign in to comment.