diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/export/export.cpp | 16 | ||||
-rw-r--r-- | platform/android/java/src/org/godotengine/godot/Godot.java | 2 | ||||
-rw-r--r-- | platform/iphone/app_delegate.mm | 7 | ||||
-rw-r--r-- | platform/javascript/SCsub | 39 | ||||
-rw-r--r-- | platform/osx/audio_driver_osx.cpp | 114 | ||||
-rw-r--r-- | platform/osx/audio_driver_osx.h | 7 | ||||
-rw-r--r-- | platform/osx/detect.py | 2 | ||||
-rw-r--r-- | platform/osx/export/export.cpp | 8 | ||||
-rw-r--r-- | platform/uwp/os_uwp.cpp | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 2 | ||||
-rw-r--r-- | platform/x11/os_x11.cpp | 27 |
11 files changed, 168 insertions, 58 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index a72e8aa90e..95f48521f8 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -554,7 +554,7 @@ void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { } else { String lang = str.substr(str.find_last("-")+1,str.length()).replace("-","_"); - String prop = "application/name_"+lang; + String prop = "application/config/name_"+lang; if (GlobalConfig::get_singleton()->has(prop)) { str = GlobalConfig::get_singleton()->get(prop); } else { @@ -628,7 +628,7 @@ String EditorExportPlatformAndroid::get_project_name() const { if (this->name!="") { aname=this->name; } else { - aname = GlobalConfig::get_singleton()->get("application/name"); + aname = GlobalConfig::get_singleton()->get("application/config/name"); } @@ -1144,7 +1144,7 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (!found) { - String appicon = GlobalConfig::get_singleton()->get("application/icon"); + String appicon = GlobalConfig::get_singleton()->get("application/config/icon"); if (appicon!="" && appicon.ends_with(".png")) { FileAccess*f = FileAccess::open(appicon,FileAccess::READ); if (f) { @@ -1763,7 +1763,7 @@ Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { String EditorExportPlatformAndroid::get_package_name() { String pname = package; - String basename = GlobalConfig::get_singleton()->get("application/name"); + String basename = GlobalConfig::get_singleton()->get("application/config/name"); basename=basename.to_lower(); String name; @@ -2208,7 +2208,7 @@ class EditorExportAndroid : public EditorExportPlatform { if (p_name != "") { aname = p_name; } else { - aname = GlobalConfig::get_singleton()->get("application/name"); + aname = GlobalConfig::get_singleton()->get("application/config/name"); } if (aname == "") { @@ -2221,7 +2221,7 @@ class EditorExportAndroid : public EditorExportPlatform { String get_package_name(const String &p_package) { String pname = p_package; - String basename = GlobalConfig::get_singleton()->get("application/name"); + String basename = GlobalConfig::get_singleton()->get("application/config/name"); basename = basename.to_lower(); String name; @@ -2750,7 +2750,7 @@ class EditorExportAndroid : public EditorExportPlatform { } else { String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_"); - String prop = "application/name_" + lang; + String prop = "application/config/name_" + lang; if (GlobalConfig::get_singleton()->has(prop)) { str = GlobalConfig::get_singleton()->get(prop); } else { @@ -3219,7 +3219,7 @@ public: if (!found) { - String appicon = GlobalConfig::get_singleton()->get("application/icon"); + String appicon = GlobalConfig::get_singleton()->get("application/config/icon"); if (appicon != "" && appicon.ends_with(".png")) { FileAccess *f = FileAccess::open(appicon, FileAccess::READ); if (f) { diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 88928089b6..d620b2b9c4 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -273,7 +273,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mView = new GodotView(getApplication(),io,use_gl2,use_32_bits, this); layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); - setKeepScreenOn(GodotLib.getGlobal("display/keep_screen_on").equals("True")); + setKeepScreenOn(GodotLib.getGlobal("display/driver/keep_screen_on").equals("True")); edittext.setView(mView); io.setEdit(edittext); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 1f81f0f86e..b6cd43b3a2 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -29,11 +29,11 @@ /*************************************************************************/ #import "app_delegate.h" +#include "audio_driver_iphone.h" #include "core/global_config.h" #import "gl_view.h" #include "main/main.h" #include "os_iphone.h" -#include "audio_driver_iphone.h" #ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED #include "modules/FacebookScorer_ios/FacebookScorer.h" @@ -615,7 +615,7 @@ static int frame_count = 0; view_controller.view = glView; window.rootViewController = view_controller; - _set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES : NO); + _set_keep_screen_on(bool(GLOBAL_DEF("display/window/keep_screen_on", true)) ? YES : NO); glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO; printf("cadisaplylink: %d", glView.useCADisplayLink); @@ -673,7 +673,6 @@ static int frame_count = 0; isAdvertisingTrackingEnabled]]; #endif - }; - (void)applicationWillTerminate:(UIApplication *)application { @@ -737,7 +736,7 @@ static int frame_count = 0; }; // Fixed audio can not resume if it is interrupted cause by an incoming phone call - if(AudioDriverIphone::get_singleton() != NULL) + if (AudioDriverIphone::get_singleton() != NULL) AudioDriverIphone::get_singleton()->start(); } diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 02ff2090f9..ca9fcb54e4 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -22,26 +22,31 @@ for x in javascript_files: env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""]) env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"']) -html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0] +# output file name without file extension +basename = "godot" + env["PROGSUFFIX"] +target_dir = env.Dir("#bin") +js_file = target_dir.File(basename + ".js") +implicit_targets = [js_file] + +zip_dir = target_dir.Dir('.javascript_zip') +zip_files = env.InstallAs([zip_dir.File("godot.js"), zip_dir.File("godotfs.js")], [js_file, "#misc/dist/html_fs/godotfs.js"]) + +if env['wasm'] == 'yes': + wasm_file = target_dir.File(basename+'.wasm') + implicit_targets.append(wasm_file) + zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm_file)) +else: + asmjs_files = [target_dir.File(basename+'.asm.js'), target_dir.File(basename+'.html.mem')] + zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) + implicit_targets.extend(asmjs_files) + +# HTML file must be the first target in the list +html_file = env.Program(["#bin/godot"] + implicit_targets, javascript_objects, PROGSUFFIX=env["PROGSUFFIX"]+".html")[0] Depends(html_file, "godot_shell.html") -basename = "godot" + env["PROGSUFFIX"] # output file name without file extension # Emscripten hardcodes file names, so replace common base name with # placeholder while leaving extension; also change `.html.mem` to just `.mem` fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html') -zip_dir = env.Dir('#bin/.javascript_zip') -zip_files = [] -js_file = env.SideEffect(html_file.File(basename+'.js'), html_file) -zip_files.append(env.InstallAs( - [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')], - [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js'])) - -if env['wasm'] == 'yes': - wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file) - zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file)) -else: - asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file) - zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) - -Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir) +zip_files.append(InstallAs(zip_dir.File('godot.html'), fixup_html)) +Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET") diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index 7469d52976..a4233b5264 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/platform/osx/audio_driver_osx.cpp @@ -31,11 +31,15 @@ #include "audio_driver_osx.h" -Error AudioDriverOSX::init() { +static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) { + AudioDriverOSX *driver = (AudioDriverOSX *)inClientData; - active = false; - channels = 2; + driver->reopen(); + + return noErr; +} +Error AudioDriverOSX::initDevice() { AudioStreamBasicDescription strdesc; strdesc.mFormatID = kAudioFormatLinearPCM; strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; @@ -43,12 +47,10 @@ Error AudioDriverOSX::init() { strdesc.mSampleRate = 44100; strdesc.mFramesPerPacket = 1; strdesc.mBitsPerChannel = 16; - strdesc.mBytesPerFrame = - strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; - strdesc.mBytesPerPacket = - strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; + strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; + strdesc.mBytesPerPacket = strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; - OSStatus result = noErr; + OSStatus result; AURenderCallbackStruct callback; AudioComponentDescription desc; AudioComponent comp = NULL; @@ -66,32 +68,90 @@ Error AudioDriverOSX::init() { ERR_FAIL_COND_V(result != noErr, FAILED); ERR_FAIL_COND_V(comp == NULL, FAILED); - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_StreamFormat, - scope, bus, &strdesc, sizeof(strdesc)); + result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, scope, bus, &strdesc, sizeof(strdesc)); ERR_FAIL_COND_V(result != noErr, FAILED); zeromem(&callback, sizeof(AURenderCallbackStruct)); callback.inputProc = &AudioDriverOSX::output_callback; callback.inputProcRefCon = this; - result = AudioUnitSetProperty(audio_unit, - kAudioUnitProperty_SetRenderCallback, - scope, bus, &callback, sizeof(callback)); + result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, scope, bus, &callback, sizeof(callback)); ERR_FAIL_COND_V(result != noErr, FAILED); result = AudioUnitInitialize(audio_unit); ERR_FAIL_COND_V(result != noErr, FAILED); - result = AudioOutputUnitStart(audio_unit); + return OK; +} + +Error AudioDriverOSX::finishDevice() { + OSStatus result; + + if (active) { + result = AudioOutputUnitStop(audio_unit); + ERR_FAIL_COND_V(result != noErr, FAILED); + + active = false; + } + + result = AudioUnitUninitialize(audio_unit); + ERR_FAIL_COND_V(result != noErr, FAILED); + + return OK; +} + +Error AudioDriverOSX::init() { + OSStatus result; + + active = false; + channels = 2; + + outputDeviceAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; + outputDeviceAddress.mScope = kAudioObjectPropertyScopeGlobal; + outputDeviceAddress.mElement = kAudioObjectPropertyElementMaster; + + result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); ERR_FAIL_COND_V(result != noErr, FAILED); const int samples = 1024; samples_in = memnew_arr(int32_t, samples); // whatever buffer_frames = samples / channels; - return OK; + return initDevice(); }; +Error AudioDriverOSX::reopen() { + Error err; + bool restart = false; + + lock(); + + if (active) { + restart = true; + } + + err = finishDevice(); + if (err != OK) { + ERR_PRINT("finishDevice failed"); + unlock(); + return err; + } + + err = initDevice(); + if (err != OK) { + ERR_PRINT("initDevice failed"); + unlock(); + return err; + } + + if (restart) { + start(); + } + + unlock(); + + return OK; +} + OSStatus AudioDriverOSX::output_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, @@ -149,7 +209,14 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon, }; void AudioDriverOSX::start() { - active = true; + if (!active) { + OSStatus result = AudioOutputUnitStart(audio_unit); + if (result != noErr) { + ERR_PRINT("AudioOutputUnitStart failed"); + } else { + active = true; + } + } }; int AudioDriverOSX::get_mix_rate() const { @@ -161,18 +228,23 @@ AudioDriver::SpeakerMode AudioDriverOSX::get_speaker_mode() const { }; void AudioDriverOSX::lock() { - if (active && mutex) + if (mutex) mutex->lock(); }; void AudioDriverOSX::unlock() { - if (active && mutex) + if (mutex) mutex->unlock(); }; void AudioDriverOSX::finish() { + OSStatus result; + + finishDevice(); - if (active) - AudioOutputUnitStop(audio_unit); + result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this); + if (result != noErr) { + ERR_PRINT("AudioObjectRemovePropertyListener failed"); + } memdelete_arr(samples_in); }; diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h index 9b48dab405..d6d00b7970 100644 --- a/platform/osx/audio_driver_osx.h +++ b/platform/osx/audio_driver_osx.h @@ -35,10 +35,12 @@ #include "servers/audio_server.h" #include <AudioUnit/AudioUnit.h> +#include <CoreAudio/AudioHardware.h> class AudioDriverOSX : public AudioDriver { AudioComponentInstance audio_unit; + AudioObjectPropertyAddress outputDeviceAddress; bool active; Mutex *mutex; @@ -52,6 +54,9 @@ class AudioDriverOSX : public AudioDriver { UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData); + Error initDevice(); + Error finishDevice(); + public: const char *get_name() const { return "AudioUnit"; @@ -65,6 +70,8 @@ public: virtual void unlock(); virtual void finish(); + Error reopen(); + AudioDriverOSX(); ~AudioDriverOSX(); }; diff --git a/platform/osx/detect.py b/platform/osx/detect.py index dfefbbc1ba..d9891dda61 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -90,7 +90,7 @@ def configure(env): env.Append(CPPPATH=['#platform/osx']) env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) + env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) env.Append(LIBS=['pthread']) env.Append(CPPFLAGS=['-mmacosx-version-min=10.9']) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index c81fb00b36..ca5535f771 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -345,7 +345,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (p_preset->get("application/icon") != "") iconpath = p_preset->get("application/icon"); else - iconpath = GlobalConfig::get_singleton()->get("application/icon"); + iconpath = GlobalConfig::get_singleton()->get("application/config/icon"); print_line("icon? " + iconpath); if (iconpath != "") { Ref<Image> icon; @@ -484,8 +484,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p String pkg_name; if (p_preset->get("application/name") != "") pkg_name = p_preset->get("application/name"); // app_name - else if (String(GlobalConfig::get_singleton()->get("application/name")) != "") - pkg_name = String(GlobalConfig::get_singleton()->get("application/name")); + else if (String(GlobalConfig::get_singleton()->get("application/config/name")) != "") + pkg_name = String(GlobalConfig::get_singleton()->get("application/config/name")); else pkg_name = "Unnamed"; @@ -539,7 +539,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (p_preset->get("application/icon") != "") iconpath = p_preset->get("application/icon"); else - iconpath = GlobalConfig::get_singleton()->get("application/icon"); + iconpath = GlobalConfig::get_singleton()->get("application/config/icon"); print_line("icon? " + iconpath); if (iconpath != "") { Ref<Image> icon; diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 28aaf9161b..b9ef778e01 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -310,7 +310,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud if (is_keep_screen_on()) display_request->RequestActive(); - set_keep_screen_on(GLOBAL_DEF("display/keep_screen_on", true)); + set_keep_screen_on(GLOBAL_DEF("display/window/keep_screen_on", true)); } void OSUWP::set_clipboard(const String &p_text) { diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2daf580c0d..36d6cd8565 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2229,7 +2229,7 @@ String OS_Windows::get_data_dir() const { if (has_environment("APPDATA")) { - bool use_godot = GlobalConfig::get_singleton()->get("application/use_shared_user_dir"); + bool use_godot = GlobalConfig::get_singleton()->get("application/config/use_shared_user_dir"); if (!use_godot) return (OS::get_singleton()->get_environment("APPDATA") + "/" + an).replace("\\", "/"); else diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4aca1468b1..04f41b2e89 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -686,6 +686,16 @@ void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) con } void OS_X11::set_wm_fullscreen(bool p_enabled) { + if (p_enabled && !is_window_resizable()) { + // Set the window as resizable to prevent window managers to ignore the fullscreen state flag. + XSizeHints *xsh; + + xsh = XAllocSizeHints(); + xsh->flags = 0L; + XSetWMNormalHints(x11_display, x11_window, xsh); + XFree(xsh); + } + // Using EWMH -- Extened Window Manager Hints XEvent xev; Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); @@ -701,6 +711,23 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { xev.xclient.data.l[2] = 0; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); + XFlush(x11_display); + + if (!p_enabled && !is_window_resizable()) { + // Reset the non-resizable flags if we un-set these before. + Size2 size = get_window_size(); + XSizeHints *xsh; + + xsh = XAllocSizeHints(); + xsh->flags = PMinSize | PMaxSize; + xsh->min_width = size.x; + xsh->max_width = size.x; + xsh->min_height = size.y; + xsh->max_height = size.y; + + XSetWMNormalHints(x11_display, x11_window, xsh); + XFree(xsh); + } } int OS_X11::get_screen_count() const { |