diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/java/src/com/android/godot/GodotIO.java | 52 | ||||
-rw-r--r-- | platform/android/java_glue.cpp | 14 | ||||
-rw-r--r-- | platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java | 2 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 10 | ||||
-rw-r--r-- | platform/android/os_android.h | 13 | ||||
-rw-r--r-- | platform/iphone/app_delegate.h | 4 | ||||
-rw-r--r-- | platform/iphone/app_delegate.mm | 9 | ||||
-rw-r--r-- | platform/iphone/detect.py | 7 | ||||
-rwxr-xr-x | platform/iphone/gl_view.mm | 19 | ||||
-rw-r--r-- | platform/iphone/os_iphone.cpp | 53 | ||||
-rw-r--r-- | platform/iphone/os_iphone.h | 1 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 42 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 68 | ||||
-rw-r--r-- | platform/x11/os_x11.h | 2 |
15 files changed, 262 insertions, 36 deletions
diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index fad489721c..d149916893 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -557,6 +557,58 @@ public class GodotIO { } } + + public static final int SYSTEM_DIR_DESKTOP=0; + public static final int SYSTEM_DIR_DCIM=1; + public static final int SYSTEM_DIR_DOCUMENTS=2; + public static final int SYSTEM_DIR_DOWNLOADS=3; + public static final int SYSTEM_DIR_MOVIES=4; + public static final int SYSTEM_DIR_MUSIC=5; + public static final int SYSTEM_DIR_PICTURES=6; + public static final int SYSTEM_DIR_RINGTONES=7; + + + public String getSystemDir(int idx) { + + String what=""; + switch(idx) { + case SYSTEM_DIR_DESKTOP: { + //what=Environment.DIRECTORY_DOCUMENTS; + what=Environment.DIRECTORY_DOWNLOADS; + } break; + case SYSTEM_DIR_DCIM: { + what=Environment.DIRECTORY_DCIM; + + } break; + case SYSTEM_DIR_DOCUMENTS: { + what=Environment.DIRECTORY_DOWNLOADS; + //what=Environment.DIRECTORY_DOCUMENTS; + } break; + case SYSTEM_DIR_DOWNLOADS: { + what=Environment.DIRECTORY_DOWNLOADS; + + } break; + case SYSTEM_DIR_MOVIES: { + what=Environment.DIRECTORY_MOVIES; + + } break; + case SYSTEM_DIR_MUSIC: { + what=Environment.DIRECTORY_MUSIC; + } break; + case SYSTEM_DIR_PICTURES: { + what=Environment.DIRECTORY_PICTURES; + } break; + case SYSTEM_DIR_RINGTONES: { + what=Environment.DIRECTORY_RINGTONES; + + } break; + } + + if (what.equals("")) + return ""; + return Environment.getExternalStoragePublicDirectory(what).getAbsolutePath(); + } + protected static final String PREFS_FILE = "device_id.xml"; protected static final String PREFS_DEVICE_ID = "device_id"; diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index fdc6f1207d..3d3ba5d276 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -599,7 +599,7 @@ static jmethodID _showKeyboard=0; static jmethodID _hideKeyboard=0; static jmethodID _setScreenOrientation=0; static jmethodID _getUniqueID=0; - +static jmethodID _getSystemDir=0; static jmethodID _playVideo=0; static jmethodID _isVideoPlaying=0; static jmethodID _pauseVideo=0; @@ -659,6 +659,14 @@ static void _set_screen_orient(int p_orient) { env->CallVoidMethod(godot_io, _setScreenOrientation, p_orient ); }; +static String _get_system_dir(int p_dir) { + + JNIEnv *env = ThreadAndroid::get_env(); + jstring s =(jstring)env->CallObjectMethod(godot_io,_getSystemDir,p_dir); + return String(env->GetStringUTFChars( s, NULL )); +}; + + static void _hide_vk() { JNIEnv* env = ThreadAndroid::get_env(); @@ -738,7 +746,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, _showKeyboard = env->GetMethodID(c,"showKeyboard","(Ljava/lang/String;)V"); _hideKeyboard = env->GetMethodID(c,"hideKeyboard","()V"); _setScreenOrientation = env->GetMethodID(c,"setScreenOrientation","(I)V"); - + _getSystemDir = env->GetMethodID(c,"getSystemDir","(I)Ljava/lang/String;"); _playVideo = env->GetMethodID(c,"playVideo","(Ljava/lang/String;)V"); _isVideoPlaying = env->GetMethodID(c,"isVideoPlaying","()Z"); _pauseVideo = env->GetMethodID(c,"pauseVideo","()V"); @@ -781,7 +789,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env, __android_log_print(ANDROID_LOG_INFO,"godot","CMDLINE LEN %i - APK EXPANSION %I\n",cmdlen,int(use_apk_expansion)); - os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video,use_apk_expansion); + os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _get_system_dir, _play_video,_is_video_playing, _pause_video, _stop_video,use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; diff --git a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java index da9d06e63c..77ebb4b780 100644 --- a/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java +++ b/platform/android/libs/downloader_library/gen/com/android/vending/expansion/downloader/BuildConfig.java @@ -2,5 +2,5 @@ package com.android.vending.expansion.downloader; public final class BuildConfig { - public final static boolean DEBUG = false; + public final static boolean DEBUG = true; }
\ No newline at end of file diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 5fad4386fa..833de059f7 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -699,12 +699,19 @@ void OS_Android::native_video_pause() { video_pause_func(); } +String OS_Android::get_system_dir(SystemDir p_dir) const { + + if (get_system_dir_func) + return get_system_dir_func(p_dir); + return String("."); +} + void OS_Android::native_video_stop() { if (video_stop_func) video_stop_func(); } -OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion) { +OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion) { use_apk_expansion=p_use_apk_expansion; @@ -726,6 +733,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu get_locale_func=p_get_locale_func; get_model_func=p_get_model_func; get_unique_id_func=p_get_unique_id; + get_system_dir_func=p_get_sdir_func; video_play_func = p_video_play_func; video_is_playing_func = p_video_is_playing_func; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index bc52a43002..26dbf4a509 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -63,6 +63,7 @@ typedef String (*GetUniqueIDFunc)(); typedef void (*ShowVirtualKeyboardFunc)(const String&); typedef void (*HideVirtualKeyboardFunc)(); typedef void (*SetScreenOrientationFunc)(int); +typedef String (*GetSystemDirFunc)(int); typedef void (*VideoPlayFunc)(const String&); typedef bool (*VideoIsPlayingFunc)(); @@ -98,6 +99,7 @@ private: SpatialSound2DServerSW *spatial_sound_2d_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; + #if 0 AudioDriverAndroid audio_driver_android; #else @@ -118,6 +120,7 @@ private: HideVirtualKeyboardFunc hide_virtual_keyboard_func; SetScreenOrientationFunc set_screen_orientation_func; GetUniqueIDFunc get_unique_id_func; + GetSystemDirFunc get_system_dir_func; VideoPlayFunc video_play_func; VideoIsPlayingFunc video_is_playing_func; @@ -203,6 +206,8 @@ public: virtual String get_unique_ID() const; + virtual String get_system_dir(SystemDir p_dir) const; + void process_accelerometer(const Vector3& p_accelerometer); void process_touch(int p_what,int p_pointer, const Vector<TouchPos>& p_points); @@ -210,11 +215,11 @@ public: void init_video_mode(int p_video_width,int p_video_height); virtual Error native_video_play(String p_path, float p_volume); - virtual bool native_video_is_playing(); - virtual void native_video_pause(); - virtual void native_video_stop(); + virtual bool native_video_is_playing(); + virtual void native_video_pause(); + virtual void native_video_stop(); - OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion); + OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id,GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion); ~OS_Android(); }; 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); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 8eb5746948..1ab15dcda3 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -52,8 +52,11 @@ #include "os/memory_pool_dynamic_prealloc.h" #include "globals.h" #include "io/marshalls.h" + +#include "shlobj.h" static const WORD MAX_CONSOLE_LINES = 1500; + //#define STDOUT_FILE extern HINSTANCE godot_hinstance; @@ -1875,7 +1878,46 @@ MainLoop *OS_Windows::get_main_loop() const { return main_loop; } +String OS_Windows::get_system_dir(SystemDir p_dir) const { + + + int id; + + + + switch(p_dir) { + case SYSTEM_DIR_DESKTOP: { + id=CSIDL_DESKTOPDIRECTORY; + } break; + case SYSTEM_DIR_DCIM: { + id=CSIDL_MYPICTURES; + } break; + case SYSTEM_DIR_DOCUMENTS: { + id=0x000C; + } break; + case SYSTEM_DIR_DOWNLOADS: { + id=0x000C ; + } break; + case SYSTEM_DIR_MOVIES: { + id=CSIDL_MYVIDEO; + } break; + case SYSTEM_DIR_MUSIC: { + id=CSIDL_MYMUSIC; + } break; + case SYSTEM_DIR_PICTURES: { + id=CSIDL_MYPICTURES; + } break; + case SYSTEM_DIR_RINGTONES: { + id=CSIDL_MYMUSIC; + } break; + } + + WCHAR szPath[MAX_PATH]; + HRESULT res = SHGetFolderPathW(NULL,id,NULL,0,szPath); + ERR_FAIL_COND_V(res!=S_OK,String()); + return String(szPath); +} String OS_Windows::get_data_dir() const { String an = Globals::get_singleton()->get("application/name"); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 4b16637143..20993c6419 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -249,6 +249,8 @@ public: virtual void move_window_to_foreground(); virtual String get_data_dir() const; + virtual String get_system_dir(SystemDir p_dir) const; + virtual void release_rendering_thread(); virtual void make_rendering_thread(); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4c45fcfaaf..0466984359 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1088,7 +1088,73 @@ String OS_X11::get_name() { Error OS_X11::shell_open(String p_uri) { - return ERR_UNAVAILABLE; + Error ok; + List<String> args; + args.push_back(p_uri); + ok = execute("/usr/bin/xdg-open",args,false); + if (ok==OK) + return OK; + ok = execute("gnome-open",args,false); + if (ok==OK) + return OK; + ok = execute("kde-open",args,false); + return ok; +} + +String OS_X11::get_system_dir(SystemDir p_dir) const { + + + String xdgparam; + + switch(p_dir) { + case SYSTEM_DIR_DESKTOP: { + + xdgparam="DESKTOP"; + } break; + case SYSTEM_DIR_DCIM: { + + xdgparam="PICTURES"; + + } break; + case SYSTEM_DIR_DOCUMENTS: { + + xdgparam="DOCUMENTS"; + + } break; + case SYSTEM_DIR_DOWNLOADS: { + + xdgparam="DOWNLOAD"; + + } break; + case SYSTEM_DIR_MOVIES: { + + xdgparam="VIDEOS"; + + } break; + case SYSTEM_DIR_MUSIC: { + + xdgparam="MUSIC"; + + } break; + case SYSTEM_DIR_PICTURES: { + + xdgparam="PICTURES"; + + } break; + case SYSTEM_DIR_RINGTONES: { + + xdgparam="MUSIC"; + + } break; + } + + String pipe; + List<String> arg; + arg.push_back(xdgparam); + Error err = const_cast<OS_X11*>(this)->execute("/usr/bin/xdg-user-dir",arg,true,NULL,&pipe); + if (err!=OK) + return "."; + return pipe.strip_edges(); } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 2ffca0e042..67772894fa 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -197,6 +197,8 @@ public: virtual void make_rendering_thread(); virtual void swap_buffers(); + virtual String get_system_dir(SystemDir p_dir) const; + virtual Error shell_open(String p_uri); virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0); |