summaryrefslogtreecommitdiff
path: root/platform/iphone
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-12-02 14:02:41 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-12-02 14:02:41 -0300
commite361e8539c889d3ca66e77ebb5d0ceb61d17f49d (patch)
treee34bb70d58e8d023df34c3e6744b5cdfa866ef7d /platform/iphone
parent9d5a2cb8470d538fa33f9f7b4d6cdd5390b3b70b (diff)
-Ability to ask for documents/pictures/etc system dirs.
-Fixes to animationplayer -fixes to collada importer
Diffstat (limited to 'platform/iphone')
-rw-r--r--platform/iphone/app_delegate.h4
-rw-r--r--platform/iphone/app_delegate.mm9
-rw-r--r--platform/iphone/detect.py7
-rwxr-xr-xplatform/iphone/gl_view.mm19
-rw-r--r--platform/iphone/os_iphone.cpp53
-rw-r--r--platform/iphone/os_iphone.h1
6 files changed, 67 insertions, 26 deletions
diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h
index db641b1f78..9437e04738 100644
--- a/platform/iphone/app_delegate.h
+++ b/platform/iphone/app_delegate.h
@@ -31,12 +31,14 @@
#import "view_controller.h"
@interface AppDelegate : NSObject <UIApplicationDelegate, UIAccelerometerDelegate, GLViewDelegate> {
- UIWindow *window;
+ //@property (strong, nonatomic) UIWindow *window;
ViewController* view_controller;
UIAccelerationValue accel[3];
UIAccelerationValue last_accel[3];
};
+@property (strong, nonatomic) UIWindow *window;
+
+ (ViewController*)getViewController;
@end
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index e214b75bb0..6ca54286ba 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -65,6 +65,8 @@ Error _shell_open(String p_uri) {
@implementation AppDelegate
+@synthesize window;
+
extern int gargc;
extern char** gargv;
extern int iphone_main(int, int, int, char**);
@@ -127,7 +129,7 @@ static int frame_count = 0;
OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String]));
- }; // break;
+ }; break;
/*
case 1: {
++frame_count;
@@ -154,7 +156,7 @@ static int frame_count = 0;
[Appirater appLaunched:YES app_id:aid];
#endif
- }; // break; fallthrough
+ }; break; // no fallthrough
default: {
@@ -260,6 +262,9 @@ static int frame_count = 0;
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();
+ };
}
- (void)applicationWillEnterForeground:(UIApplication *)application
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index a5ce376b8f..93345be730 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -21,8 +21,7 @@ def get_opts():
return [
('IPHONEPLATFORM', 'name of the iphone platform', 'iPhoneOS'),
('IPHONEPATH', 'the path to iphone toolchain', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain'),
- #('IOS_SDK_VERSION', 'The SDK version', 'iPhoneOS7.0'),
- ('IOS_SDK_VERSION', 'The SDK version', 'iPhoneOS8.1'),
+ ('IOS_SDK_VERSION', 'The SDK version', 'iPhoneOS'),
('IPHONESDK', 'path to the iphone SDK', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${IOS_SDK_VERSION}.sdk/'),
('game_center', 'Support for game center', 'yes'),
('store_kit', 'Support for in-app store', 'yes'),
@@ -96,8 +95,8 @@ def configure(env):
if (env["target"]=="release"):
- env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall'])
- env.Append(LINKFLAGS=['-Os', '-ffast-math'])
+ env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall'])
+ env.Append(LINKFLAGS=['-O3', '-ffast-math'])
elif env["target"] == "release_debug":
env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED'])
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 55b5eabacf..4dd2084c20 100755
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -125,6 +125,7 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
AVMediaSelectionGroup *audioGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicAudible];
+ NSMutableArray *allAudioParams = [NSMutableArray array];
for (id track in audioGroup.options)
{
NSString* language = [[track locale] localeIdentifier];
@@ -132,7 +133,17 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
if ([language isEqualToString:[NSString stringWithUTF8String:p_audio_track.utf8()]])
{
- [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: audioGroup];
+ AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
+ [audioInputParams setVolume:p_volume atTime:kCMTimeZero];
+ [audioInputParams setTrackID:[track trackID]];
+ [allAudioParams addObject:audioInputParams];
+
+ AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix];
+ [audioMix setInputParameters:allAudioParams];
+
+ [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: audioGroup];
+ [_instance.avPlayer.currentItem setAudioMix:audioMix];
+
break;
}
}
@@ -174,7 +185,13 @@ void _pause_video() {
video_playing = false;
}
+void _focus_out_video() {
+ printf("focus out pausing video\n");
+ [_instance.avPlayer pause];
+};
+
void _unpause_video() {
+
[_instance.avPlayer play];
video_playing = true;
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index c8a132c39b..812879d427 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -40,6 +40,7 @@
#include "audio_driver_iphone.h"
#include "core/os/dir_access.h"
+#include "core/os/file_access.h"
#include "core/globals.h"
#include "sem_iphone.h"
@@ -77,7 +78,7 @@ void OSIPhone::set_data_dir(String p_dir) {
DirAccess* da = DirAccess::open(p_dir);
data_dir = da->get_current_dir();
-
+ printf("setting data dir to %ls from %ls\n", data_dir.c_str(), p_dir.c_str());
memdelete(da);
};
@@ -211,14 +212,16 @@ void OSIPhone::key(uint32_t p_key, bool p_pressed) {
void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, bool p_use_as_mouse) {
- InputEvent ev;
- ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = ++last_event_id;
- ev.screen_touch.index=p_idx;
- ev.screen_touch.pressed=p_pressed;
- ev.screen_touch.x=p_x;
- ev.screen_touch.y=p_y;
- queue_event(ev);
+ if (!GLOBAL_DEF("debug/disable_touch", false)) {
+ InputEvent ev;
+ ev.type = InputEvent::SCREEN_TOUCH;
+ ev.ID = ++last_event_id;
+ ev.screen_touch.index=p_idx;
+ ev.screen_touch.pressed=p_pressed;
+ ev.screen_touch.x=p_x;
+ ev.screen_touch.y=p_y;
+ queue_event(ev);
+ };
if (p_use_as_mouse) {
@@ -247,15 +250,18 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
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) {
- InputEvent ev;
- ev.type=InputEvent::SCREEN_DRAG;
- ev.ID = ++last_event_id;
- ev.screen_drag.index=p_idx;
- ev.screen_drag.x=p_x;
- ev.screen_drag.y=p_y;
- ev.screen_drag.relative_x = p_x - p_prev_x;
- ev.screen_drag.relative_y = p_y - p_prev_y;
- queue_event(ev);
+ if (!GLOBAL_DEF("debug/disable_touch", false)) {
+
+ InputEvent ev;
+ ev.type=InputEvent::SCREEN_DRAG;
+ ev.ID = ++last_event_id;
+ ev.screen_drag.index=p_idx;
+ ev.screen_drag.x=p_x;
+ ev.screen_drag.y=p_y;
+ ev.screen_drag.relative_x = p_x - p_prev_x;
+ ev.screen_drag.relative_y = p_y - p_prev_y;
+ queue_event(ev);
+ };
if (p_use_as_mouse) {
InputEvent ev;
@@ -491,8 +497,16 @@ extern bool _is_video_playing();
extern void _pause_video();
extern void _unpause_video();
extern void _stop_video();
+extern void _focus_out_video();
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
+ FileAccess* f = FileAccess::open(p_path, FileAccess::READ);
+ bool exists = f && f->is_open();
+ printf("file exists for %ls, %i, %p\n", p_path.c_str(), (int)exists, f);
+ if (f)
+ memdelete(f);
+ if (!exists)
+ return FAILED;
if ( _play_video(p_path, p_volume, p_audio_track, p_subtitle_track) )
return OK;
return FAILED;
@@ -511,6 +525,9 @@ void OSIPhone::native_video_unpause() {
_unpause_video();
};
+void OSIPhone::native_video_focus_out() {
+ _focus_out_video();
+};
void OSIPhone::native_video_stop() {
if (native_video_is_playing())
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index bf8c5bb1c9..cb294d07eb 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -188,6 +188,7 @@ public:
virtual bool native_video_is_playing() const;
virtual void native_video_pause();
virtual void native_video_unpause();
+ virtual void native_video_focus_out();
virtual void native_video_stop();
OSIPhone(int width, int height);