diff options
Diffstat (limited to 'platform')
25 files changed, 483 insertions, 297 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index a65dab9668..31fee5722c 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -2,6 +2,8 @@ import shutil from compat import open_utf8 +from distutils.version import LooseVersion +from detect import get_ndk_version Import('env') @@ -169,3 +171,7 @@ if lib_arch_dir != '': out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE")) + ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) + if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): + stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so' + env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
\ No newline at end of file diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index b9f1f1eab0..46bd691290 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -82,9 +82,7 @@ Error AudioDriverAndroid::init() { int latency = GLOBAL_DEF_RST("audio/output_latency", 25); unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000); - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("audio buffer size: " + itos(buffer_size)); - } + print_verbose("Audio buffer size: " + itos(buffer_size)); audioBuffer = env->CallObjectMethod(io, _init_audio, mix_rate, buffer_size); diff --git a/platform/android/detect.py b/platform/android/detect.py index 0c6c9fdca3..b22e85b2c1 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -204,18 +204,26 @@ def configure(env): ## Compile flags + if env['android_stl']: + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"]) + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) + env.Append(CXXFLAGS=['-frtti',"-std=gnu++14"]) + else: + env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) + ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): print("Using NDK unified headers") sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot" - env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) + env.Append(CPPFLAGS=["--sysroot="+sysroot]) env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath]) + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/android/support/include"]) # For unified headers this define has to be set manually env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(get_platform(env['ndk_platform']))]) else: print("Using NDK deprecated headers") env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"]) - + env.Append(CPPFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) env.Append(CPPFLAGS='-DNO_STATVFS -DGLES_ENABLED'.split()) @@ -246,23 +254,24 @@ def configure(env): env.Append(CPPFLAGS=target_opts) env.Append(CPPFLAGS=common_opts) - if env['android_stl']: - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath]) - env.Append(LIBS=["gnustl_static"]) - else: - env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) - ## Link flags - - env['LINKFLAGS'] = ['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel'] + if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): + if LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"): + env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a','-Wl,--exclude-libs,libatomic.a','-nostdlib++']) + env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libandroid_support.a"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libc++_shared.so"]) + else: + env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) + if mt_link: + env.Append(LINKFLAGS=['-Wl,--threads']) + if env["android_arch"] == "armv7": env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split()) env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split()) env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split()) - if mt_link: - env.Append(LINKFLAGS=['-Wl,--threads']) + env.Append(LINKFLAGS=target_opts) env.Append(LINKFLAGS=common_opts) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 9ad0219746..5c8d9e078f 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -257,7 +257,6 @@ class EditorExportAndroid : public EditorExportPlatform { if (dpos == -1) continue; d = d.substr(0, dpos).strip_edges(); - //print_line("found device: "+d); ldevices.push_back(d); } @@ -345,8 +344,6 @@ class EditorExportAndroid : public EditorExportPlatform { } d.name = vendor + " " + device; - //print_line("name: "+d.name); - //print_line("description: "+d.description); } ndevices.push_back(d); @@ -671,19 +668,14 @@ class EditorExportAndroid : public EditorExportPlatform { ucstring.write[len] = 0; string_table.write[i] = ucstring.ptr(); } - - //print_line("String "+itos(i)+": "+string_table[i]); } for (uint32_t i = string_end; i < (ofs + size); i++) { stable_extra.push_back(p_manifest[i]); } - //printf("stable extra: %i\n",int(stable_extra.size())); string_table_ends = ofs + size; - //print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends)); - } break; case CHUNK_XML_START_TAG: { @@ -714,35 +706,25 @@ class EditorExportAndroid : public EditorExportPlatform { //replace project information if (tname == "manifest" && attrname == "package") { - - print_line("FOUND package"); string_table.write[attr_value] = get_package_name(package_name); } - if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionCode") { - - print_line("FOUND versionCode"); + if (tname == "manifest" && attrname == "versionCode") { encode_uint32(version_code, &p_manifest.write[iofs + 16]); } - if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionName") { - - print_line("FOUND versionName"); + if (tname == "manifest" && attrname == "versionName") { if (attr_value == 0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else string_table.write[attr_value] = version_name; } - if (tname == "activity" && /*nspace=="android" &&*/ attrname == "screenOrientation") { + if (tname == "activity" && attrname == "screenOrientation") { encode_uint32(orientation == 0 ? 0 : 1, &p_manifest.write[iofs + 16]); } - if (tname == "uses-feature" && /*nspace=="android" &&*/ attrname == "glEsVersion") { - print_line("version number: " + itos(decode_uint32(&p_manifest[iofs + 16]))); - } - if (tname == "supports-screens") { if (attrname == "smallScreens") { @@ -773,7 +755,6 @@ class EditorExportAndroid : public EditorExportPlatform { String tname = string_table[name]; if (tname == "manifest") { - print_line("Found manifest end"); // save manifest ending so we can restore it Vector<uint8_t> manifest_end; @@ -913,8 +894,6 @@ class EditorExportAndroid : public EditorExportPlatform { encode_uint32(string_table.size(), &ret.write[16]); //update new number of strings encode_uint32(string_data_offset - 8, &ret.write[28]); //update new string data offset - //print_line("file size: "+itos(ret.size())); - p_manifest = ret; } @@ -956,7 +935,6 @@ class EditorExportAndroid : public EditorExportPlatform { void _fix_resources(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest) { const int UTF8_FLAG = 0x00000100; - print_line("*******************GORRRGLE***********************"); uint32_t string_block_len = decode_uint32(&p_manifest[16]); uint32_t string_count = decode_uint32(&p_manifest[20]); @@ -1086,16 +1064,15 @@ public: virtual void get_export_options(List<ExportOption> *r_options) { - /*r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/api", PROPERTY_HINT_ENUM, "OpenGL ES 2.0,OpenGL ES 3.0"), 1));*/ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "apk"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name"), "org.godotengine.$genname")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.$genname"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"), 0)); @@ -1105,10 +1082,10 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); for (int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icons[i].option_id, PROPERTY_HINT_FILE, "png"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icons[i].option_id, PROPERTY_HINT_FILE, "*.png"), "")); } - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "keystore"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "*.keystore"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_user"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_password"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "apk_expansion/enable"), false)); @@ -1133,8 +1110,6 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "user_permissions/" + itos(i)), false)); } - - //r_options->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)")); } virtual String get_name() const { @@ -1237,8 +1212,8 @@ public: err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); } - print_line("Installing into device (please wait..): " + devices[p_device].name); - ep.step("Installing to Device (please wait..)..", 2); + print_line("Installing to device (please wait...): " + devices[p_device].name); + ep.step("Installing to device (please wait...)", 2); args.clear(); args.push_back("-s"); @@ -1336,12 +1311,28 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { + String err; r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String(); + if (p_preset->get("custom_package/debug") != "") { + if (FileAccess::exists(p_preset->get("custom_package/debug"))) { + r_missing_templates = false; + } else { + err += "Custom debug package not found.\n"; + } + } + + if (p_preset->get("custom_package/release") != "") { + if (FileAccess::exists(p_preset->get("custom_package/release"))) { + r_missing_templates = false; + } else { + err += "Custom release package not found.\n"; + } + } + bool valid = !r_missing_templates; String adb = EditorSettings::get_singleton()->get("export/android/adb"); - String err; if (!FileAccess::exists(adb)) { @@ -1600,8 +1591,11 @@ public: String apkfname = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb"; String fullpath = p_path.get_base_dir().plus_file(apkfname); err = save_pack(p_preset, fullpath); + if (err != OK) { + unzClose(pkg); EditorNode::add_io_error("Could not write expansion package file: " + apkfname); + return OK; } @@ -1847,6 +1841,9 @@ public: r_features->push_back("Android"); } + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + } + EditorExportAndroid() { Ref<Image> img = memnew(Image(_android_logo)); @@ -1883,7 +1880,7 @@ void register_android_exporter() { EDITOR_DEF("export/android/jarsigner", ""); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/jarsigner", PROPERTY_HINT_GLOBAL_FILE, exe_ext)); EDITOR_DEF("export/android/debug_keystore", ""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore")); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "*.keystore")); EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey"); EDITOR_DEF("export/android/debug_keystore_pass", "android"); EDITOR_DEF("export/android/force_system_user", false); diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 0e5f4fb93a..061e05f5ee 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -928,7 +928,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerMethod(JNIEnv *e jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data()); if (!mid) { - print_line("FAILED GETTING METHOD ID " + mname); + print_line("RegisterMethod: Failed getting method ID: " + mname); } s->add_method(mname, mid, types, get_jni_type(retval)); diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 446a5911e5..022ccb7d89 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -554,7 +554,6 @@ bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, St jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName); String str_type = env->GetStringUTFChars(name2, NULL); - print_line("name: " + str_type); env->DeleteLocalRef(name2); uint32_t t = 0; @@ -1191,9 +1190,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); - - //args[i] = _jobject_to_variant(env, obj); - //print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type())); }; env->DeleteLocalRef(methods); @@ -1210,7 +1206,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { jstring name = (jstring)env->CallObjectMethod(obj, Field_getName); String str_field = env->GetStringUTFChars(name, NULL); env->DeleteLocalRef(name); - print_line("FIELD: " + str_field); int mods = env->CallIntMethod(obj, Field_getModifiers); if ((mods & 0x8) && (mods & 0x10) && (mods & 0x1)) { //static final public! diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index f9eda9dff1..c8bdf98923 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -337,8 +337,6 @@ void OS_Android::process_event(Ref<InputEvent> p_event) { void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points) { - //print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size())); - switch (p_what) { case 0: { //gesture begin diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index e59c81a148..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(); }; @@ -169,39 +172,39 @@ static const LoadingScreenInfo loading_screen_infos[] = { 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, "required_icons/app_store_1024x1024", PROPERTY_HINT_FILE, "png"), "")); // App Store + 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, "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, "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 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::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), "")); } r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false)); @@ -736,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 @@ -806,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) { diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index 98988d97fd..a93c98a89f 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -32,6 +32,6 @@ zip_files = env.InstallAs([ ], [ js_wrapped, wasm, - '#misc/dist/html/default.html' + '#misc/dist/html/full-size.html' ]) env.Zip('#bin/godot', zip_files, ZIPROOT=zip_dir, ZIPSUFFIX='${PROGSUFFIX}${ZIPSUFFIX}', ZIPCOMSTR='Archving $SOURCES as $TARGET') diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 7cff6ba172..a7f0084562 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -74,6 +74,9 @@ public: r_features->push_back(get_os_name()); } + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + } + EditorExportPlatformJavaScript(); }; @@ -117,10 +120,10 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "html"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); } String EditorExportPlatformJavaScript::get_name() const { @@ -140,14 +143,35 @@ Ref<Texture> EditorExportPlatformJavaScript::get_logo() const { bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { - r_missing_templates = false; + bool valid = false; + String err; + + if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) != "") + valid = true; + else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) != "") + valid = true; + + if (p_preset->get("custom_template/debug") != "") { + if (FileAccess::exists(p_preset->get("custom_template/debug"))) { + valid = true; + } else { + err += "Custom debug template not found.\n"; + } + } + + if (p_preset->get("custom_template/release") != "") { + if (FileAccess::exists(p_preset->get("custom_template/release"))) { + valid = true; + } else { + err += "Custom release template not found.\n"; + } + } - if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String()) - r_missing_templates = true; - else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String()) - r_missing_templates = true; + if (!err.empty()) + r_error = err; - return !r_missing_templates; + r_missing_templates = !valid; + return valid; } String EditorExportPlatformJavaScript::get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { diff --git a/platform/javascript/http_request.js b/platform/javascript/http_request.js index c420052e54..ee1c06c623 100644 --- a/platform/javascript/http_request.js +++ b/platform/javascript/http_request.js @@ -82,7 +82,7 @@ var GodotHTTPRequest = { godot_xhr_send_string: function(xhrId, strPtr) { if (!strPtr) { - Module.printErr("Failed to send string per XHR: null pointer"); + console.warn("Failed to send string per XHR: null pointer"); return; } GodotHTTPRequest.requests[xhrId].send(UTF8ToString(strPtr)); @@ -90,11 +90,11 @@ var GodotHTTPRequest = { godot_xhr_send_data: function(xhrId, ptr, len) { if (!ptr) { - Module.printErr("Failed to send data per XHR: null pointer"); + console.warn("Failed to send data per XHR: null pointer"); return; } if (len < 0) { - Module.printErr("Failed to send data per XHR: buffer length less than 0"); + console.warn("Failed to send data per XHR: buffer length less than 0"); return; } GodotHTTPRequest.requests[xhrId].send(HEAPU8.subarray(ptr, ptr + len)); diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index 2ef88345f6..07b4c192e6 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -69,7 +69,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { eval_ret = eval(UTF8ToString(CODE)); } } catch (e) { - Module.printErr(e); + console.warn(e); eval_ret = null; } @@ -97,7 +97,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { if (array_ptr!==0) { _free(array_ptr) } - Module.printErr(e); + console.warn(e); // fall through } break; diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index b9d586e233..5a8a05d4df 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -71,14 +71,6 @@ static bool is_canvas_focused() { static bool cursor_inside_canvas = true; -EM_BOOL OS_JavaScript::browser_resize_callback(int p_event_type, const EmscriptenUiEvent *p_event, void *p_user_data) { - - // The order of the fullscreen change event and the window size change - // event varies, even within just one browser, so defer handling. - get_singleton()->canvas_size_adjustment_requested = true; - return false; -} - EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data) { OS_JavaScript *os = get_singleton(); @@ -88,7 +80,13 @@ EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const Emscri // This event property is the only reliable data on // browser fullscreen state. os->video_mode.fullscreen = p_event->isFullscreen; - os->canvas_size_adjustment_requested = true; + if (os->video_mode.fullscreen) { + os->entering_fullscreen = false; + } else { + // Restoring maximized window now will cause issues, + // so delay until main_loop_iterate. + os->just_exited_fullscreen = true; + } } return false; } @@ -114,14 +112,14 @@ Size2 OS_JavaScript::get_screen_size(int p_screen) const { void OS_JavaScript::set_window_size(const Size2 p_size) { windowed_size = p_size; - if (is_window_fullscreen()) { + if (video_mode.fullscreen) { window_maximized = false; set_window_fullscreen(false); - } else if (is_window_maximized()) { - set_window_maximized(false); } else { - video_mode.width = p_size.x; - video_mode.height = p_size.y; + if (window_maximized) { + emscripten_exit_soft_fullscreen(); + window_maximized = false; + } emscripten_set_canvas_size(p_size.x, p_size.y); } } @@ -135,31 +133,22 @@ Size2 OS_JavaScript::get_window_size() const { void OS_JavaScript::set_window_maximized(bool p_enabled) { - window_maximized = p_enabled; - if (is_window_fullscreen()) { + if (video_mode.fullscreen) { + window_maximized = p_enabled; set_window_fullscreen(false); - return; - } - // Calling emscripten_enter_soft_fullscreen mutltiple times hides all - // page elements except the canvas permanently, so track state. - if (p_enabled && !soft_fullscreen_enabled) { - + } else if (!p_enabled) { + emscripten_exit_soft_fullscreen(); + window_maximized = false; + } else if (!window_maximized) { + // Prevent calling emscripten_enter_soft_fullscreen mutltiple times, + // this would hide page elements permanently. EmscriptenFullscreenStrategy strategy; strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; strategy.canvasResizedCallback = NULL; emscripten_enter_soft_fullscreen(NULL, &strategy); - soft_fullscreen_enabled = true; - video_mode.width = get_window_size().width; - video_mode.height = get_window_size().height; - } else if (!p_enabled) { - - emscripten_exit_soft_fullscreen(); - soft_fullscreen_enabled = false; - video_mode.width = windowed_size.width; - video_mode.height = windowed_size.height; - emscripten_set_canvas_size(video_mode.width, video_mode.height); + window_maximized = p_enabled; } } @@ -170,30 +159,33 @@ bool OS_JavaScript::is_window_maximized() const { void OS_JavaScript::set_window_fullscreen(bool p_enabled) { - if (p_enabled == is_window_fullscreen()) { + if (p_enabled == video_mode.fullscreen) { return; } - // Just request changes here, if successful, canvas is resized in - // _browser_resize_callback or _fullscreen_change_callback. - EMSCRIPTEN_RESULT result; + // Just request changes here, if successful, logic continues in + // fullscreen_change_callback. if (p_enabled) { if (window_maximized) { - // Soft fullsreen during real fulllscreen can cause issues. - set_window_maximized(false); - window_maximized = true; + // Soft fullsreen during real fullscreen can cause issues, so exit. + // This must be called before requesting full screen. + emscripten_exit_soft_fullscreen(); } EmscriptenFullscreenStrategy strategy; strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; strategy.canvasResizedCallback = NULL; - emscripten_request_fullscreen_strategy(NULL, false, &strategy); + EMSCRIPTEN_RESULT result = emscripten_request_fullscreen_strategy(NULL, false, &strategy); + ERR_EXPLAIN("Enabling fullscreen is only possible from an input callback for the HTML5 platform"); + ERR_FAIL_COND(result == EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED); + ERR_FAIL_COND(result != EMSCRIPTEN_RESULT_SUCCESS); + // Not fullscreen yet, so prevent "windowed" canvas dimensions from + // being overwritten. + entering_fullscreen = true; } else { - result = emscripten_exit_fullscreen(); - if (result != EMSCRIPTEN_RESULT_SUCCESS) { - ERR_PRINTS("Failed to exit fullscreen: Code " + itos(result)); - } + // No logic allowed here, since exiting w/ ESC key won't use this function. + ERR_FAIL_COND(emscripten_exit_fullscreen() != EMSCRIPTEN_RESULT_SUCCESS); } } @@ -725,7 +717,6 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, SET_EM_CALLBACK("#canvas", keydown, keydown_callback) SET_EM_CALLBACK("#canvas", keypress, keypress_callback) SET_EM_CALLBACK("#canvas", keyup, keyup_callback) - SET_EM_CALLBACK(NULL, resize, browser_resize_callback) SET_EM_CALLBACK(NULL, fullscreenchange, fullscreen_change_callback) SET_EM_CALLBACK_NOTARGET(gamepadconnected, gamepad_change_callback) SET_EM_CALLBACK_NOTARGET(gamepaddisconnected, gamepad_change_callback) @@ -788,24 +779,38 @@ bool OS_JavaScript::main_loop_iterate() { /* clang-format off */ EM_ASM( FS.syncfs(function(err) { - if (err) { Module.printErr('Failed to save IDB file system: ' + err.message); } + if (err) { console.warn('Failed to save IDB file system: ' + err.message); } }); ); /* clang-format on */ } } + process_joypads(); - if (canvas_size_adjustment_requested) { - if (video_mode.fullscreen || window_maximized) { - video_mode.width = get_window_size().width; - video_mode.height = get_window_size().height; - } - if (!video_mode.fullscreen) { - set_window_maximized(window_maximized); + if (just_exited_fullscreen) { + if (window_maximized) { + EmscriptenFullscreenStrategy strategy; + strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; + strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + strategy.canvasResizedCallback = NULL; + emscripten_enter_soft_fullscreen(NULL, &strategy); + } else { + emscripten_set_canvas_size(windowed_size.width, windowed_size.height); } - canvas_size_adjustment_requested = false; + just_exited_fullscreen = false; } + + int canvas[3]; + emscripten_get_canvas_size(canvas, canvas + 1, canvas + 2); + video_mode.width = canvas[0]; + video_mode.height = canvas[1]; + if (!window_maximized && !video_mode.fullscreen && !just_exited_fullscreen && !entering_fullscreen) { + windowed_size.width = canvas[0]; + windowed_size.height = canvas[1]; + } + return Main::iteration(); } @@ -958,8 +963,8 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) { set_cmdline(p_argv[0], arguments); window_maximized = false; - soft_fullscreen_enabled = false; - canvas_size_adjustment_requested = false; + entering_fullscreen = false; + just_exited_fullscreen = false; main_loop = NULL; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 915320fe39..f40fb8fc7e 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -44,8 +44,8 @@ class OS_JavaScript : public OS_Unix { VideoMode video_mode; Vector2 windowed_size; bool window_maximized; - bool soft_fullscreen_enabled; - bool canvas_size_adjustment_requested; + bool entering_fullscreen; + bool just_exited_fullscreen; InputDefault *input; Ref<InputEventKey> deferred_key_event; @@ -59,7 +59,6 @@ class OS_JavaScript : public OS_Unix { int64_t sync_wait_time; int64_t last_sync_check_time; - static EM_BOOL browser_resize_callback(int p_event_type, const EmscriptenUiEvent *p_event, void *p_user_data); static EM_BOOL fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data); static EM_BOOL keydown_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index b630e4f223..880705b507 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -86,6 +86,9 @@ public: r_features->push_back("OSX"); } + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + } + EditorExportPlatformOSX(); ~EditorExportPlatformOSX(); }; @@ -106,14 +109,14 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> void EditorExportPlatformOSX::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/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/icon", PROPERTY_HINT_FILE, "png"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier"), "org.godotengine.macgame")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "godotmacgame")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.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"), "")); @@ -377,7 +380,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p String file = fname; - print_line("READ: " + file); Vector<uint8_t> data; data.resize(info.uncompressed_size); @@ -391,7 +393,6 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p file = file.replace_first("osx_template.app/", ""); if (file == "Contents/Info.plist") { - print_line("parse plist"); _fix_plist(p_preset, data, pkg_name); } @@ -412,13 +413,12 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p iconpath = p_preset->get("application/icon"); else iconpath = ProjectSettings::get_singleton()->get("application/config/icon"); - print_line("icon? " + iconpath); + if (iconpath != "") { Ref<Image> icon; icon.instance(); icon->load(iconpath); if (!icon->empty()) { - print_line("loaded?"); _make_icon(icon, data); } } @@ -472,9 +472,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p Z_DEFLATED, Z_DEFAULT_COMPRESSION); - print_line("OPEN ERR: " + itos(zerr)); zerr = zipWriteInFileInZip(dst_pkg_zip, data.ptr(), data.size()); - print_line("WRITE ERR: " + itos(zerr)); zipCloseFileInZip(dst_pkg_zip); } } diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 7bf274310d..41cfada723 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1351,8 +1351,6 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a AudioDriverManager::initialize(p_audio_driver); - midi_driver.open(); - input = memnew(InputDefault); joypad_osx = memnew(JoypadOSX); @@ -1370,6 +1368,8 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a void OS_OSX::finalize() { + midi_driver.close(); + CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL); CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL); diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index ebc2c2d7a2..1ad5293b44 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -1050,15 +1050,15 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/display_name"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/short_name"), "Godot")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name"), "Godot.Engine")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/description"), "Godot Engine")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher"), "CN=GodotEngine")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher_display_name"), "Godot Engine")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/display_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/short_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game.Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/description"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher", PROPERTY_HINT_PLACEHOLDER_TEXT, "CN=CompanyName"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/publisher_display_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/product_guid"), "00000000-0000-0000-0000-000000000000")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/publisher_guid"), "00000000-0000-0000-0000-000000000000")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/product_guid", PROPERTY_HINT_PLACEHOLDER_TEXT, "00000000-0000-0000-0000-000000000000"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "identity/publisher_guid", PROPERTY_HINT_PLACEHOLDER_TEXT, "00000000-0000-0000-0000-000000000000"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "signing/certificate", PROPERTY_HINT_GLOBAL_FILE, "*.pfx"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "signing/password"), "")); @@ -1087,8 +1087,8 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_wide310x150"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "tiles/show_name_on_square310x310"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); // Capabilities const char **basic = uwp_capabilities; @@ -1454,6 +1454,9 @@ public: r_features->push_back("UWP"); } + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + } + EditorExportUWP() { Ref<Image> img = memnew(Image(_uwp_logo)); logo.instance(); diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index a158237418..59435b04ea 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -68,20 +68,6 @@ void ContextGL_Win::swap_buffers() { SwapBuffers(hDC); } -/* -static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { - - print_line(String()+"getting proc of: "+p_function); - GLWrapperFuncPtr func=(GLWrapperFuncPtr)get_gl_proc_address(p_function); - if (!func) { - print_line("Couldn't find function: "+String(p_function)); - print_line("error: "+itos(GetLastError())); - } - return func; - -} -*/ - void ContextGL_Win::set_use_vsync(bool p_use) { if (wglSwapIntervalEXT) { diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 34fc3e09b5..150d418502 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -172,6 +172,7 @@ def configure_msvc(env, manual_msvc_config): env.Append(CCFLAGS=['/O1']) env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + env.Append(LINKFLAGS=['/OPT:REF']) elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) @@ -180,12 +181,7 @@ def configure_msvc(env, manual_msvc_config): env.Append(CCFLAGS=['/O1']) env.AppendUnique(CPPDEFINES = ['DEBUG_ENABLED']) env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) - - elif (env["target"] == "debug_release"): - env.Append(CCFLAGS=['/Z7', '/Od']) - env.Append(LINKFLAGS=['/DEBUG']) - env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS']) - env.Append(LINKFLAGS=['/ENTRY:mainCRTStartup']) + env.Append(LINKFLAGS=['/OPT:REF']) elif (env["target"] == "debug"): env.AppendUnique(CCFLAGS=['/Z7', '/Od', '/EHsc']) @@ -194,6 +190,10 @@ def configure_msvc(env, manual_msvc_config): env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE']) env.Append(LINKFLAGS=['/DEBUG']) + if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes"): + env.AppendUnique(CCFLAGS=['/Z7']) + env.AppendUnique(LINKFLAGS=['/DEBUG']) + ## Compile/link flags env.AppendUnique(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo']) @@ -210,6 +210,7 @@ def configure_msvc(env, manual_msvc_config): 'WIN32', 'MSVC', {'WINVER' : '$target_win_version', '_WIN32_WINNT': '$target_win_version'}]) + env.AppendUnique(CPPDEFINES=['NOMINMAX']) # disable bogus min/max WinDef.h macros if env["bits"] == "64": env.AppendUnique(CPPDEFINES=['_WIN64']) diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 97544c18f5..38fd6366c7 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -137,14 +137,14 @@ Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) { EditorExportPlatformPC::get_export_options(r_options); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_GLOBAL_FILE, "*.ico"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), String())); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), String())); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_GLOBAL_FILE, "*.ico"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), "")); } void register_windows_exporter() { diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index 796531fe24..b56fb6509e 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -540,9 +540,7 @@ void JoypadWindows::load_xinput() { } if (!xinput_dll) { - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("Could not find XInput, using DirectInput only"); - } + print_verbose("Could not find XInput, using DirectInput only"); return; } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d5bb85c035..fa8717a4b8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -190,6 +190,28 @@ BOOL WINAPI HandlerRoutine(_In_ DWORD dwCtrlType) { } } +BOOL CALLBACK _CloseWindowsEnum(HWND hWnd, LPARAM lParam) { + DWORD dwID; + + GetWindowThreadProcessId(hWnd, &dwID); + + if (dwID == (DWORD)lParam) { + PostMessage(hWnd, WM_CLOSE, 0, 0); + } + + return TRUE; +} + +bool _close_gracefully(const PROCESS_INFORMATION &pi, const DWORD dwStopWaitMsec) { + if (!EnumWindows(_CloseWindowsEnum, pi.dwProcessId)) + return false; + + if (WaitForSingleObject(pi.hProcess, dwStopWaitMsec) != WAIT_OBJECT_0) + return false; + + return true; +} + void OS_Windows::initialize_debugging() { SetConsoleCtrlHandler(HandlerRoutine, TRUE); @@ -387,7 +409,84 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) input->set_mouse_in_window(false); } break; + case WM_INPUT: { + if (mouse_mode != MOUSE_MODE_CAPTURED || !use_raw_input) { + break; + } + + UINT dwSize; + + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)); + LPBYTE lpb = new BYTE[dwSize]; + if (lpb == NULL) { + return 0; + } + + if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize) + OutputDebugString(TEXT("GetRawInputData does not return correct size !\n")); + + RAWINPUT *raw = (RAWINPUT *)lpb; + + if (raw->header.dwType == RIM_TYPEMOUSE) { + Ref<InputEventMouseMotion> mm; + mm.instance(); + + mm->set_control(control_mem); + mm->set_shift(shift_mem); + mm->set_alt(alt_mem); + + mm->set_button_mask(last_button_state); + + Point2i c(video_mode.width / 2, video_mode.height / 2); + + // centering just so it works as before + POINT pos = { (int)c.x, (int)c.y }; + ClientToScreen(hWnd, &pos); + SetCursorPos(pos.x, pos.y); + + mm->set_position(c); + mm->set_global_position(c); + input->set_mouse_position(c); + mm->set_speed(Vector2(0, 0)); + + if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) { + mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY)); + + } else if (raw->data.mouse.usFlags == MOUSE_MOVE_ABSOLUTE) { + + int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); + int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + int nScreenLeft = GetSystemMetrics(SM_XVIRTUALSCREEN); + int nScreenTop = GetSystemMetrics(SM_YVIRTUALSCREEN); + + Vector2 abs_pos( + (double(raw->data.mouse.lLastX) - 65536.0 / (nScreenWidth)) * nScreenWidth / 65536.0 + nScreenLeft, + (double(raw->data.mouse.lLastY) - 65536.0 / (nScreenHeight)) * nScreenHeight / 65536.0 + nScreenTop); + + POINT coords; //client coords + coords.x = abs_pos.x; + coords.y = abs_pos.y; + + ScreenToClient(hWnd, &coords); + + mm->set_relative(Vector2(coords.x - old_x, coords.y - old_y)); + old_x = coords.x; + old_y = coords.y; + + /*Input.mi.dx = (int)((((double)(pos.x)-nScreenLeft) * 65536) / nScreenWidth + 65536 / (nScreenWidth)); + Input.mi.dy = (int)((((double)(pos.y)-nScreenTop) * 65536) / nScreenHeight + 65536 / (nScreenHeight)); + */ + } + + if (window_has_focus && main_loop) + input->parse_input_event(mm); + } + delete[] lpb; + } break; case WM_MOUSEMOVE: { + if (mouse_mode == MOUSE_MODE_CAPTURED && use_raw_input) { + break; + } if (input->is_emulating_mouse_from_touch()) { // Universal translation enabled; ignore OS translation @@ -754,14 +853,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (ke.uMsg == WM_SYSKEYUP) ke.uMsg = WM_KEYUP; - /*if (ke.uMsg==WM_KEYDOWN && alt_mem && uMsg!=WM_SYSKEYDOWN) { - //altgr hack for intl keyboards, not sure how good it is - //windows is weeeeird - ke.mod_state.alt=false; - ke.mod_state.control=false; - print_line("") - }*/ - ke.wParam = wParam; ke.lParam = lParam; key_event_buffer[key_event_pos++] = ke; @@ -769,7 +860,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; case WM_INPUTLANGCHANGEREQUEST: { - print_line("input lang change"); + // FIXME: Do something? } break; case WM_TOUCH: { @@ -1024,7 +1115,6 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int WNDCLASSEXW wc; if (is_hidpi_allowed()) { - print_line("hidpi aware?"); HMODULE Shcore = LoadLibraryW(L"Shcore.dll"); if (Shcore != NULL) { @@ -1066,6 +1156,20 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int return ERR_UNAVAILABLE; } + use_raw_input = true; + + RAWINPUTDEVICE Rid[1]; + + Rid[0].usUsagePage = 0x01; + Rid[0].usUsage = 0x02; + Rid[0].dwFlags = 0; + Rid[0].hwndTarget = 0; + + if (RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])) == FALSE) { + //registration failed. + use_raw_input = false; + } + pre_fs_valid = true; if (video_mode.fullscreen) { @@ -1085,8 +1189,6 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int WindowRect.right = data.size.width; WindowRect.bottom = data.size.height; - print_line("wr right " + itos(WindowRect.right) + ", " + itos(WindowRect.bottom)); - /* DEVMODE dmScreenSettings; memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); dmScreenSettings.dmSize=sizeof(dmScreenSettings); @@ -1219,10 +1321,6 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int AudioDriverManager::initialize(p_audio_driver); -#ifdef WINMIDI_ENABLED - driver_midi.open(); -#endif - TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; @@ -1374,12 +1472,6 @@ void OS_Windows::finalize() { if (user_proc) { SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)user_proc); }; - - /* - if (debugger_connection_console) { - memdelete(debugger_connection_console); - } - */ } void OS_Windows::finalize_core() { @@ -1643,9 +1735,6 @@ void OS_Windows::set_window_fullscreen(bool p_enabled) { if (pre_fs_valid) { GetWindowRect(hWnd, &pre_fs_rect); - //print_line("A: "+itos(pre_fs_rect.left)+","+itos(pre_fs_rect.top)+","+itos(pre_fs_rect.right-pre_fs_rect.left)+","+itos(pre_fs_rect.bottom-pre_fs_rect.top)); - //MapWindowPoints(hWnd, GetParent(hWnd), (LPPOINT) &pre_fs_rect, 2); - //print_line("B: "+itos(pre_fs_rect.left)+","+itos(pre_fs_rect.top)+","+itos(pre_fs_rect.right-pre_fs_rect.left)+","+itos(pre_fs_rect.bottom-pre_fs_rect.top)); } int cs = get_current_screen(); @@ -2322,20 +2411,26 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, return OK; }; -Error OS_Windows::kill(const ProcessID &p_pid) { - +Error OS_Windows::kill(const ProcessID &p_pid, const int p_max_wait_msec) { ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi; process_map->erase(p_pid); - const int ret = TerminateProcess(pi.hProcess, 0); + Error result; + + if (p_max_wait_msec != -1 && _close_gracefully(pi, p_max_wait_msec)) { + result = OK; + } else { + const int ret = TerminateProcess(pi.hProcess, 0); + result = ret != 0 ? OK : FAILED; + } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - return ret != 0 ? OK : FAILED; -}; + return result; +} int OS_Windows::get_process_id() const { return _getpid(); @@ -2777,7 +2872,7 @@ int OS_Windows::get_power_percent_left() { bool OS_Windows::_check_internal_feature_support(const String &p_feature) { - return p_feature == "pc" || p_feature == "s3tc"; + return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc"; } void OS_Windows::disable_crash_handler() { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 69c7d851b8..243d4bb328 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -125,6 +125,7 @@ class OS_Windows : public OS { bool force_quit; bool window_has_focus; uint32_t last_button_state; + bool use_raw_input; HCURSOR cursors[CURSOR_MAX] = { NULL }; CursorShape cursor_shape; @@ -258,7 +259,7 @@ public: virtual uint64_t get_ticks_usec() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false); - virtual Error kill(const ProcessID &p_pid); + virtual Error kill(const ProcessID &p_pid, const int p_stop_max_wait_msec = -1); virtual int get_process_id() const; virtual bool has_environment(const String &p_var) const; diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index cd76667c64..5a239e326b 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -65,19 +65,6 @@ void ContextGL_X11::swap_buffers() { glXSwapBuffers(x11_display, x11_window); } -/* -static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { - - //print_line(String()+"getting proc of: "+p_function); - GLWrapperFuncPtr func=(GLWrapperFuncPtr)glXGetProcAddress( (const GLubyte*) p_function); - if (!func) { - print_line("Couldn't find function: "+String(p_function)); - } - - return func; - -}*/ - static bool ctxErrorOccurred = false; static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) { ctxErrorOccurred = true; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index a1e844898e..e4a72e0715 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -170,13 +170,13 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a #ifdef TOUCH_ENABLED if (!XQueryExtension(x11_display, "XInputExtension", &touch.opcode, &event_base, &error_base)) { - fprintf(stderr, "XInput extension not available"); + print_verbose("XInput extension not available, touch support disabled."); } else { // 2.2 is the first release with multitouch int xi_major = 2; int xi_minor = 2; if (XIQueryVersion(x11_display, &xi_major, &xi_minor) != Success) { - fprintf(stderr, "XInput 2.2 not available (server supports %d.%d)\n", xi_major, xi_minor); + print_verbose(vformat("XInput 2.2 not available (server supports %d.%d), touch support disabled.", xi_major, xi_minor)); touch.opcode = 0; } else { int dev_count; @@ -198,14 +198,14 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a } if (direct_touch) { touch.devices.push_back(dev->deviceid); - fprintf(stderr, "Using touch device: %s\n", dev->name); + print_verbose("XInput: Using touch device: " + String(dev->name)); } } XIFreeDeviceInfo(info); - if (is_stdout_verbose() && !touch.devices.size()) { - fprintf(stderr, "No touch devices found\n"); + if (!touch.devices.size()) { + print_verbose("XInput: No touch devices found."); } } } @@ -266,7 +266,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a */ // maybe contextgl wants to be in charge of creating the window -//print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) ContextGL_X11::ContextType opengl_api_type = ContextGL_X11::GLES_3_0_COMPATIBLE; @@ -342,10 +341,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a AudioDriverManager::initialize(p_audio_driver); -#ifdef ALSAMIDI_ENABLED - driver_alsamidi.open(); -#endif - ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); ERR_FAIL_COND_V(x11_window == 0, ERR_UNAVAILABLE); @@ -427,9 +422,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a cursor_theme = XcursorGetTheme(x11_display); if (!cursor_theme) { - if (is_stdout_verbose()) { - print_line("XcursorGetTheme could not get cursor theme"); - } + print_verbose("XcursorGetTheme could not get cursor theme"); cursor_theme = "default"; } @@ -442,7 +435,6 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a current_cursor = CURSOR_ARROW; if (cursor_theme) { - //print_line("cursor theme: "+String(cursor_theme)); for (int i = 0; i < CURSOR_MAX; i++) { static const char *cursor_file[] = { @@ -468,10 +460,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); if (img[i]) { cursors[i] = XcursorImageLoadCursor(x11_display, img[i]); - //print_line("found cursor: "+String(cursor_file[i])+" id "+itos(cursors[i])); } else { - if (OS::is_stdout_verbose()) - print_line("failed cursor: " + String(cursor_file[i])); + print_verbose("Failed loading custom cursor: " + String(cursor_file[i])); } } } @@ -1516,7 +1506,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // KeyMappingX11 also translates keysym to unicode. // It does a binary search on a table to translate // most properly. - //print_line("keysym_unicode: "+rtos(keysym_unicode)); unsigned int unicode = keysym_unicode > 0 ? KeyMappingX11::get_unicode_from_keysym(keysym_unicode) : 0; /* Phase 4, determine if event must be filtered */ @@ -1539,7 +1528,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // know Mod1 was ALT and Mod4 was META (applekey/winkey) // just tried Mods until i found them. - //print_line("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask)); + //print_verbose("mod1: "+itos(xkeyevent->state&Mod1Mask)+" mod 5: "+itos(xkeyevent->state&Mod5Mask)); Ref<InputEventKey> k; k.instance(); @@ -2344,7 +2333,7 @@ Error OS_X11::shell_open(String p_uri) { bool OS_X11::_check_internal_feature_support(const String &p_feature) { - return p_feature == "pc" || p_feature == "s3tc"; + return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc"; } String OS_X11::get_config_path() const { @@ -2575,51 +2564,146 @@ void OS_X11::swap_buffers() { } void OS_X11::alert(const String &p_alert, const String &p_title) { + const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" }; + + String path = get_environment("PATH"); + Vector<String> path_elems = path.split(":", false); + String program; + + for (int i = 0; i < path_elems.size(); i++) { + for (unsigned int k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { + String tested_path = path_elems[i] + "/" + message_programs[k]; + + if (FileAccess::exists(tested_path)) { + program = tested_path; + break; + } + } + + if (program.length()) + break; + } List<String> args; - args.push_back("-center"); - args.push_back("-title"); - args.push_back(p_title); - args.push_back(p_alert); - execute("xmessage", args, true); + if (program.ends_with("zenity")) { + args.push_back("--error"); + args.push_back("--width"); + args.push_back("500"); + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--text"); + args.push_back(p_alert); + } + + if (program.ends_with("kdialog")) { + args.push_back("--error"); + args.push_back(p_alert); + args.push_back("--title"); + args.push_back(p_title); + } + + if (program.ends_with("Xdialog")) { + args.push_back("--title"); + args.push_back(p_title); + args.push_back("--msgbox"); + args.push_back(p_alert); + args.push_back("0"); + args.push_back("0"); + } + + if (program.ends_with("xmessage")) { + args.push_back("-center"); + args.push_back("-title"); + args.push_back(p_title); + args.push_back(p_alert); + } + + if (program.length()) { + execute(program, args, true); + } else { + print_line(p_alert); + } + + return; +} + +bool g_set_icon_error = false; +int set_icon_errorhandler(Display *dpy, XErrorEvent *ev) { + g_set_icon_error = true; + return 0; } void OS_X11::set_icon(const Ref<Image> &p_icon) { + int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&set_icon_errorhandler); + Atom net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False); if (p_icon.is_valid()) { Ref<Image> img = p_icon->duplicate(); img->convert(Image::FORMAT_RGBA8); - int w = img->get_width(); - int h = img->get_height(); + while (true) { + int w = img->get_width(); + int h = img->get_height(); - // We're using long to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits - Vector<long> pd; + if (g_set_icon_error) { + g_set_icon_error = false; - pd.resize(2 + w * h); + WARN_PRINT("Icon too large, attempting to resize icon."); - pd.write[0] = w; - pd.write[1] = h; + int new_width, new_height; + if (w > h) { + new_width = w / 2; + new_height = h * new_width / w; + } else { + new_height = h / 2; + new_width = w * new_height / h; + } - PoolVector<uint8_t>::Read r = img->get_data().read(); + w = new_width; + h = new_height; - long *wr = &pd.write[2]; - uint8_t const *pr = r.ptr(); + if (!w || !h) { + WARN_PRINT("Unable to set icon."); + break; + } - for (int i = 0; i < w * h; i++) { - long v = 0; - // A R G B - v |= pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2]; - *wr++ = v; - pr += 4; + img->resize(w, h, Image::INTERPOLATE_CUBIC); + } + + // We're using long to have wordsize (32Bit build -> 32 Bits, 64 Bit build -> 64 Bits + Vector<long> pd; + + pd.resize(2 + w * h); + + pd.write[0] = w; + pd.write[1] = h; + + PoolVector<uint8_t>::Read r = img->get_data().read(); + + long *wr = &pd.write[2]; + uint8_t const *pr = r.ptr(); + + for (int i = 0; i < w * h; i++) { + long v = 0; + // A R G B + v |= pr[3] << 24 | pr[0] << 16 | pr[1] << 8 | pr[2]; + *wr++ = v; + pr += 4; + } + + XChangeProperty(x11_display, x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size()); + + if (!g_set_icon_error) + break; } - XChangeProperty(x11_display, x11_window, net_wm_icon, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)pd.ptr(), pd.size()); } else { XDeleteProperty(x11_display, x11_window, net_wm_icon); } + XFlush(x11_display); + XSetErrorHandler(oldHandler); } void OS_X11::force_process_input() { |