summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/app_delegate.mm11
-rw-r--r--platform/iphone/display_layer.mm12
-rw-r--r--platform/iphone/display_server_iphone.mm23
-rw-r--r--platform/iphone/godot_iphone.mm12
-rw-r--r--platform/iphone/godot_view.mm6
-rw-r--r--platform/iphone/godot_view_gesture_recognizer.mm1
-rw-r--r--platform/iphone/godot_view_renderer.mm3
-rw-r--r--platform/iphone/ios.mm5
-rw-r--r--platform/iphone/joypad_iphone.mm27
-rw-r--r--platform/iphone/os_iphone.h1
-rw-r--r--platform/iphone/os_iphone.mm22
-rw-r--r--platform/iphone/view_controller.mm2
12 files changed, 68 insertions, 57 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 5130a26f15..c5c9b5a5f9 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "app_delegate.h"
+
#include "core/config/project_settings.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#import "godot_view.h"
@@ -76,7 +77,7 @@ static ViewController *mainViewController = nil;
// bail, things did not go very well for us, should probably output a message on screen with our error code...
exit(0);
return NO;
- };
+ }
ViewController *viewController = [[ViewController alloc] init];
viewController.godotView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
@@ -99,7 +100,7 @@ static ViewController *mainViewController = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
return YES;
-};
+}
- (void)onAudioInterruption:(NSNotification *)notification {
if ([notification.name isEqualToString:AVAudioSessionInterruptionNotification]) {
@@ -111,17 +112,17 @@ static ViewController *mainViewController = nil;
OSIPhone::get_singleton()->on_focus_in();
}
}
-};
+}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
}
-};
+}
- (void)applicationWillTerminate:(UIApplication *)application {
iphone_finish();
-};
+}
// When application goes to background (e.g. user switches to another app or presses Home),
// then applicationWillResignActive -> applicationDidEnterBackground are called.
diff --git a/platform/iphone/display_layer.mm b/platform/iphone/display_layer.mm
index 7448dfed4a..92e81448ac 100644
--- a/platform/iphone/display_layer.mm
+++ b/platform/iphone/display_layer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "display_layer.h"
+
#include "core/config/project_settings.h"
#include "core/os/keyboard.h"
#include "display_server_iphone.h"
@@ -153,17 +154,6 @@
return NO;
}
- // if (OS::get_singleton()) {
- // OS::VideoMode vm;
- // vm.fullscreen = true;
- // vm.width = backingWidth;
- // vm.height = backingHeight;
- // vm.resizable = false;
- // OS::get_singleton()->set_video_mode(vm);
- // OSIPhone::get_singleton()->set_base_framebuffer(viewFramebuffer);
- // };
- // gl_view_base_fb = viewFramebuffer;
-
return YES;
}
diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm
index 9491c9cf90..a0f8daf5a0 100644
--- a/platform/iphone/display_server_iphone.mm
+++ b/platform/iphone/display_server_iphone.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "display_server_iphone.h"
+
#import "app_delegate.h"
#include "core/config/project_settings.h"
#include "core/io/file_access_pack.h"
@@ -231,7 +232,7 @@ void DisplayServerIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_presse
ev->set_position(Vector2(p_x, p_y));
perform_event(ev);
}
-};
+}
void DisplayServerIPhone::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)) {
@@ -241,16 +242,16 @@ void DisplayServerIPhone::touch_drag(int p_idx, int p_prev_x, int p_prev_y, int
ev->set_position(Vector2(p_x, p_y));
ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y));
perform_event(ev);
- };
-};
+ }
+}
void DisplayServerIPhone::perform_event(const Ref<InputEvent> &p_event) {
Input::get_singleton()->parse_input_event(p_event);
-};
+}
void DisplayServerIPhone::touches_cancelled(int p_idx) {
touch_press(p_idx, -1, -1, false, false);
-};
+}
// MARK: Keyboard
@@ -263,13 +264,13 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) {
ev->set_physical_keycode(p_key);
ev->set_unicode((char32_t)p_key);
perform_event(ev);
-};
+}
// MARK: Motion
void DisplayServerIPhone::update_gravity(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_gravity(Vector3(p_x, p_y, p_z));
-};
+}
void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
// Found out the Z should not be negated! Pass as is!
@@ -279,15 +280,15 @@ void DisplayServerIPhone::update_accelerometer(float p_x, float p_y, float p_z)
p_z / kDisplayServerIPhoneAcceleration);
Input::get_singleton()->set_accelerometer(v_accelerometer);
-};
+}
void DisplayServerIPhone::update_magnetometer(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_magnetometer(Vector3(p_x, p_y, p_z));
-};
+}
void DisplayServerIPhone::update_gyroscope(float p_x, float p_y, float p_z) {
Input::get_singleton()->set_gyroscope(Vector3(p_x, p_y, p_z));
-};
+}
// MARK: -
@@ -520,7 +521,7 @@ void DisplayServerIPhone::window_move_to_foreground(WindowID p_window) {
float DisplayServerIPhone::screen_get_max_scale() const {
return screen_get_scale(SCREEN_OF_MAIN_WINDOW);
-};
+}
void DisplayServerIPhone::screen_set_orientation(DisplayServer::ScreenOrientation p_orientation, int p_screen) {
screen_orientation = p_orientation;
diff --git a/platform/iphone/godot_iphone.mm b/platform/iphone/godot_iphone.mm
index a76276e815..49474ef554 100644
--- a/platform/iphone/godot_iphone.mm
+++ b/platform/iphone/godot_iphone.mm
@@ -53,7 +53,7 @@ int add_path(int p_argc, char **p_args) {
p_args[p_argc] = nullptr;
return p_argc;
-};
+}
int add_cmdline(int p_argc, char **p_args) {
NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
@@ -67,12 +67,12 @@ int add_cmdline(int p_argc, char **p_args) {
continue;
}
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding];
- };
+ }
p_args[p_argc] = nullptr;
return p_argc;
-};
+}
int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
size_t len = strlen(argv[0]);
@@ -103,7 +103,7 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
char *fargv[64];
for (int i = 0; i < argc; i++) {
fargv[i] = argv[i];
- };
+ }
fargv[argc] = nullptr;
argc = add_path(argc, fargv);
argc = add_cmdline(argc, fargv);
@@ -119,10 +119,10 @@ int iphone_main(int argc, char **argv, String data_dir, String cache_dir) {
os->initialize_modules();
return 0;
-};
+}
void iphone_finish() {
printf("iphone_finish\n");
Main::cleanup();
delete os;
-};
+}
diff --git a/platform/iphone/godot_view.mm b/platform/iphone/godot_view.mm
index ae92f32851..da71312fc4 100644
--- a/platform/iphone/godot_view.mm
+++ b/platform/iphone/godot_view.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view.h"
+
#include "core/os/keyboard.h"
#include "core/string/ustring.h"
#import "display_layer.h"
@@ -226,8 +227,9 @@ static const float earth_gravity = 9.80665;
[self.displayLink setPaused:YES];
// Process all input events
- while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource)
- ;
+ while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) {
+ // Continue.
+ }
// We are good to go, resume the CADisplayLink
[self.displayLink setPaused:NO];
diff --git a/platform/iphone/godot_view_gesture_recognizer.mm b/platform/iphone/godot_view_gesture_recognizer.mm
index a46c42765a..18939f7108 100644
--- a/platform/iphone/godot_view_gesture_recognizer.mm
+++ b/platform/iphone/godot_view_gesture_recognizer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view_gesture_recognizer.h"
+
#import "godot_view.h"
#include "core/config/project_settings.h"
diff --git a/platform/iphone/godot_view_renderer.mm b/platform/iphone/godot_view_renderer.mm
index e49edf5b74..32477ae41c 100644
--- a/platform/iphone/godot_view_renderer.mm
+++ b/platform/iphone/godot_view_renderer.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "godot_view_renderer.h"
+
#include "core/config/project_settings.h"
#include "core/os/keyboard.h"
#import "display_server_iphone.h"
@@ -101,7 +102,7 @@
double dval = [n doubleValue];
ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval);
- };
+ }
// do stuff
}
}
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index da21ad0ace..ad1ea70c10 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "ios.h"
+
#import "app_delegate.h"
#import "view_controller.h"
#import <UIKit/UIKit.h>
@@ -36,7 +37,7 @@
void iOS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
-};
+}
void iOS::alert(const char *p_alert, const char *p_title) {
NSString *title = [NSString stringWithUTF8String:p_title];
@@ -75,6 +76,6 @@ String iOS::get_rate_url(int p_app_id) const {
printf("returning rate url %s\n", ret.utf8().get_data());
return ret;
-};
+}
iOS::iOS() {}
diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm
index f45f4da5a8..9c2feeaaca 100644
--- a/platform/iphone/joypad_iphone.mm
+++ b/platform/iphone/joypad_iphone.mm
@@ -29,6 +29,7 @@
/*************************************************************************/
#import "joypad_iphone.h"
+
#include "core/config/project_settings.h"
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "main/main.h"
@@ -139,10 +140,10 @@ void JoypadIPhone::start_processing() {
for (NSNumber *key in keys) {
int joy_id = [key intValue];
return joy_id;
- };
+ }
return -1;
-};
+}
- (void)addiOSJoypad:(GCController *)controller {
// get a new id for our controller
@@ -156,7 +157,7 @@ void JoypadIPhone::start_processing() {
// assign our player index
if (controller.playerIndex == GCControllerPlayerIndexUnset) {
controller.playerIndex = [self getFreePlayerIndex];
- };
+ }
// tell Godot about our new controller
Input::get_singleton()->joy_connection_changed(joy_id, true, String::utf8([controller.vendorName UTF8String]));
@@ -202,8 +203,8 @@ void JoypadIPhone::start_processing() {
// and remove it from our dictionary
[self.connectedJoypads removeObjectForKey:key];
- };
-};
+ }
+}
- (GCControllerPlayerIndex)getFreePlayerIndex {
bool have_player_1 = false;
@@ -223,9 +224,9 @@ void JoypadIPhone::start_processing() {
have_player_3 = true;
} else if (controller.playerIndex == GCControllerPlayerIndex4) {
have_player_4 = true;
- };
- };
- };
+ }
+ }
+ }
if (!have_player_1) {
return GCControllerPlayerIndex1;
@@ -237,7 +238,7 @@ void JoypadIPhone::start_processing() {
return GCControllerPlayerIndex4;
} else {
return GCControllerPlayerIndexUnset;
- };
+ }
}
- (void)setControllerInputHandler:(GCController *)controller {
@@ -285,7 +286,7 @@ void JoypadIPhone::start_processing() {
gamepad.dpad.left.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT,
gamepad.dpad.right.isPressed);
- };
+ }
if (element == gamepad.leftThumbstick) {
float value = gamepad.leftThumbstick.xAxis.value;
@@ -303,7 +304,7 @@ void JoypadIPhone::start_processing() {
} else if (element == gamepad.rightTrigger) {
float value = gamepad.rightTrigger.value;
Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, value);
- };
+ }
};
} else if (controller.microGamepad != nil) {
// micro gamepads were added in OS 9 and feature just 2 buttons and a d-pad
@@ -329,7 +330,7 @@ void JoypadIPhone::start_processing() {
gamepad.dpad.down.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed);
Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed);
- };
+ }
};
}
@@ -338,6 +339,6 @@ void JoypadIPhone::start_processing() {
///@TODO need to add support for controllerPausedHandler which should be a
/// toggle
-};
+}
@end
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index aca6f5fe2b..3281ff0cdb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -109,6 +109,7 @@ public:
virtual String get_locale() const override;
virtual String get_unique_id() const override;
+ virtual String get_processor_name() const override;
virtual void vibrate_handheld(int p_duration_ms = 500) override;
diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm
index 8350365d88..56cb49318c 100644
--- a/platform/iphone/os_iphone.mm
+++ b/platform/iphone/os_iphone.mm
@@ -31,6 +31,7 @@
#ifdef IPHONE_ENABLED
#include "os_iphone.h"
+
#import "app_delegate.h"
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
@@ -45,6 +46,7 @@
#import <AudioToolbox/AudioServices.h>
#import <UIKit/UIKit.h>
#import <dlfcn.h>
+#include <sys/sysctl.h>
#if defined(VULKAN_ENABLED)
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
@@ -168,7 +170,7 @@ void OSIPhone::delete_main_loop() {
if (main_loop) {
main_loop->finalize();
memdelete(main_loop);
- };
+ }
main_loop = nullptr;
}
@@ -197,7 +199,7 @@ void OSIPhone::finalize() {
deinitialize_modules();
// Already gets called
- // delete_main_loop();
+ //delete_main_loop();
}
// MARK: Dynamic Libraries
@@ -230,12 +232,13 @@ Error OSIPhone::get_dynamic_library_symbol_handle(void *p_library_handle, const
String OSIPhone::get_name() const {
return "iOS";
-};
+}
String OSIPhone::get_model_name() const {
String model = ios->get_model();
- if (model != "")
+ if (model != "") {
return model;
+ }
return OS_Unix::get_model_name();
}
@@ -253,7 +256,7 @@ Error OSIPhone::shell_open(String p_uri) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
return OK;
-};
+}
void OSIPhone::set_user_data_dir(String p_dir) {
DirAccess *da = DirAccess::open(p_dir);
@@ -287,6 +290,15 @@ String OSIPhone::get_unique_id() const {
return String::utf8([uuid UTF8String]);
}
+String OSIPhone::get_processor_name() const {
+ char buffer[256];
+ size_t buffer_len = 256;
+ if (sysctlbyname("machdep.cpu.brand_string", &buffer, &buffer_len, NULL, 0) == 0) {
+ return String::utf8(buffer, buffer_len);
+ }
+ ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name. Returning an empty string."));
+}
+
void OSIPhone::vibrate_handheld(int p_duration_ms) {
// iOS does not support duration for vibration
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index e1fc645c13..4f4ef4f046 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -203,7 +203,7 @@
case DisplayServer::SCREEN_LANDSCAPE:
return UIInterfaceOrientationMaskLandscapeLeft;
}
-};
+}
- (BOOL)prefersStatusBarHidden {
return YES;