summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/SCsub7
-rw-r--r--platform/iphone/app_delegate.h1
-rw-r--r--platform/iphone/app_delegate.mm203
-rw-r--r--platform/iphone/detect.py8
-rw-r--r--platform/iphone/export/export.cpp113
-rw-r--r--platform/iphone/game_center.mm5
-rw-r--r--platform/iphone/gl_view.h2
-rw-r--r--platform/iphone/gl_view.mm24
-rw-r--r--platform/iphone/icloud.mm2
-rw-r--r--platform/iphone/in_app_store.h1
-rw-r--r--platform/iphone/in_app_store.mm15
-rw-r--r--platform/iphone/logo.pngbin1905 -> 1489 bytes
-rw-r--r--platform/iphone/os_iphone.cpp69
-rw-r--r--platform/iphone/os_iphone.h21
-rw-r--r--platform/iphone/platform_config.h1
-rw-r--r--platform/iphone/power_iphone.cpp2
-rw-r--r--platform/iphone/view_controller.mm65
17 files changed, 292 insertions, 247 deletions
diff --git a/platform/iphone/SCsub b/platform/iphone/SCsub
index 6b5f30dc41..b96bec16b4 100644
--- a/platform/iphone/SCsub
+++ b/platform/iphone/SCsub
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+import os
Import('env')
@@ -21,6 +22,10 @@ ios_lib = env_ios.add_library('iphone', iphone_lib)
def combine_libs(target=None, source=None, env=None):
lib_path = target[0].srcnode().abspath
- env.Execute('$IPHONEPATH/usr/bin/libtool -static -o "' + lib_path + '" ' + ' '.join([('"' + lib.srcnode().abspath + '"') for lib in source]))
+ if ("OSXCROSS_IOS" in os.environ):
+ libtool = '$IPHONEPATH/usr/bin/${ios_triple}libtool'
+ else:
+ libtool = "$IPHONEPATH/usr/bin/libtool"
+ env.Execute(libtool + ' -static -o "' + lib_path + '" ' + ' '.join([('"' + lib.srcnode().abspath + '"') for lib in source]))
combine_command = env_ios.Command('#bin/libgodot' + env_ios['LIBSUFFIX'], [ios_lib] + env_ios['LIBS'], combine_libs)
diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h
index f14864b5b7..c34b5053d6 100644
--- a/platform/iphone/app_delegate.h
+++ b/platform/iphone/app_delegate.h
@@ -37,6 +37,7 @@
@interface AppDelegate : NSObject <UIApplicationDelegate, GLViewDelegate> {
//@property (strong, nonatomic) UIWindow *window;
ViewController *view_controller;
+ bool is_focus_out;
};
@property(strong, nonatomic) UIWindow *window;
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 5c3799ab09..cc4985eb0c 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -79,6 +79,7 @@ static ViewController *mainViewController = nil;
}
NSMutableDictionary *ios_joysticks = nil;
+NSMutableArray *pending_ios_joysticks = nil;
- (GCControllerPlayerIndex)getFreePlayerIndex {
bool have_player_1 = false;
@@ -115,6 +116,66 @@ NSMutableDictionary *ios_joysticks = nil;
};
};
+void _ios_add_joystick(GCController *controller, AppDelegate *delegate) {
+ // get a new id for our controller
+ int joy_id = OSIPhone::get_singleton()->get_unused_joy_id();
+ if (joy_id != -1) {
+ // assign our player index
+ if (controller.playerIndex == GCControllerPlayerIndexUnset) {
+ controller.playerIndex = [delegate getFreePlayerIndex];
+ };
+
+ // tell Godot about our new controller
+ OSIPhone::get_singleton()->joy_connection_changed(
+ joy_id, true, [controller.vendorName UTF8String]);
+
+ // add it to our dictionary, this will retain our controllers
+ [ios_joysticks setObject:controller
+ forKey:[NSNumber numberWithInt:joy_id]];
+
+ // set our input handler
+ [delegate setControllerInputHandler:controller];
+ } else {
+ printf("Couldn't retrieve new joy id\n");
+ };
+}
+
+static void on_focus_out(ViewController *view_controller, bool *is_focus_out) {
+ if (!*is_focus_out) {
+ *is_focus_out = true;
+ if (OS::get_singleton()->get_main_loop())
+ OS::get_singleton()->get_main_loop()->notification(
+ MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+
+ [view_controller.view stopAnimation];
+ if (OS::get_singleton()->native_video_is_playing()) {
+ OSIPhone::get_singleton()->native_video_focus_out();
+ }
+
+ AudioDriverCoreAudio *audio = dynamic_cast<AudioDriverCoreAudio *>(AudioDriverCoreAudio::get_singleton());
+ if (audio)
+ audio->stop();
+ }
+}
+
+static void on_focus_in(ViewController *view_controller, bool *is_focus_out) {
+ if (*is_focus_out) {
+ *is_focus_out = false;
+ if (OS::get_singleton()->get_main_loop())
+ OS::get_singleton()->get_main_loop()->notification(
+ MainLoop::NOTIFICATION_WM_FOCUS_IN);
+
+ [view_controller.view startAnimation];
+ if (OSIPhone::get_singleton()->native_video_is_playing()) {
+ OSIPhone::get_singleton()->native_video_unpause();
+ }
+
+ AudioDriverCoreAudio *audio = dynamic_cast<AudioDriverCoreAudio *>(AudioDriverCoreAudio::get_singleton());
+ if (audio)
+ audio->start();
+ }
+}
+
- (void)controllerWasConnected:(NSNotification *)notification {
// create our dictionary if we don't have one yet
if (ios_joysticks == nil) {
@@ -127,28 +188,12 @@ NSMutableDictionary *ios_joysticks = nil;
printf("Couldn't retrieve new controller\n");
} else if ([[ios_joysticks allKeysForObject:controller] count] != 0) {
printf("Controller is already registered\n");
+ } else if (frame_count > 1) {
+ _ios_add_joystick(controller, self);
} else {
- // get a new id for our controller
- int joy_id = OSIPhone::get_singleton()->get_unused_joy_id();
- if (joy_id != -1) {
- // assign our player index
- if (controller.playerIndex == GCControllerPlayerIndexUnset) {
- controller.playerIndex = [self getFreePlayerIndex];
- };
-
- // tell Godot about our new controller
- OSIPhone::get_singleton()->joy_connection_changed(
- joy_id, true, [controller.vendorName UTF8String]);
-
- // add it to our dictionary, this will retain our controllers
- [ios_joysticks setObject:controller
- forKey:[NSNumber numberWithInt:joy_id]];
-
- // set our input handler
- [self setControllerInputHandler:controller];
- } else {
- printf("Couldn't retrieve new joy id\n");
- };
+ if (pending_ios_joysticks == nil)
+ pending_ios_joysticks = [[NSMutableArray alloc] init];
+ [pending_ios_joysticks addObject:controller];
};
};
@@ -352,6 +397,27 @@ NSMutableDictionary *ios_joysticks = nil;
[ios_joysticks dealloc];
ios_joysticks = nil;
};
+
+ if (pending_ios_joysticks != nil) {
+ [pending_ios_joysticks dealloc];
+ pending_ios_joysticks = nil;
+ };
+};
+
+OS::VideoMode _get_video_mode() {
+ int backingWidth;
+ int backingHeight;
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
+ GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
+ GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+
+ OS::VideoMode vm;
+ vm.fullscreen = true;
+ vm.width = backingWidth;
+ vm.height = backingHeight;
+ vm.resizable = false;
+ return vm;
};
static int frame_count = 0;
@@ -360,19 +426,7 @@ static int frame_count = 0;
switch (frame_count) {
case 0: {
- int backingWidth;
- int backingHeight;
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
- GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
- GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
-
- OS::VideoMode vm;
- vm.fullscreen = true;
- vm.width = backingWidth;
- vm.height = backingHeight;
- vm.resizable = false;
- OS::get_singleton()->set_video_mode(vm);
+ OS::get_singleton()->set_video_mode(_get_video_mode());
if (!OS::get_singleton()) {
exit(0);
@@ -410,6 +464,14 @@ static int frame_count = 0;
Main::setup2();
++frame_count;
+ if (pending_ios_joysticks != nil) {
+ for (GCController *controller in pending_ios_joysticks) {
+ _ios_add_joystick(controller, self);
+ }
+ [pending_ios_joysticks dealloc];
+ pending_ios_joysticks = nil;
+ }
+
// this might be necessary before here
NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
for (NSString *key in dict) {
@@ -543,6 +605,8 @@ static int frame_count = 0;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect rect = [[UIScreen mainScreen] bounds];
+ is_focus_out = false;
+
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
// disable idle timer
// application.idleTimerDisabled = YES;
@@ -562,18 +626,13 @@ static int frame_count = 0;
//[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
// UIViewAutoresizingFlexibleWidth];
- int backingWidth;
- int backingHeight;
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
- GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES,
- GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+ OS::VideoMode vm = _get_video_mode();
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
- int err = iphone_main(backingWidth, backingHeight, gargc, gargv, String::utf8([documentsDirectory UTF8String]));
+ int err = iphone_main(vm.width, vm.height, gargc, gargv, String::utf8([documentsDirectory UTF8String]));
if (err != 0) {
// bail, things did not go very well for us, should probably output a message on screen with our error code...
exit(0);
@@ -584,7 +643,7 @@ static int frame_count = 0;
view_controller.view = glView;
window.rootViewController = view_controller;
- _set_keep_screen_on(bool(GLOBAL_DEF("display/window/keep_screen_on", true)) ? YES : NO);
+ _set_keep_screen_on(bool(GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true)) ? YES : NO);
glView.useCADisplayLink =
bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
printf("cadisaplylink: %d", glView.useCADisplayLink);
@@ -607,6 +666,12 @@ static int frame_count = 0;
[self initGameControllers];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(onAudioInterruption:)
+ name:AVAudioSessionInterruptionNotification
+ object:[AVAudioSession sharedInstance]];
+
// OSIPhone::screen_width = rect.size.width - rect.origin.x;
// OSIPhone::screen_height = rect.size.height - rect.origin.y;
@@ -618,6 +683,18 @@ static int frame_count = 0;
return TRUE;
};
+- (void)onAudioInterruption:(NSNotification *)notification {
+ if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
+ if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeBegan]]) {
+ NSLog(@"Audio interruption began");
+ on_focus_out(view_controller, &is_focus_out);
+ } else if ([[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey] isEqualToNumber:[NSNumber numberWithInt:AVAudioSessionInterruptionTypeEnded]]) {
+ NSLog(@"Audio interruption ended");
+ on_focus_in(view_controller, &is_focus_out);
+ }
+ }
+};
+
- (void)applicationWillTerminate:(UIApplication *)application {
[self deinitGameControllers];
@@ -632,44 +709,22 @@ static int frame_count = 0;
iphone_finish();
};
-- (void)applicationDidEnterBackground:(UIApplication *)application {
- ///@TODO maybe add pause motionManager? and where would we unpause it?
-
- if (OS::get_singleton()->get_main_loop())
- OS::get_singleton()->get_main_loop()->notification(
- MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+// When application goes to background (e.g. user switches to another app or presses Home),
+// then applicationWillResignActive -> applicationDidEnterBackground are called.
+// When user opens the inactive app again,
+// applicationWillEnterForeground -> applicationDidBecomeActive are called.
- [view_controller.view stopAnimation];
- if (OS::get_singleton()->native_video_is_playing()) {
- OSIPhone::get_singleton()->native_video_focus_out();
- };
-}
-
-- (void)applicationWillEnterForeground:(UIApplication *)application {
- // OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- [view_controller.view startAnimation];
-}
+// There are cases when applicationWillResignActive -> applicationDidBecomeActive
+// sequence is called without the app going to background. For example, that happens
+// if you open the app list without switching to another app or open/close the
+// notification panel by swiping from the upper part of the screen.
- (void)applicationWillResignActive:(UIApplication *)application {
- // OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
- [view_controller.view
- stopAnimation]; // FIXME: pause seems to be recommended elsewhere
+ on_focus_out(view_controller, &is_focus_out);
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
- if (OS::get_singleton()->get_main_loop())
- OS::get_singleton()->get_main_loop()->notification(
- MainLoop::NOTIFICATION_WM_FOCUS_IN);
-
- [view_controller.view
- startAnimation]; // FIXME: resume seems to be recommended elsewhere
- if (OSIPhone::get_singleton()->native_video_is_playing()) {
- OSIPhone::get_singleton()->native_video_unpause();
- };
-
- // Fixed audio can not resume if it is interrupted cause by an incoming phone call
- if (AudioDriverCoreAudio::get_singleton() != NULL)
- AudioDriverCoreAudio::get_singleton()->start();
+ on_focus_in(view_controller, &is_focus_out);
}
- (void)dealloc {
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index 25674c2b47..b13a1e9643 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -47,8 +47,12 @@ def configure(env):
if (env["target"].startswith("release")):
env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
- env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
- env.Append(LINKFLAGS=['-O2'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
+ env.Append(LINKFLAGS=['-O2'])
+ else: #optimize for size
+ env.Append(CPPFLAGS=['-Os', '-ftree-vectorize'])
+ env.Append(LINKFLAGS=['-Os'])
if env["target"] == "release_debug":
env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index e3119814f4..008e213e5e 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -119,6 +119,9 @@ public:
r_features->push_back("iOS");
}
+ virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) {
+ }
+
EditorExportPlatformIOS();
~EditorExportPlatformIOS();
};
@@ -147,47 +150,62 @@ Vector<EditorExportPlatformIOS::ExportArchitecture> EditorExportPlatformIOS::_ge
return archs;
}
+struct LoadingScreenInfo {
+ const char *preset_key;
+ const char *export_name;
+};
+
+static const LoadingScreenInfo loading_screen_infos[] = {
+ { "landscape_launch_screens/iphone_2436x1125", "Default-Landscape-X.png" },
+ { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png" },
+ { "landscape_launch_screens/ipad_1024x768", "Default-Landscape.png" },
+ { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png" },
+
+ { "portrait_launch_screens/iphone_640x960", "Default-480h@2x.png" },
+ { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png" },
+ { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png" },
+ { "portrait_launch_screens/iphone_1125x2436", "Default-Portrait-X.png" },
+ { "portrait_launch_screens/ipad_768x1024", "Default-Portrait.png" },
+ { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png" },
+ { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png" }
+};
+
void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_store_team_id"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_debug"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_debug"), "iPhone Developer"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_debug", PROPERTY_HINT_PLACEHOLDER_TEXT, "iPhone Developer"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_debug", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 1));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/provisioning_profile_uuid_release"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_release"), "iPhone Distribution"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/code_sign_identity_release", PROPERTY_HINT_PLACEHOLDER_TEXT, "iPhone Distribution"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_method_release", PROPERTY_HINT_ENUM, "App Store,Development,Ad-Hoc,Enterprise"), 0));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/info"), "Made with Godot Engine"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier"), "org.godotengine.iosgame"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "????"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "come.example.game"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version"), "1.0"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version"), "1.0"));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPhone/iPod Touch with retina display
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/ipad_76x76", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad
-
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/iphone_180x180", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPhone with retina HD display
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_152x152", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad with retina display
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_167x167", PROPERTY_HINT_FILE, "png"), "")); // Home screen on iPad Pro
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "png"), "")); // Spotlight
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "png"), "")); // Spotlight on devices with retina display
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/iphone_120x120", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone/iPod Touch with retina display
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/ipad_76x76", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "required_icons/app_store_1024x1024", PROPERTY_HINT_FILE, "*.png"), "")); // App Store
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/iphone_2208x1242", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6 Plus, 6s Plus, 7 Plus
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/ipad_2732x2048", PROPERTY_HINT_FILE, "png"), "")); // 12.9-inch iPad Pro
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "landscape_launch_screens/ipad_2048x1536", PROPERTY_HINT_FILE, "png"), "")); // Other iPads
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/iphone_180x180", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPhone with retina HD display
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_152x152", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad with retina display
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/ipad_167x167", PROPERTY_HINT_FILE, "*.png"), "")); // Home screen on iPad Pro
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight on devices with retina display
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_640x1136", PROPERTY_HINT_FILE, "png"), "")); // iPhone 5, 5s, SE
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_750x1334", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6, 6s, 7
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/iphone_1242x2208", PROPERTY_HINT_FILE, "png"), "")); // iPhone 6 Plus, 6s Plus, 7 Plus
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/ipad_2048x2732", PROPERTY_HINT_FILE, "png"), "")); // 12.9-inch iPad Pro
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "portrait_launch_screens/ipad_1536x2048", PROPERTY_HINT_FILE, "png"), "")); // Other iPads
+ for (int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), ""));
+ }
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
@@ -261,7 +279,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
CharString cs = strnew.utf8();
pfile.resize(cs.size() - 1);
for (int i = 0; i < cs.size() - 1; i++) {
- pfile[i] = cs[i];
+ pfile.write[i] = cs[i];
}
}
@@ -313,6 +331,7 @@ static const IconInfo icon_infos[] = {
{ "required_icons/iphone_120x120", "iphone", "Icon-120.png", "120", "3x", "40x40", true },
{ "required_icons/ipad_76x76", "ipad", "Icon-76.png", "76", "1x", "76x76", false },
+ { "required_icons/app_store_1024x1024", "ios-marketing", "Icon-1024.png", "1024", "1x", "1024x1024", false },
{ "optional_icons/iphone_180x180", "iphone", "Icon-180.png", "180", "3x", "60x60", false },
@@ -380,23 +399,6 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr
return OK;
}
-struct LoadingScreenInfo {
- const char *preset_key;
- const char *export_name;
-};
-
-static const LoadingScreenInfo loading_screen_infos[] = {
- { "landscape_launch_screens/iphone_2208x1242", "Default-Landscape-736h@3x.png" },
- { "landscape_launch_screens/ipad_2732x2048", "Default-Landscape-1366h@2x.png" },
- { "landscape_launch_screens/ipad_2048x1536", "Default-Landscape@2x.png" },
-
- { "portrait_launch_screens/iphone_640x1136", "Default-568h@2x.png" },
- { "portrait_launch_screens/iphone_750x1334", "Default-667h@2x.png" },
- { "portrait_launch_screens/iphone_1242x2208", "Default-Portrait-736h@3x.png" },
- { "portrait_launch_screens/ipad_2048x2732", "Default-Portrait-1366h@2x.png" },
- { "portrait_launch_screens/ipad_1536x2048", "Default-Portrait@2x.png" }
-};
-
Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPreset> &p_preset, const String &p_dest_dir) {
DirAccess *da = DirAccess::open(p_dest_dir);
ERR_FAIL_COND_V(!da, ERR_CANT_OPEN);
@@ -404,12 +406,14 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre
for (int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) {
LoadingScreenInfo info = loading_screen_infos[i];
String loading_screen_file = p_preset->get(info.preset_key);
- Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
- if (err) {
- memdelete(da);
- String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file;
- ERR_PRINT(err_str.utf8().get_data());
- return err;
+ if (loading_screen_file.size() > 0) {
+ Error err = da->copy(loading_screen_file, p_dest_dir + info.export_name);
+ if (err) {
+ memdelete(da);
+ String err_str = String("Failed to export loading screen (") + info.preset_key + ") from path: " + loading_screen_file;
+ ERR_PRINT(err_str.utf8().get_data());
+ return err;
+ }
}
}
memdelete(da);
@@ -488,7 +492,7 @@ private:
ret.resize(sizeof(num) * 2);
for (int i = 0; i < sizeof(num) * 2; ++i) {
uint8_t four_bits = (num >> (sizeof(num) * 8 - (i + 1) * 4)) & 0xF;
- ret[i] = _hex_char(four_bits);
+ ret.write[i] = _hex_char(four_bits);
}
return String::utf8(ret.ptr(), ret.size());
}
@@ -586,7 +590,7 @@ void EditorExportPlatformIOS::_add_assets_to_project(Vector<uint8_t> &p_project_
CharString cs = str.utf8();
p_project_data.resize(cs.size() - 1);
for (int i = 0; i < cs.size() - 1; i++) {
- p_project_data[i] = cs[i];
+ p_project_data.write[i] = cs[i];
}
}
@@ -735,7 +739,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".fat.a";
- print_line("static library: " + library_to_use);
+ print_line("Static library: " + library_to_use);
String pkg_name;
if (p_preset->get("application/name") != "")
pkg_name = p_preset->get("application/name"); // app_name
@@ -780,7 +784,9 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
int ret = unzGoToFirstFile(src_pkg_zip);
Vector<uint8_t> project_file_data;
while (ret == UNZ_OK) {
+#if defined(OSX_ENABLED) || defined(X11_ENABLED)
bool is_execute = false;
+#endif
//get filename
unz_file_info info;
@@ -803,7 +809,6 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
file = file.replace_first("iphone/", "");
if (files_to_parse.has(file)) {
- print_line(String("parse ") + file);
_fix_config_file(p_preset, data, config_data, p_debug);
} else if (file.begins_with("libgodot.iphone")) {
if (file != library_to_use) {
@@ -811,7 +816,9 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
continue; //ignore!
}
found_library = true;
+#if defined(OSX_ENABLED) || defined(X11_ENABLED)
is_execute = true;
+#endif
file = "godot_ios.a";
}
if (file == project_file) {
@@ -854,7 +861,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
f->close();
memdelete(f);
-#ifdef OSX_ENABLED
+#if defined(OSX_ENABLED) || defined(X11_ENABLED)
if (is_execute) {
// we need execute rights on this file
chmod(file.utf8().get_data(), 0755);
@@ -887,7 +894,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
if (err)
return err;
- err = _export_loading_screens(p_preset, dest_dir + binary_name + "/");
+ err = _export_loading_screens(p_preset, dest_dir + binary_name + "/Images.xcassets/LaunchImage.launchimage/");
if (err)
return err;
diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm
index 57ff79f7bc..e210bfb862 100644
--- a/platform/iphone/game_center.mm
+++ b/platform/iphone/game_center.mm
@@ -139,7 +139,6 @@ Error GameCenter::post_score(Variant p_score) {
[GKScore reportScores:@[ reporter ]
withCompletionHandler:^(NSError *error) {
-
Dictionary ret;
ret["type"] = "post_score";
if (error == nil) {
@@ -177,7 +176,6 @@ Error GameCenter::award_achievement(Variant p_params) {
[GKAchievement reportAchievements:@[ achievement ]
withCompletionHandler:^(NSError *error) {
-
Dictionary ret;
ret["type"] = "award_achievement";
if (error == nil) {
@@ -196,7 +194,6 @@ Error GameCenter::award_achievement(Variant p_params) {
void GameCenter::request_achievement_descriptions() {
[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:^(NSArray *descriptions, NSError *error) {
-
Dictionary ret;
ret["type"] = "achievement_descriptions";
if (error == nil) {
@@ -252,7 +249,6 @@ void GameCenter::request_achievement_descriptions() {
void GameCenter::request_achievements() {
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
-
Dictionary ret;
ret["type"] = "achievements";
if (error == nil) {
@@ -347,7 +343,6 @@ Error GameCenter::request_identity_verification_signature() {
GKLocalPlayer *player = [GKLocalPlayer localPlayer];
[player generateIdentityVerificationSignatureWithCompletionHandler:^(NSURL *publicKeyUrl, NSData *signature, NSData *salt, uint64_t timestamp, NSError *error) {
-
Dictionary ret;
ret["type"] = "identity_verification_signature";
if (error == nil) {
diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h
index 85376ebc08..0d101eb696 100644
--- a/platform/iphone/gl_view.h
+++ b/platform/iphone/gl_view.h
@@ -83,6 +83,8 @@
@property(strong, nonatomic) MPMoviePlayerController *moviePlayerController;
@property(strong, nonatomic) UIWindow *backgroundWindow;
+@property(nonatomic) UITextAutocorrectionType autocorrectionType;
+
- (void)startAnimation;
- (void)stopAnimation;
- (void)drawView;
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 69116c64c6..478a3125af 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -78,6 +78,16 @@ void _hide_keyboard() {
keyboard_text = "";
};
+Rect2 _get_ios_window_safe_area(float p_window_width, float p_window_height) {
+ UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, 0, 0);
+ if (_instance != nil && [_instance respondsToSelector:@selector(safeAreaInsets)]) {
+ insets = [_instance safeAreaInsets];
+ }
+ ERR_FAIL_COND_V(insets.left < 0 || insets.top < 0 || insets.right < 0 || insets.bottom < 0,
+ Rect2(0, 0, p_window_width, p_window_height));
+ return Rect2(insets.left, insets.top, p_window_width - insets.right - insets.left, p_window_height - insets.bottom - insets.top);
+}
+
bool _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
p_path = ProjectSettings::get_singleton()->globalize_path(p_path);
@@ -326,9 +336,7 @@ static void clear_touches() {
// Generate IDs for a framebuffer object and a color renderbuffer
UIScreen *mainscr = [UIScreen mainScreen];
printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height);
- float minPointSize = MIN(mainscr.bounds.size.width, mainscr.bounds.size.height);
- float minScreenSize = MIN(mainscr.currentMode.size.width, mainscr.currentMode.size.height);
- self.contentScaleFactor = minScreenSize / minPointSize;
+ self.contentScaleFactor = mainscr.nativeScale;
glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);
@@ -489,7 +497,7 @@ static void clear_touches() {
int tid = get_touch_id(touch);
ERR_FAIL_COND(tid == -1);
CGPoint touchPoint = [touch locationInView:self];
- OSIPhone::get_singleton()->mouse_button(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1, tid == 0);
+ OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
};
};
}
@@ -506,10 +514,9 @@ static void clear_touches() {
continue;
int tid = get_touch_id(touch);
ERR_FAIL_COND(tid == -1);
- int first = get_first_id(touch);
CGPoint touchPoint = [touch locationInView:self];
CGPoint prev_point = [touch previousLocationInView:self];
- OSIPhone::get_singleton()->mouse_move(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, first == tid);
+ OSIPhone::get_singleton()->touch_drag(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor);
};
};
}
@@ -525,9 +532,9 @@ static void clear_touches() {
continue;
int tid = get_touch_id(touch);
ERR_FAIL_COND(tid == -1);
- int rem = remove_touch(touch);
+ remove_touch(touch);
CGPoint touchPoint = [touch locationInView:self];
- OSIPhone::get_singleton()->mouse_button(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false, rem == 0);
+ OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, false, false);
};
};
}
@@ -627,6 +634,7 @@ static void clear_touches() {
}
init_touches();
self.multipleTouchEnabled = YES;
+ self.autocorrectionType = UITextAutocorrectionTypeNo;
printf("******** adding observer for sound routing changes\n");
[[NSNotificationCenter defaultCenter]
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm
index 7508a480ce..a9748bf562 100644
--- a/platform/iphone/icloud.mm
+++ b/platform/iphone/icloud.mm
@@ -131,6 +131,8 @@ Variant nsobject_to_variant(NSObject *object) {
return Variant([num floatValue]);
} else if (strcmp([num objCType], @encode(double)) == 0) {
return Variant((float)[num doubleValue]);
+ } else {
+ return Variant();
}
} else if ([object isKindOfClass:[NSDate class]]) {
//this is a type that icloud supports...but how did you submit it in the first place?
diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h
index 7d53eaae20..353438676d 100644
--- a/platform/iphone/in_app_store.h
+++ b/platform/iphone/in_app_store.h
@@ -46,6 +46,7 @@ class InAppStore : public Object {
public:
Error request_product_info(Variant p_params);
+ Error restore_purchases();
Error purchase(Variant p_params);
int get_pending_event_count();
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index 9bb3d7d3fa..2cdd477ed1 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -63,6 +63,7 @@ InAppStore *InAppStore::instance = NULL;
void InAppStore::_bind_methods() {
ClassDB::bind_method(D_METHOD("request_product_info"), &InAppStore::request_product_info);
+ ClassDB::bind_method(D_METHOD("restore_purchases"), &InAppStore::restore_purchases);
ClassDB::bind_method(D_METHOD("purchase"), &InAppStore::purchase);
ClassDB::bind_method(D_METHOD("get_pending_event_count"), &InAppStore::get_pending_event_count);
@@ -153,6 +154,14 @@ Error InAppStore::request_product_info(Variant p_params) {
return OK;
};
+Error InAppStore::restore_purchases() {
+
+ printf("restoring purchases!\n");
+ [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
+
+ return OK;
+};
+
@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
};
@end
@@ -229,6 +238,7 @@ Error InAppStore::request_product_info(Variant p_params) {
ret["type"] = "purchase";
ret["result"] = "error";
ret["product_id"] = pid;
+ ret["error"] = String::utf8([transaction.error.localizedDescription UTF8String]);
InAppStore::get_singleton()->_post_event(ret);
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
} break;
@@ -236,6 +246,11 @@ Error InAppStore::request_product_info(Variant p_params) {
printf("status transaction restored!\n");
String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
InAppStore::get_singleton()->_record_purchase(pid);
+ Dictionary ret;
+ ret["type"] = "restore";
+ ret["result"] = "ok";
+ ret["product_id"] = pid;
+ InAppStore::get_singleton()->_post_event(ret);
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
} break;
default: {
diff --git a/platform/iphone/logo.png b/platform/iphone/logo.png
index 8dd718524c..405b6f93ca 100644
--- a/platform/iphone/logo.png
+++ b/platform/iphone/logo.png
Binary files differ
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index c284ab6905..a4538a6673 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -64,11 +64,6 @@ OSIPhone *OSIPhone::get_singleton() {
return (OSIPhone *)OS::get_singleton();
};
-uint8_t OSIPhone::get_orientations() const {
-
- return supported_orientations;
-};
-
extern int gl_view_base_fb; // from gl_view.mm
void OSIPhone::set_data_dir(String p_dir) {
@@ -98,13 +93,13 @@ void OSIPhone::initialize_core() {
set_data_dir(data_dir);
};
+int OSIPhone::get_current_video_driver() const {
+ return video_driver_index;
+}
+
Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
- supported_orientations = 0;
- supported_orientations |= ((GLOBAL_DEF("video_mode/allow_horizontal", true) ? 1 : 0) << LandscapeLeft);
- supported_orientations |= ((GLOBAL_DEF("video_mode/allow_horizontal_flipped", false) ? 1 : 0) << LandscapeRight);
- supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical", false) ? 1 : 0) << PortraitDown);
- supported_orientations |= ((GLOBAL_DEF("video_mode/allow_vertical_flipped", false) ? 1 : 0) << PortraitUp);
+ video_driver_index = p_video_driver; //this may be misleading
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
@@ -123,7 +118,6 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
// reset this to what it should be, it will have been set to 0 after visual_server->init() is called
RasterizerStorageGLES3::system_fbo = gl_view_base_fb;
- AudioDriverManager::add_driver(&audio_driver);
AudioDriverManager::initialize(p_audio_driver);
input = memnew(InputDefault);
@@ -191,7 +185,7 @@ void OSIPhone::key(uint32_t p_key, bool p_pressed) {
queue_event(ev);
};
-void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, bool p_use_as_mouse) {
+void OSIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
Ref<InputEventScreenTouch> ev;
@@ -203,28 +197,10 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
queue_event(ev);
};
- mouse_list.pressed[p_idx] = p_pressed;
-
- if (p_use_as_mouse) {
-
- Ref<InputEventMouseButton> ev;
- ev.instance();
-
- ev->set_position(Vector2(p_x, p_y));
- ev->set_global_position(Vector2(p_x, p_y));
-
- //mouse_list.pressed[p_idx] = p_pressed;
-
- input->set_mouse_position(ev->get_position());
- ev->set_button_index(BUTTON_LEFT);
- ev->set_doubleclick(p_doubleclick);
- ev->set_pressed(p_pressed);
-
- queue_event(ev);
- };
+ touch_list.pressed[p_idx] = p_pressed;
};
-void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, bool p_use_as_mouse) {
+void OSIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y) {
if (!GLOBAL_DEF("debug/disable_touch", false)) {
@@ -235,21 +211,6 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
queue_event(ev);
};
-
- if (p_use_as_mouse) {
- Ref<InputEventMouseMotion> ev;
- ev.instance();
-
- ev->set_position(Vector2(p_x, p_y));
- ev->set_global_position(Vector2(p_x, p_y));
- ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
-
- input->set_mouse_position(ev->get_position());
- ev->set_speed(input->get_last_mouse_speed());
- ev->set_button_mask(BUTTON_LEFT); // pressed
-
- queue_event(ev);
- };
};
void OSIPhone::queue_event(const Ref<InputEvent> &p_event) {
@@ -263,10 +224,10 @@ void OSIPhone::touches_cancelled() {
for (int i = 0; i < MAX_MOUSE_COUNT; i++) {
- if (mouse_list.pressed[i]) {
+ if (touch_list.pressed[i]) {
// send a mouse_up outside the screen
- mouse_button(i, -1, -1, false, false, false);
+ touch_press(i, -1, -1, false, false);
};
};
};
@@ -377,7 +338,7 @@ Point2 OSIPhone::get_mouse_position() const {
int OSIPhone::get_mouse_button_state() const {
- return mouse_list.pressed[0];
+ return 0;
};
void OSIPhone::set_window_title(const String &p_title){};
@@ -505,6 +466,12 @@ Size2 OSIPhone::get_window_size() const {
return Vector2(video_mode.width, video_mode.height);
}
+extern Rect2 _get_ios_window_safe_area(float p_window_width, float p_window_height);
+
+Rect2 OSIPhone::get_window_safe_area() const {
+ return _get_ios_window_safe_area(video_mode.width, video_mode.height);
+}
+
bool OSIPhone::has_touchscreen_ui_hint() const {
return true;
@@ -632,6 +599,8 @@ OSIPhone::OSIPhone(int width, int height, String p_data_dir) {
loggers.push_back(memnew(StdLogger));
#endif
_set_logger(memnew(CompositeLogger(loggers)));
+
+ AudioDriverManager::add_driver(&audio_driver);
};
OSIPhone::~OSIPhone() {
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 2e4458aeed..db2912ad93 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -47,14 +47,6 @@
class OSIPhone : public OS_Unix {
-public:
- enum Orientations {
- PortraitDown,
- PortraitUp,
- LandscapeLeft,
- LandscapeRight,
- };
-
private:
enum {
MAX_MOUSE_COUNT = 8,
@@ -64,8 +56,6 @@ private:
static HashMap<String, void *> dynamic_symbol_lookup_table;
friend void register_dynamic_symbol(char *name, void *address);
- uint8_t supported_orientations;
-
VisualServer *visual_server;
AudioDriverCoreAudio audio_driver;
@@ -87,6 +77,8 @@ private:
virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) const;
+ virtual int get_current_video_driver() const;
+
virtual void initialize_core();
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
@@ -106,7 +98,7 @@ private:
};
};
- MouseList mouse_list;
+ MouseList touch_list;
Vector3 last_accel;
@@ -122,13 +114,15 @@ private:
int virtual_keyboard_height;
+ int video_driver_index;
+
public:
bool iterate();
uint8_t get_orientations() const;
- void mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, bool p_use_as_mouse);
- void mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, bool p_use_as_mouse);
+ void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick);
+ void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y);
void touches_cancelled();
void key(uint32_t p_key, bool p_pressed);
void set_virtual_keyboard_height(int p_height);
@@ -177,6 +171,7 @@ public:
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot);
virtual Size2 get_window_size() const;
+ virtual Rect2 get_window_safe_area() const;
virtual bool has_touchscreen_ui_hint() const;
diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h
index d205c7da83..d9fd61fb6e 100644
--- a/platform/iphone/platform_config.h
+++ b/platform/iphone/platform_config.h
@@ -30,6 +30,7 @@
#include <alloca.h>
+#define GLES2_INCLUDE_H <ES2/gl.h>
#define GLES3_INCLUDE_H <ES3/gl.h>
#define PLATFORM_REFCOUNT
diff --git a/platform/iphone/power_iphone.cpp b/platform/iphone/power_iphone.cpp
index 95a9aa9705..7f9dadc363 100644
--- a/platform/iphone/power_iphone.cpp
+++ b/platform/iphone/power_iphone.cpp
@@ -30,7 +30,7 @@
#include "power_iphone.h"
-bool OS::PowerState::UpdatePowerInfo() {
+bool PowerIphone::UpdatePowerInfo() {
return false;
}
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index cdaae0cb81..f75f0fd812 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -83,51 +83,36 @@ int add_cmdline(int p_argc, char **p_args) {
printf("*********** did receive memory warning!\n");
};
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)p_orientation {
-
- if (/*OSIPhone::get_singleton() == NULL*/ TRUE) {
-
- printf("checking on info.plist\n");
- NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
- switch (p_orientation) {
-
- case UIInterfaceOrientationLandscapeLeft:
- return [arr indexOfObject:@"UIInterfaceOrientationLandscapeLeft"] != NSNotFound ? YES : NO;
-
- case UIInterfaceOrientationLandscapeRight:
- return [arr indexOfObject:@"UIInterfaceOrientationLandscapeRight"] != NSNotFound ? YES : NO;
-
- case UIInterfaceOrientationPortrait:
- return [arr indexOfObject:@"UIInterfaceOrientationPortrait"] != NSNotFound ? YES : NO;
-
- case UIInterfaceOrientationPortraitUpsideDown:
- return [arr indexOfObject:@"UIInterfaceOrientationPortraitUpsideDown"] != NSNotFound ? YES : NO;
-
- default:
- return NO;
- }
- };
-
- uint8_t supported = OSIPhone::get_singleton()->get_orientations();
- switch (p_orientation) {
-
- case UIInterfaceOrientationLandscapeLeft:
- return supported & (1 << OSIPhone::LandscapeLeft) ? YES : NO;
-
- case UIInterfaceOrientationLandscapeRight:
- return supported & (1 << OSIPhone::LandscapeRight) ? YES : NO;
-
- case UIInterfaceOrientationPortrait:
- return supported & (1 << OSIPhone::PortraitDown) ? YES : NO;
-
- case UIInterfaceOrientationPortraitUpsideDown:
- return supported & (1 << OSIPhone::PortraitUp) ? YES : NO;
-
+- (BOOL)shouldAutorotate {
+ switch (OS::get_singleton()->get_screen_orientation()) {
+ case OS::SCREEN_SENSOR:
+ case OS::SCREEN_SENSOR_LANDSCAPE:
+ case OS::SCREEN_SENSOR_PORTRAIT:
+ return YES;
default:
return NO;
}
};
+- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
+ switch (OS::get_singleton()->get_screen_orientation()) {
+ case OS::SCREEN_PORTRAIT:
+ return UIInterfaceOrientationMaskPortrait;
+ case OS::SCREEN_REVERSE_LANDSCAPE:
+ return UIInterfaceOrientationMaskLandscapeRight;
+ case OS::SCREEN_REVERSE_PORTRAIT:
+ return UIInterfaceOrientationMaskPortraitUpsideDown;
+ case OS::SCREEN_SENSOR_LANDSCAPE:
+ return UIInterfaceOrientationMaskLandscape;
+ case OS::SCREEN_SENSOR_PORTRAIT:
+ return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
+ case OS::SCREEN_SENSOR:
+ return UIInterfaceOrientationMaskAll;
+ case OS::SCREEN_LANDSCAPE:
+ return UIInterfaceOrientationMaskLandscapeLeft;
+ }
+};
+
- (BOOL)prefersStatusBarHidden {
return YES;
}