diff options
Diffstat (limited to 'platform')
31 files changed, 409 insertions, 404 deletions
diff --git a/platform/SCsub b/platform/SCsub index 2019a30be7..0f9c2047a0 100644 --- a/platform/SCsub +++ b/platform/SCsub @@ -18,10 +18,13 @@ for platform in env.platform_apis: reg_apis_inc += '\n' reg_apis += '}\n\n' unreg_apis += '}\n' + +# NOTE: It is safe to generate this file here, since this is still execute serially with open_utf8('register_platform_apis.gen.cpp', 'w') as f: - f.write(reg_apis_inc) - f.write(reg_apis) - f.write(unreg_apis) + f.write(reg_apis_inc) + f.write(reg_apis) + f.write(unreg_apis) + platform_sources.append('register_platform_apis.gen.cpp') lib = env.add_library('platform', platform_sources) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 59e35884d1..9ad0219746 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -665,11 +665,11 @@ class EditorExportAndroid : public EditorExportPlatform { ucstring.resize(len + 1); for (uint32_t j = 0; j < len; j++) { uint16_t c = decode_uint16(&p_manifest[string_at + 2 + 2 * j]); - ucstring[j] = c; + ucstring.write[j] = c; } string_end = MAX(string_at + 2 + 2 * len, string_end); - ucstring[len] = 0; - string_table[i] = ucstring.ptr(); + ucstring.write[len] = 0; + string_table.write[i] = ucstring.ptr(); } //print_line("String "+itos(i)+": "+string_table[i]); @@ -716,13 +716,13 @@ class EditorExportAndroid : public EditorExportPlatform { if (tname == "manifest" && attrname == "package") { print_line("FOUND package"); - string_table[attr_value] = get_package_name(package_name); + string_table.write[attr_value] = get_package_name(package_name); } if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionCode") { print_line("FOUND versionCode"); - encode_uint32(version_code, &p_manifest[iofs + 16]); + encode_uint32(version_code, &p_manifest.write[iofs + 16]); } if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionName") { @@ -731,12 +731,12 @@ class EditorExportAndroid : public EditorExportPlatform { if (attr_value == 0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else - string_table[attr_value] = version_name; + string_table.write[attr_value] = version_name; } if (tname == "activity" && /*nspace=="android" &&*/ attrname == "screenOrientation") { - encode_uint32(orientation == 0 ? 0 : 1, &p_manifest[iofs + 16]); + encode_uint32(orientation == 0 ? 0 : 1, &p_manifest.write[iofs + 16]); } if (tname == "uses-feature" && /*nspace=="android" &&*/ attrname == "glEsVersion") { @@ -747,19 +747,19 @@ class EditorExportAndroid : public EditorExportPlatform { if (attrname == "smallScreens") { - encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]); + encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); } else if (attrname == "normalScreens") { - encode_uint32(screen_support_normal ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]); + encode_uint32(screen_support_normal ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); } else if (attrname == "largeScreens") { - encode_uint32(screen_support_large ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]); + encode_uint32(screen_support_large ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); } else if (attrname == "xlargeScreens") { - encode_uint32(screen_support_xlarge ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]); + encode_uint32(screen_support_xlarge ? 0xFFFFFFFF : 0, &p_manifest.write[iofs + 16]); } } @@ -811,45 +811,45 @@ class EditorExportAndroid : public EditorExportPlatform { } // start tag - encode_uint16(0x102, &p_manifest[ofs]); // type - encode_uint16(16, &p_manifest[ofs + 2]); // headersize - encode_uint32(56, &p_manifest[ofs + 4]); // size - encode_uint32(0, &p_manifest[ofs + 8]); // lineno - encode_uint32(-1, &p_manifest[ofs + 12]); // comment - encode_uint32(-1, &p_manifest[ofs + 16]); // ns - encode_uint32(attr_uses_permission_string, &p_manifest[ofs + 20]); // name - encode_uint16(20, &p_manifest[ofs + 24]); // attr_start - encode_uint16(20, &p_manifest[ofs + 26]); // attr_size - encode_uint16(1, &p_manifest[ofs + 28]); // num_attrs - encode_uint16(0, &p_manifest[ofs + 30]); // id_index - encode_uint16(0, &p_manifest[ofs + 32]); // class_index - encode_uint16(0, &p_manifest[ofs + 34]); // style_index + encode_uint16(0x102, &p_manifest.write[ofs]); // type + encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize + encode_uint32(56, &p_manifest.write[ofs + 4]); // size + encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno + encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment + encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns + encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name + encode_uint16(20, &p_manifest.write[ofs + 24]); // attr_start + encode_uint16(20, &p_manifest.write[ofs + 26]); // attr_size + encode_uint16(1, &p_manifest.write[ofs + 28]); // num_attrs + encode_uint16(0, &p_manifest.write[ofs + 30]); // id_index + encode_uint16(0, &p_manifest.write[ofs + 32]); // class_index + encode_uint16(0, &p_manifest.write[ofs + 34]); // style_index // attribute - encode_uint32(ns_android_string, &p_manifest[ofs + 36]); // ns - encode_uint32(attr_name_string, &p_manifest[ofs + 40]); // 'name' - encode_uint32(perm_string, &p_manifest[ofs + 44]); // raw_value - encode_uint16(8, &p_manifest[ofs + 48]); // typedvalue_size - p_manifest[ofs + 50] = 0; // typedvalue_always0 - p_manifest[ofs + 51] = 0x03; // typedvalue_type (string) - encode_uint32(perm_string, &p_manifest[ofs + 52]); // typedvalue reference + encode_uint32(ns_android_string, &p_manifest.write[ofs + 36]); // ns + encode_uint32(attr_name_string, &p_manifest.write[ofs + 40]); // 'name' + encode_uint32(perm_string, &p_manifest.write[ofs + 44]); // raw_value + encode_uint16(8, &p_manifest.write[ofs + 48]); // typedvalue_size + p_manifest.write[ofs + 50] = 0; // typedvalue_always0 + p_manifest.write[ofs + 51] = 0x03; // typedvalue_type (string) + encode_uint32(perm_string, &p_manifest.write[ofs + 52]); // typedvalue reference ofs += 56; // end tag - encode_uint16(0x103, &p_manifest[ofs]); // type - encode_uint16(16, &p_manifest[ofs + 2]); // headersize - encode_uint32(24, &p_manifest[ofs + 4]); // size - encode_uint32(0, &p_manifest[ofs + 8]); // lineno - encode_uint32(-1, &p_manifest[ofs + 12]); // comment - encode_uint32(-1, &p_manifest[ofs + 16]); // ns - encode_uint32(attr_uses_permission_string, &p_manifest[ofs + 20]); // name + encode_uint16(0x103, &p_manifest.write[ofs]); // type + encode_uint16(16, &p_manifest.write[ofs + 2]); // headersize + encode_uint32(24, &p_manifest.write[ofs + 4]); // size + encode_uint32(0, &p_manifest.write[ofs + 8]); // lineno + encode_uint32(-1, &p_manifest.write[ofs + 12]); // comment + encode_uint32(-1, &p_manifest.write[ofs + 16]); // ns + encode_uint32(attr_uses_permission_string, &p_manifest.write[ofs + 20]); // name ofs += 24; } // copy footer back in - memcpy(&p_manifest[ofs], manifest_end.ptr(), manifest_end.size()); + memcpy(&p_manifest.write[ofs], manifest_end.ptr(), manifest_end.size()); } } break; } @@ -864,19 +864,19 @@ class EditorExportAndroid : public EditorExportPlatform { for (uint32_t i = 0; i < string_table_begins; i++) { - ret[i] = p_manifest[i]; + ret.write[i] = p_manifest[i]; } ofs = 0; for (int i = 0; i < string_table.size(); i++) { - encode_uint32(ofs, &ret[string_table_begins + i * 4]); + encode_uint32(ofs, &ret.write[string_table_begins + i * 4]); ofs += string_table[i].length() * 2 + 2 + 2; } ret.resize(ret.size() + ofs); string_data_offset = ret.size() - ofs; - uint8_t *chars = &ret[string_data_offset]; + uint8_t *chars = &ret.write[string_data_offset]; for (int i = 0; i < string_table.size(); i++) { String s = string_table[i]; @@ -903,15 +903,15 @@ class EditorExportAndroid : public EditorExportPlatform { uint32_t extra = (p_manifest.size() - string_table_ends); ret.resize(new_stable_end + extra); for (uint32_t i = 0; i < extra; i++) - ret[new_stable_end + i] = p_manifest[string_table_ends + i]; + ret.write[new_stable_end + i] = p_manifest[string_table_ends + i]; while (ret.size() % 4) ret.push_back(0); - encode_uint32(ret.size(), &ret[4]); //update new file size + encode_uint32(ret.size(), &ret.write[4]); //update new file size - encode_uint32(new_stable_end - 8, &ret[12]); //update new string table size - encode_uint32(string_table.size(), &ret[16]); //update new number of strings - encode_uint32(string_data_offset - 8, &ret[28]); //update new string data offset + encode_uint32(new_stable_end - 8, &ret.write[12]); //update new string table size + 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())); @@ -935,9 +935,9 @@ class EditorExportAndroid : public EditorExportPlatform { Vector<uint8_t> str8; str8.resize(len + 1); for (uint32_t i = 0; i < len; i++) { - str8[i] = p_bytes[offset + i]; + str8.write[i] = p_bytes[offset + i]; } - str8[len] = 0; + str8.write[len] = 0; String str; str.parse_utf8((const char *)str8.ptr()); return str; @@ -1001,18 +1001,18 @@ class EditorExportAndroid : public EditorExportPlatform { for (uint32_t i = 0; i < string_table_begins; i++) { - ret[i] = p_manifest[i]; + ret.write[i] = p_manifest[i]; } int ofs = 0; for (int i = 0; i < string_table.size(); i++) { - encode_uint32(ofs, &ret[string_table_begins + i * 4]); + encode_uint32(ofs, &ret.write[string_table_begins + i * 4]); ofs += string_table[i].length() * 2 + 2 + 2; } ret.resize(ret.size() + ofs); - uint8_t *chars = &ret[ret.size() - ofs]; + uint8_t *chars = &ret.write[ret.size() - ofs]; for (int i = 0; i < string_table.size(); i++) { String s = string_table[i]; @@ -1031,19 +1031,19 @@ class EditorExportAndroid : public EditorExportPlatform { ret.push_back(0); //change flags to not use utf8 - encode_uint32(string_flags & ~0x100, &ret[28]); + encode_uint32(string_flags & ~0x100, &ret.write[28]); //change length - encode_uint32(ret.size() - 12, &ret[16]); + encode_uint32(ret.size() - 12, &ret.write[16]); //append the rest... int rest_from = 12 + string_block_len; int rest_to = ret.size(); int rest_len = (p_manifest.size() - rest_from); ret.resize(ret.size() + (p_manifest.size() - rest_from)); for (int i = 0; i < rest_len; i++) { - ret[rest_to + i] = p_manifest[rest_from + i]; + ret.write[rest_to + i] = p_manifest[rest_from + i]; } //finally update the size - encode_uint32(ret.size(), &ret[4]); + encode_uint32(ret.size(), &ret.write[4]); p_manifest = ret; //printf("end\n"); @@ -1644,7 +1644,7 @@ public: //add comandline Vector<uint8_t> clf; clf.resize(4); - encode_uint32(cl.size(), &clf[0]); + encode_uint32(cl.size(), &clf.write[0]); for (int i = 0; i < cl.size(); i++) { print_line(itos(i) + " param: " + cl[i]); @@ -1654,8 +1654,8 @@ public: if (!length) continue; clf.resize(base + 4 + length); - encode_uint32(length, &clf[base]); - copymem(&clf[base + 4], txt.ptr(), length); + encode_uint32(length, &clf.write[base]); + copymem(&clf.write[base + 4], txt.ptr(), length); } zip_fileinfo zipfi = get_zip_fileinfo(); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index cc512263bc..f9eda9dff1 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -357,8 +357,8 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> touch.resize(p_points.size()); for (int i = 0; i < p_points.size(); i++) { - touch[i].id = p_points[i].id; - touch[i].pos = p_points[i].pos; + touch.write[i].id = p_points[i].id; + touch.write[i].pos = p_points[i].pos; } //send touch @@ -399,7 +399,7 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev->set_position(p_points[idx].pos); ev->set_relative(p_points[idx].pos - touch[i].pos); input->parse_input_event(ev); - touch[i].pos = p_points[idx].pos; + touch.write[i].pos = p_points[idx].pos; } } break; diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 1f901c4919..aeaf698015 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -100,7 +100,7 @@ int AudioDriverMediaKit::get_mix_rate() const { return mix_rate; } -AudioDriverSW::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const { +AudioDriverMediaKit::SpeakerMode AudioDriverMediaKit::get_speaker_mode() const { return speaker_mode; } diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h index a09403e7d6..02fefcf52a 100644 --- a/platform/haiku/audio_driver_media_kit.h +++ b/platform/haiku/audio_driver_media_kit.h @@ -35,9 +35,10 @@ #include "core/os/mutex.h" #include "core/os/thread.h" -#include <SoundPlayer.h> #include <kernel/image.h> // needed for image_id +#include <SoundPlayer.h> + class AudioDriverMediaKit : public AudioDriver { Mutex *mutex; diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py index 2959023204..7ecdd2bb11 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -64,6 +64,87 @@ def configure(env): env["CC"] = "gcc-x86" env["CXX"] = "g++-x86" + ## Dependencies + + if not env['builtin_libwebp']: + env.ParseConfig('pkg-config libwebp --cflags --libs') + + # freetype depends on libpng and zlib, so bundling one of them while keeping others + # as shared libraries leads to weird issues + if env['builtin_freetype'] or env['builtin_libpng'] or env['builtin_zlib']: + env['builtin_freetype'] = True + env['builtin_libpng'] = True + env['builtin_zlib'] = True + + if not env['builtin_freetype']: + env.ParseConfig('pkg-config freetype2 --cflags --libs') + + if not env['builtin_libpng']: + env.ParseConfig('pkg-config libpng --cflags --libs') + + if not env['builtin_bullet']: + # We need at least version 2.88 + import subprocess + bullet_version = subprocess.check_output(['pkg-config', 'bullet', '--modversion']).strip() + if bullet_version < "2.88": + # Abort as system bullet was requested but too old + print("Bullet: System version {0} does not match minimal requirements ({1}). Aborting.".format(bullet_version, "2.88")) + sys.exit(255) + env.ParseConfig('pkg-config bullet --cflags --libs') + + if not env['builtin_enet']: + env.ParseConfig('pkg-config libenet --cflags --libs') + + if not env['builtin_squish'] and env['tools']: + env.ParseConfig('pkg-config libsquish --cflags --libs') + + if not env['builtin_zstd']: + env.ParseConfig('pkg-config libzstd --cflags --libs') + + # Sound and video libraries + # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) + + if not env['builtin_libtheora']: + env['builtin_libogg'] = False # Needed to link against system libtheora + env['builtin_libvorbis'] = False # Needed to link against system libtheora + env.ParseConfig('pkg-config theora theoradec --cflags --libs') + + if not env['builtin_libvpx']: + env.ParseConfig('pkg-config vpx --cflags --libs') + + if not env['builtin_libvorbis']: + env['builtin_libogg'] = False # Needed to link against system libvorbis + env.ParseConfig('pkg-config vorbis vorbisfile --cflags --libs') + + if not env['builtin_opus']: + env['builtin_libogg'] = False # Needed to link against system opus + env.ParseConfig('pkg-config opus opusfile --cflags --libs') + + if not env['builtin_libogg']: + env.ParseConfig('pkg-config ogg --cflags --libs') + + if env['builtin_libtheora']: + list_of_x86 = ['x86_64', 'x86', 'i386', 'i586'] + if any(platform.machine() in s for s in list_of_x86): + env["x86_libtheora_opt_gcc"] = True + + if not env['builtin_libwebsockets']: + env.ParseConfig('pkg-config libwebsockets --cflags --libs') + + if not env['builtin_mbedtls']: + # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228 + env.Append(LIBS=['mbedtls', 'mbedcrypto', 'mbedx509']) + + if not env['builtin_miniupnpc']: + # No pkgconfig file so far, hardcode default paths. + env.Append(CPPPATH=["/system/develop/headers/x86/miniupnpc"]) + env.Append(LIBS=["miniupnpc"]) + + # On Linux wchar_t should be 32-bits + # 16-bit library shouldn't be required due to compiler optimisations + if not env['builtin_pcre2']: + env.ParseConfig('pkg-config libpcre2-32 --cflags --libs') + ## Flags env.Append(CPPPATH=['#platform/haiku']) diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h index f92969bbb1..a870037985 100644 --- a/platform/haiku/haiku_application.h +++ b/platform/haiku/haiku_application.h @@ -31,9 +31,10 @@ #ifndef HAIKU_APPLICATION_H #define HAIKU_APPLICATION_H -#include <Application.h> #include <kernel/image.h> // needed for image_id +#include <Application.h> + class HaikuApplication : public BApplication { public: HaikuApplication(); diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index b234a2ff91..7eeb226167 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -41,10 +41,14 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : last_buttons_state = 0; last_button_mask = 0; last_key_modifier_state = 0; + + view = NULL; + update_runner = NULL; + input = NULL; + main_loop = NULL; } HaikuDirectWindow::~HaikuDirectWindow() { - delete update_runner; } void HaikuDirectWindow::SetHaikuGLView(HaikuGLView *p_view) { @@ -53,7 +57,7 @@ void HaikuDirectWindow::SetHaikuGLView(HaikuGLView *p_view) { void HaikuDirectWindow::StartMessageRunner() { update_runner = new BMessageRunner(BMessenger(this), - new BMessage(REDRAW_MSG), 1000000 / 30 /* 30 fps */); + new BMessage(REDRAW_MSG), 1000000 / 60 /* 60 fps */); } void HaikuDirectWindow::StopMessageRunner() { @@ -69,6 +73,7 @@ void HaikuDirectWindow::SetMainLoop(MainLoop *p_main_loop) { } bool HaikuDirectWindow::QuitRequested() { + StopMessageRunner(); main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); return false; } @@ -152,39 +157,36 @@ void HaikuDirectWindow::HandleMouseButton(BMessage *message) { } */ - Ref<InputEvent> mouse_event; - mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON; - mouse_event.device = 0; + Ref<InputEventMouseButton> mouse_event; + mouse_event.instance(); - mouse_event.mouse_button.mod = GetKeyModifierState(modifiers); - mouse_event->get_button_mask() = GetMouseButtonState(buttons); - mouse_event->get_position().x = where.x; - mouse_event->get_position().y = where.y; - mouse_event.mouse_button.global_x = where.x; - mouse_event.mouse_button.global_y = where.y; + mouse_event->set_button_mask(GetMouseButtonState(buttons)); + mouse_event->set_position({ where.x, where.y }); + mouse_event->set_global_position({ where.x, where.y }); + GetKeyModifierState(mouse_event, modifiers); switch (button) { default: case B_PRIMARY_MOUSE_BUTTON: - mouse_event->get_button_index() = 1; + mouse_event->set_button_index(1); break; case B_SECONDARY_MOUSE_BUTTON: - mouse_event->get_button_index() = 2; + mouse_event->set_button_index(2); break; case B_TERTIARY_MOUSE_BUTTON: - mouse_event->get_button_index() = 3; + mouse_event->set_button_index(3); break; } - mouse_event->is_pressed() = (message->what == B_MOUSE_DOWN); + mouse_event->set_pressed(message->what == B_MOUSE_DOWN); if (message->what == B_MOUSE_DOWN && mouse_event->get_button_index() == 1) { int32 clicks = message->FindInt32("clicks"); if (clicks > 1) { - mouse_event.mouse_button.doubleclick = true; + mouse_event->set_doubleclick(true); } } @@ -208,22 +210,18 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage *message) { Point2i rel = pos - last_mouse_position; - Ref<InputEvent> motion_event; - motion_event.type = Ref<InputEvent>::MOUSE_MOTION; - motion_event.device = 0; + Ref<InputEventMouseMotion> motion_event; + motion_event.instance(); + GetKeyModifierState(motion_event, modifiers); - motion_event.mouse_motion.mod = GetKeyModifierState(modifiers); - motion_event->get_button_mask() = GetMouseButtonState(buttons); - motion_event.mouse_motion.x = pos.x; - motion_event.mouse_motion.y = pos.y; + motion_event->set_button_mask(GetMouseButtonState(buttons)); + motion_event->set_position({ pos.x, pos.y }); input->set_mouse_position(pos); - motion_event.mouse_motion.global_x = pos.x; - motion_event.mouse_motion.global_y = pos.y; - motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x; - motion_event.mouse_motion.speed_y = input->get_last_mouse_speed().y; + motion_event->set_global_position({ pos.x, pos.y }); + motion_event->set_speed({ input->get_last_mouse_speed().x, + input->get_last_mouse_speed().y }); - motion_event->get_relative().x = rel.x; - motion_event->get_relative().y = rel.y; + motion_event->set_relative({ rel.x, rel.y }); last_mouse_position = pos; @@ -236,22 +234,21 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage *message) { return; } - Ref<InputEvent> mouse_event; - mouse_event.type = Ref<InputEvent>::MOUSE_BUTTON; - mouse_event.device = 0; + Ref<InputEventMouseButton> mouse_event; + mouse_event.instance(); + //GetKeyModifierState(mouse_event, modifiers); - mouse_event->get_button_index() = wheel_delta_y < 0 ? 4 : 5; - mouse_event.mouse_button.mod = GetKeyModifierState(last_key_modifier_state); - mouse_event->get_button_mask() = last_button_mask; - mouse_event->get_position().x = last_mouse_position.x; - mouse_event->get_position().y = last_mouse_position.y; - mouse_event.mouse_button.global_x = last_mouse_position.x; - mouse_event.mouse_button.global_y = last_mouse_position.y; + mouse_event->set_button_index(wheel_delta_y < 0 ? 4 : 5); + mouse_event->set_button_mask(last_button_mask); + mouse_event->set_position({ last_mouse_position.x, + last_mouse_position.y }); + mouse_event->set_global_position({ last_mouse_position.x, + last_mouse_position.y }); - mouse_event->is_pressed() = true; + mouse_event->set_pressed(true); input->parse_input_event(mouse_event); - mouse_event->is_pressed() = false; + mouse_event->set_pressed(false); input->parse_input_event(mouse_event); } @@ -272,24 +269,23 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) { return; } - Ref<InputEvent> event; - event.type = Ref<InputEvent>::KEY; - event.device = 0; - event.key.mod = GetKeyModifierState(modifiers); - event->is_pressed() = (message->what == B_KEY_DOWN); - event->get_scancode() = KeyMappingHaiku::get_keysym(raw_char, key); - event->is_echo() = message->HasInt32("be:key_repeat"); - event.key.unicode = 0; + Ref<InputEventKey> event; + event.instance(); + GetKeyModifierState(event, modifiers); + event->set_pressed(message->what == B_KEY_DOWN); + event->set_scancode(KeyMappingHaiku::get_keysym(raw_char, key)); + event->set_echo(message->HasInt32("be:key_repeat")); + event->set_unicode(0); const char *bytes = NULL; if (message->FindString("bytes", &bytes) == B_OK) { - event.key.unicode = BUnicodeChar::FromUTF8(&bytes); + event->set_unicode(BUnicodeChar::FromUTF8(&bytes)); } //make it consistent across platforms. if (event->get_scancode() == KEY_BACKTAB) { - event->get_scancode() = KEY_TAB; - event->get_shift() = true; + event->set_scancode(KEY_TAB); + event->set_shift(true); } input->parse_input_event(event); @@ -309,14 +305,14 @@ void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage *message) { int32 key = old_modifiers ^ modifiers; - Ref<InputEvent> event; - event.type = Ref<InputEvent>::KEY; - event.device = 0; - event.key.mod = GetKeyModifierState(modifiers); - event->is_pressed() = ((modifiers & key) != 0); - event->get_scancode() = KeyMappingHaiku::get_modifier_keysym(key); - event->is_echo() = false; - event.key.unicode = 0; + Ref<InputEventWithModifiers> event; + event.instance(); + GetKeyModifierState(event, modifiers); + + event->set_shift(key & B_SHIFT_KEY); + event->set_alt(key & B_OPTION_KEY); + event->set_control(key & B_CONTROL_KEY); + event->set_command(key & B_COMMAND_KEY); input->parse_input_event(event); } @@ -333,14 +329,13 @@ void HaikuDirectWindow::HandleWindowResized(BMessage *message) { current_video_mode->height = height; } -inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) { +inline void HaikuDirectWindow::GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state) { last_key_modifier_state = p_state; - InputModifierState state; - state.shift = (p_state & B_SHIFT_KEY) != 0; - state.control = (p_state & B_CONTROL_KEY) != 0; - state.alt = (p_state & B_OPTION_KEY) != 0; - state.meta = (p_state & B_COMMAND_KEY) != 0; + event->set_shift(p_state & B_SHIFT_KEY); + event->set_control(p_state & B_CONTROL_KEY); + event->set_alt(p_state & B_OPTION_KEY); + event->set_metakey(p_state & B_COMMAND_KEY); return state; } diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 55c2f5fccc..eee09191fa 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -31,9 +31,10 @@ #ifndef HAIKU_DIRECT_WINDOW_H #define HAIKU_DIRECT_WINDOW_H -#include <DirectWindow.h> #include <kernel/image.h> // needed for image_id +#include <DirectWindow.h> + #include "core/os/os.h" #include "main/input_default.h" @@ -63,7 +64,7 @@ private: void HandleWindowResized(BMessage *message); void HandleKeyboardEvent(BMessage *message); void HandleKeyboardModifierEvent(BMessage *message); - inline InputModifierState GetKeyModifierState(uint32 p_state); + inline void GetKeyModifierState(Ref<InputEventWithModifiers> event, uint32 p_state); inline int GetMouseButtonState(uint32 p_state); public: diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h index 1a694dc13b..6869cb7de7 100644 --- a/platform/haiku/haiku_gl_view.h +++ b/platform/haiku/haiku_gl_view.h @@ -31,9 +31,10 @@ #ifndef HAIKU_GL_VIEW_H #define HAIKU_GL_VIEW_H -#include <GLView.h> #include <kernel/image.h> // needed for image_id +#include <GLView.h> + class HaikuGLView : public BGLView { public: HaikuGLView(BRect frame, uint32 type); diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 209cb5cec4..c80365f1f3 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -28,9 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "drivers/gles3/rasterizer_gles3.h" + #include "os_haiku.h" -#include "drivers/gles3/rasterizer_gles3.h" #include "main/main.h" #include "servers/physics/physics_server_sw.h" #include "servers/visual/visual_server_raster.h" @@ -111,13 +112,12 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p context_gl->initialize(); context_gl->make_current(); context_gl->set_use_vsync(current_video_mode.use_vsync); - - /* Port to GLES 3 rasterizer */ - //rasterizer = memnew(RasterizerGLES2); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); #endif - visual_server = memnew(VisualServerRaster(rasterizer)); + visual_server = memnew(VisualServerRaster()); ERR_FAIL_COND_V(!visual_server, ERR_UNAVAILABLE); @@ -138,8 +138,6 @@ Error OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p AudioDriverManager::initialize(p_audio_driver); - power_manager = memnew(PowerHaiku); - return OK; } @@ -152,7 +150,6 @@ void OS_Haiku::finalize() { visual_server->finish(); memdelete(visual_server); - memdelete(rasterizer); memdelete(input); @@ -336,7 +333,7 @@ String OS_Haiku::get_config_path() const { if (has_environment("XDG_CONFIG_HOME")) { return get_environment("XDG_CONFIG_HOME"); } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".config"); + return get_environment("HOME").plus_file("config/settings"); } else { return "."; } @@ -347,7 +344,7 @@ String OS_Haiku::get_data_path() const { if (has_environment("XDG_DATA_HOME")) { return get_environment("XDG_DATA_HOME"); } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".local/share"); + return get_environment("HOME").plus_file("config/data"); } else { return get_config_path(); } @@ -358,8 +355,23 @@ String OS_Haiku::get_cache_path() const { if (has_environment("XDG_CACHE_HOME")) { return get_environment("XDG_CACHE_HOME"); } else if (has_environment("HOME")) { - return get_environment("HOME").plus_file(".cache"); + return get_environment("HOME").plus_file("config/cache"); } else { return get_config_path(); } } + +OS::PowerState OS_Haiku::get_power_state() { + WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); + return OS::POWERSTATE_UNKNOWN; +} + +int OS_Haiku::get_power_seconds_left() { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; +} + +int OS_Haiku::get_power_percent_left() { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; +} diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 13d4420bde..e862eb44c3 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -37,9 +37,7 @@ #include "haiku_application.h" #include "haiku_direct_window.h" #include "main/input_default.h" -#include "power_haiku.h" #include "servers/audio_server.h" -#include "servers/visual/rasterizer.h" #include "servers/visual_server.h" class OS_Haiku : public OS_Unix { @@ -48,11 +46,9 @@ private: HaikuDirectWindow *window; MainLoop *main_loop; InputDefault *input; - Rasterizer *rasterizer; VisualServer *visual_server; VideoMode current_video_mode; int video_driver_index; - PowerHaiku *power_manager; #ifdef MEDIA_KIT_ENABLED AudioDriverMediaKit driver_media_kit; diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h index bbd72dfeb6..72c8ee2535 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -34,3 +34,4 @@ #define _BSD_SOURCE 1 #define GLES3_INCLUDE_H "glad/glad.h" +#define GLES2_INCLUDE_H "glad/glad.h" diff --git a/platform/haiku/power_haiku.cpp b/platform/haiku/power_haiku.cpp deleted file mode 100644 index 2a26dd0f9c..0000000000 --- a/platform/haiku/power_haiku.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************/ -/* power_haiku.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "core/error_macros.h" - -#include "power_haiku.h" - -bool PowerHaiku::UpdatePowerInfo() { - - return false; -} - -OS::PowerState PowerHaiku::get_power_state() { - if (UpdatePowerInfo()) { - return power_state; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); - return OS::POWERSTATE_UNKNOWN; - } -} - -int PowerX11::get_power_seconds_left() { - if (UpdatePowerInfo()) { - return nsecs_left; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); - return -1; - } -} - -int PowerX11::get_power_percent_left() { - if (UpdatePowerInfo()) { - return percent_left; - } else { - WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); - return -1; - } -} - -PowerHaiku::PowerHaiku() : - nsecs_left(-1), - percent_left(-1), - power_state(OS::POWERSTATE_UNKNOWN) { -} - -PowerHaiku::~PowerHaiku() { -} diff --git a/platform/haiku/power_haiku.h b/platform/haiku/power_haiku.h deleted file mode 100644 index 2fe85cd23d..0000000000 --- a/platform/haiku/power_haiku.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************/ -/* power_haiku.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef PLATFORM_HAIKU_POWER_HAIKU_H_ -#define PLATFORM_HAIKU_POWER_HAIKU_H_ - -#include <os/os.h> - -class PowerHaiku { -private: - int nsecs_left; - int percent_left; - OS::PowerState power_state; - - bool UpdatePowerInfo(); - -public: - PowerHaiku(); - virtual ~PowerHaiku(); - - OS::PowerState get_power_state(); - int get_power_seconds_left(); - int get_power_percent_left(); -}; - -#endif /* PLATFORM_HAIKU_POWER_HAIKU_H_ */ diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 5480d30e7a..e59c81a148 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -276,7 +276,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_ CharString cs = strnew.utf8(); pfile.resize(cs.size() - 1); for (int i = 0; i < cs.size() - 1; i++) { - pfile[i] = cs[i]; + pfile.write[i] = cs[i]; } } @@ -489,7 +489,7 @@ private: ret.resize(sizeof(num) * 2); for (int i = 0; i < sizeof(num) * 2; ++i) { uint8_t four_bits = (num >> (sizeof(num) * 8 - (i + 1) * 4)) & 0xF; - ret[i] = _hex_char(four_bits); + ret.write[i] = _hex_char(four_bits); } return String::utf8(ret.ptr(), ret.size()); } @@ -587,7 +587,7 @@ void EditorExportPlatformIOS::_add_assets_to_project(Vector<uint8_t> &p_project_ CharString cs = str.utf8(); p_project_data.resize(cs.size() - 1); for (int i = 0; i < cs.size() - 1; i++) { - p_project_data[i] = cs[i]; + p_project_data.write[i] = cs[i]; } } diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 9591850662..7cff6ba172 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -95,7 +95,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re CharString cs = str_export.utf8(); p_html.resize(cs.length()); for (int i = 0; i < cs.length(); i++) { - p_html[i] = cs[i]; + p_html.write[i] = cs[i]; } } diff --git a/platform/osx/SCsub b/platform/osx/SCsub index 4dfa46528a..5c973c30c2 100644 --- a/platform/osx/SCsub +++ b/platform/osx/SCsub @@ -3,14 +3,8 @@ import os Import('env') -def make_debug(target, source, env): - if (env["macports_clang"] != 'no'): - mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") - mpclangver = env["macports_clang"] - os.system(mpprefix + '/libexec/llvm-' + mpclangver + '/bin/llvm-dsymutil {0} -o {0}.dSYM'.format(target[0])) - else: - os.system('dsymutil {0} -o {0}.dSYM'.format(target[0])) - os.system('strip -u -r {0}'.format(target[0])) +from platform_methods import run_in_subprocess +import platform_osx_builders files = [ 'crash_handler_osx.mm', @@ -25,5 +19,5 @@ files = [ prog = env.add_program('#bin/godot', files) if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]: - env.AddPostAction(prog, make_debug) + env.AddPostAction(prog, run_in_subprocess(platform_osx_builders.make_debug_osx)) diff --git a/platform/osx/detect.py b/platform/osx/detect.py index af96659239..8a0883eca3 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -116,7 +116,7 @@ def configure(env): env.Append(CPPPATH=['#platform/osx']) env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED', '-DCOREMIDI_ENABLED']) - env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMidi', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) + env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMIDI', '-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 db265812fa..b630e4f223 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -137,10 +137,10 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ Vector<uint8_t> data; data.resize(8); - data[0] = 'i'; - data[1] = 'c'; - data[2] = 'n'; - data[3] = 's'; + data.write[0] = 'i'; + data.write[1] = 'c'; + data.write[2] = 'n'; + data.write[3] = 's'; const char *name[] = { "ic09", "ic08", "ic07", "icp6", "icp5", "icp4" }; int index = 0; @@ -160,19 +160,19 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ int ofs = data.size(); uint32_t len = f->get_len(); data.resize(data.size() + len + 8); - f->get_buffer(&data[ofs + 8], len); + f->get_buffer(&data.write[ofs + 8], len); memdelete(f); len += 8; len = BSWAP32(len); - copymem(&data[ofs], name[index], 4); - encode_uint32(len, &data[ofs + 4]); + copymem(&data.write[ofs], name[index], 4); + encode_uint32(len, &data.write[ofs + 4]); index++; size /= 2; } uint32_t total_len = data.size(); total_len = BSWAP32(total_len); - encode_uint32(total_len, &data[4]); + encode_uint32(total_len, &data.write[4]); p_data = data; } @@ -210,7 +210,7 @@ void EditorExportPlatformOSX::_fix_plist(const Ref<EditorExportPreset> &p_preset CharString cs = strnew.utf8(); plist.resize(cs.size() - 1); for (int i = 0; i < cs.size() - 1; i++) { - plist[i] = cs[i]; + plist.write[i] = cs[i]; } } diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 20ceadca9d..365b39c573 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -271,7 +271,7 @@ void JoypadOSX::_device_removed(int p_id) { ERR_FAIL_COND(device == -1); input->joy_connection_changed(p_id, false, ""); - device_list[device].free(); + device_list.write[device].free(); device_list.remove(device); } @@ -460,19 +460,19 @@ void JoypadOSX::process_joypads() { poll_joypads(); for (int i = 0; i < device_list.size(); i++) { - joypad &joy = device_list[i]; + joypad &joy = device_list.write[i]; for (int j = 0; j < joy.axis_elements.size(); j++) { - rec_element &elem = joy.axis_elements[j]; + rec_element &elem = joy.axis_elements.write[j]; int value = joy.get_hid_element_state(&elem); input->joy_axis(joy.id, j, axis_correct(value, elem.min, elem.max)); } for (int j = 0; j < joy.button_elements.size(); j++) { - int value = joy.get_hid_element_state(&joy.button_elements[j]); + int value = joy.get_hid_element_state(&joy.button_elements.write[j]); input->joy_button(joy.id, j, (value >= 1)); } for (int j = 0; j < joy.hat_elements.size(); j++) { - rec_element &elem = joy.hat_elements[j]; + rec_element &elem = joy.hat_elements.write[j]; int value = joy.get_hid_element_state(&elem); int hat_value = process_hat_value(elem.min, elem.max, value); input->joy_hat(joy.id, hat_value); @@ -495,7 +495,7 @@ void JoypadOSX::process_joypads() { } void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) { - joypad *joy = &device_list[get_joy_index(p_id)]; + joypad *joy = &device_list.write[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; joy->ff_effect.dwDuration = p_duration * FF_SECONDS; joy->ff_effect.dwGain = p_magnitude * FF_FFNOMINALMAX; @@ -504,7 +504,7 @@ void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_dura } void JoypadOSX::joypad_vibration_stop(int p_id, uint64_t p_timestamp) { - joypad *joy = &device_list[get_joy_index(p_id)]; + joypad *joy = &device_list.write[get_joy_index(p_id)]; joy->ff_timestamp = p_timestamp; FFEffectStop(joy->ff_object); } @@ -596,7 +596,7 @@ JoypadOSX::JoypadOSX() { JoypadOSX::~JoypadOSX() { for (int i = 0; i < device_list.size(); i++) { - device_list[i].free(); + device_list.write[i].free(); } IOHIDManagerUnscheduleFromRunLoop(hid_manager, CFRunLoopGetCurrent(), GODOT_JOY_LOOP_RUN_MODE); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index e77f8b3173..7bf274310d 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -95,7 +95,7 @@ static void push_to_key_event_buffer(const OS_OSX::KeyEvent &p_event) { if (OS_OSX::singleton->key_event_pos >= buffer.size()) { buffer.resize(1 + OS_OSX::singleton->key_event_pos); } - buffer[OS_OSX::singleton->key_event_pos++] = p_event; + buffer.write[OS_OSX::singleton->key_event_pos++] = p_event; } static int mouse_x = 0; @@ -602,8 +602,8 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) { mm->set_position(pos); mm->set_global_position(pos); Vector2 relativeMotion = Vector2(); - relativeMotion.x = [event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]); - relativeMotion.y = [event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]); + relativeMotion.x = [event deltaX] * OS_OSX::singleton -> _mouse_scale([[event window] backingScaleFactor]); + relativeMotion.y = [event deltaY] * OS_OSX::singleton -> _mouse_scale([[event window] backingScaleFactor]); mm->set_relative(relativeMotion); get_key_modifier_state([event modifierFlags], mm); @@ -2405,7 +2405,7 @@ void OS_OSX::process_key_events() { Ref<InputEventKey> k; for (int i = 0; i < key_event_pos; i++) { - KeyEvent &ke = key_event_buffer[i]; + const KeyEvent &ke = key_event_buffer[i]; if ((i == 0 && ke.scancode == 0) || (i > 0 && key_event_buffer[i - 1].scancode == 0)) { k.instance(); diff --git a/platform/osx/platform_osx_builders.py b/platform/osx/platform_osx_builders.py new file mode 100644 index 0000000000..81997f674b --- /dev/null +++ b/platform/osx/platform_osx_builders.py @@ -0,0 +1,21 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_osx(target, source, env): + if (env["macports_clang"] != 'no'): + mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") + mpclangver = env["macports_clang"] + os.system(mpprefix + '/libexec/llvm-' + mpclangver + '/bin/llvm-dsymutil {0} -o {0}.dSYM'.format(target[0])) + else: + os.system('dsymutil {0} -o {0}.dSYM'.format(target[0])) + os.system('strip -u -r {0}'.format(target[0])) + + +if __name__ == '__main__': + subprocess_main(globals()) diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 35c0b30ce4..ebc2c2d7a2 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -301,37 +301,37 @@ Vector<uint8_t> AppxPackager::make_file_header(FileMeta p_file_meta) { int offs = 0; // Write magic - offs += buf_put_int32(FILE_HEADER_MAGIC, &buf[offs]); + offs += buf_put_int32(FILE_HEADER_MAGIC, &buf.write[offs]); // Version - offs += buf_put_int16(ZIP_VERSION, &buf[offs]); + offs += buf_put_int16(ZIP_VERSION, &buf.write[offs]); // Special flag - offs += buf_put_int16(GENERAL_PURPOSE, &buf[offs]); + offs += buf_put_int16(GENERAL_PURPOSE, &buf.write[offs]); // Compression - offs += buf_put_int16(p_file_meta.compressed ? Z_DEFLATED : 0, &buf[offs]); + offs += buf_put_int16(p_file_meta.compressed ? Z_DEFLATED : 0, &buf.write[offs]); // File date and time - offs += buf_put_int32(0, &buf[offs]); + offs += buf_put_int32(0, &buf.write[offs]); // CRC-32 - offs += buf_put_int32(p_file_meta.file_crc32, &buf[offs]); + offs += buf_put_int32(p_file_meta.file_crc32, &buf.write[offs]); // Compressed size - offs += buf_put_int32(p_file_meta.compressed_size, &buf[offs]); + offs += buf_put_int32(p_file_meta.compressed_size, &buf.write[offs]); // Uncompressed size - offs += buf_put_int32(p_file_meta.uncompressed_size, &buf[offs]); + offs += buf_put_int32(p_file_meta.uncompressed_size, &buf.write[offs]); // File name length - offs += buf_put_int16(p_file_meta.name.length(), &buf[offs]); + offs += buf_put_int16(p_file_meta.name.length(), &buf.write[offs]); // Extra data length - offs += buf_put_int16(0, &buf[offs]); + offs += buf_put_int16(0, &buf.write[offs]); // File name - offs += buf_put_string(p_file_meta.name, &buf[offs]); + offs += buf_put_string(p_file_meta.name, &buf.write[offs]); // Done! return buf; @@ -344,47 +344,47 @@ void AppxPackager::store_central_dir_header(const FileMeta &p_file, bool p_do_ha buf.resize(buf.size() + BASE_CENTRAL_DIR_SIZE + p_file.name.length()); // Write magic - offs += buf_put_int32(CENTRAL_DIR_MAGIC, &buf[offs]); + offs += buf_put_int32(CENTRAL_DIR_MAGIC, &buf.write[offs]); // ZIP versions - offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]); - offs += buf_put_int16(ZIP_VERSION, &buf[offs]); + offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]); + offs += buf_put_int16(ZIP_VERSION, &buf.write[offs]); // General purpose flag - offs += buf_put_int16(GENERAL_PURPOSE, &buf[offs]); + offs += buf_put_int16(GENERAL_PURPOSE, &buf.write[offs]); // Compression - offs += buf_put_int16(p_file.compressed ? Z_DEFLATED : 0, &buf[offs]); + offs += buf_put_int16(p_file.compressed ? Z_DEFLATED : 0, &buf.write[offs]); // Modification date/time - offs += buf_put_int32(0, &buf[offs]); + offs += buf_put_int32(0, &buf.write[offs]); // Crc-32 - offs += buf_put_int32(p_file.file_crc32, &buf[offs]); + offs += buf_put_int32(p_file.file_crc32, &buf.write[offs]); // File sizes - offs += buf_put_int32(p_file.compressed_size, &buf[offs]); - offs += buf_put_int32(p_file.uncompressed_size, &buf[offs]); + offs += buf_put_int32(p_file.compressed_size, &buf.write[offs]); + offs += buf_put_int32(p_file.uncompressed_size, &buf.write[offs]); // File name length - offs += buf_put_int16(p_file.name.length(), &buf[offs]); + offs += buf_put_int16(p_file.name.length(), &buf.write[offs]); // Extra field length - offs += buf_put_int16(0, &buf[offs]); + offs += buf_put_int16(0, &buf.write[offs]); // Comment length - offs += buf_put_int16(0, &buf[offs]); + offs += buf_put_int16(0, &buf.write[offs]); // Disk number start, internal/external file attributes for (int i = 0; i < 8; i++) { - buf[offs++] = 0; + buf.write[offs++] = 0; } // Relative offset - offs += buf_put_int32(p_file.zip_offset, &buf[offs]); + offs += buf_put_int32(p_file.zip_offset, &buf.write[offs]); // File name - offs += buf_put_string(p_file.name, &buf[offs]); + offs += buf_put_string(p_file.name, &buf.write[offs]); // Done! } @@ -397,62 +397,62 @@ Vector<uint8_t> AppxPackager::make_end_of_central_record() { int offs = 0; // Write magic - offs += buf_put_int32(ZIP64_END_OF_CENTRAL_DIR_MAGIC, &buf[offs]); + offs += buf_put_int32(ZIP64_END_OF_CENTRAL_DIR_MAGIC, &buf.write[offs]); // Size of this record - offs += buf_put_int64(ZIP64_END_OF_CENTRAL_DIR_SIZE, &buf[offs]); + offs += buf_put_int64(ZIP64_END_OF_CENTRAL_DIR_SIZE, &buf.write[offs]); // Version (yes, twice) - offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]); - offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf[offs]); + offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]); + offs += buf_put_int16(ZIP_ARCHIVE_VERSION, &buf.write[offs]); // Disk number for (int i = 0; i < 8; i++) { - buf[offs++] = 0; + buf.write[offs++] = 0; } // Number of entries (total and per disk) - offs += buf_put_int64(file_metadata.size(), &buf[offs]); - offs += buf_put_int64(file_metadata.size(), &buf[offs]); + offs += buf_put_int64(file_metadata.size(), &buf.write[offs]); + offs += buf_put_int64(file_metadata.size(), &buf.write[offs]); // Size of central dir - offs += buf_put_int64(central_dir_data.size(), &buf[offs]); + offs += buf_put_int64(central_dir_data.size(), &buf.write[offs]); // Central dir offset - offs += buf_put_int64(central_dir_offset, &buf[offs]); + offs += buf_put_int64(central_dir_offset, &buf.write[offs]); ////// ZIP64 locator // Write magic for zip64 central dir locator - offs += buf_put_int32(ZIP64_END_DIR_LOCATOR_MAGIC, &buf[offs]); + offs += buf_put_int32(ZIP64_END_DIR_LOCATOR_MAGIC, &buf.write[offs]); // Disk number for (int i = 0; i < 4; i++) { - buf[offs++] = 0; + buf.write[offs++] = 0; } // Relative offset - offs += buf_put_int64(end_of_central_dir_offset, &buf[offs]); + offs += buf_put_int64(end_of_central_dir_offset, &buf.write[offs]); // Number of disks - offs += buf_put_int32(1, &buf[offs]); + offs += buf_put_int32(1, &buf.write[offs]); /////// End of zip directory // Write magic for end central dir - offs += buf_put_int32(END_OF_CENTRAL_DIR_MAGIC, &buf[offs]); + offs += buf_put_int32(END_OF_CENTRAL_DIR_MAGIC, &buf.write[offs]); // Dummy stuff for Zip64 for (int i = 0; i < 4; i++) { - buf[offs++] = 0x0; + buf.write[offs++] = 0x0; } for (int i = 0; i < 12; i++) { - buf[offs++] = 0xFF; + buf.write[offs++] = 0xFF; } // Size of comments for (int i = 0; i < 2; i++) { - buf[offs++] = 0; + buf.write[offs++] = 0; } // Done! @@ -508,7 +508,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t size_t block_size = (p_len - step) > BLOCK_SIZE ? BLOCK_SIZE : (p_len - step); for (uint32_t i = 0; i < block_size; i++) { - strm_in[i] = p_buffer[step + i]; + strm_in.write[i] = p_buffer[step + i]; } BlockHash bh; @@ -530,14 +530,14 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + bh.compressed_size); for (uint32_t i = 0; i < bh.compressed_size; i++) - file_buffer[start + i] = strm_out[i]; + file_buffer.write[start + i] = strm_out[i]; } else { bh.compressed_size = block_size; //package->store_buffer(strm_in.ptr(), block_size); int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + block_size); for (uint32_t i = 0; i < bh.compressed_size; i++) - file_buffer[start + i] = strm_in[i]; + file_buffer.write[start + i] = strm_in[i]; } meta.hashes.push_back(bh); @@ -560,7 +560,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before)); for (uint32_t i = 0; i < (strm.total_out - total_out_before); i++) - file_buffer[start + i] = strm_out[i]; + file_buffer.write[start + i] = strm_out[i]; deflateEnd(&strm); meta.compressed_size = strm.total_out; @@ -864,7 +864,7 @@ class EditorExportUWP : public EditorExportPlatform { r_ret.resize(result.length()); for (int i = 0; i < result.length(); i++) - r_ret[i] = result.utf8().get(i); + r_ret.write[i] = result.utf8().get(i); return r_ret; } @@ -1371,8 +1371,8 @@ public: CharString txt = cl[i].utf8(); int base = clf.size(); clf.resize(base + 4 + txt.length()); - encode_uint32(txt.length(), &clf[base]); - copymem(&clf[base + 4], txt.ptr(), txt.length()); + encode_uint32(txt.length(), &clf.write[base]); + copymem(&clf.write[base + 4], txt.ptr(), txt.length()); print_line(itos(i) + " param: " + cl[i]); } diff --git a/platform/windows/SCsub b/platform/windows/SCsub index ed3827353d..53ed3bf887 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -3,15 +3,8 @@ import os Import('env') -def make_debug_mingw(target, source, env): - mingw_prefix = "" - if (env["bits"] == "32"): - mingw_prefix = env["mingw_prefix_32"] - else: - mingw_prefix = env["mingw_prefix_64"] - os.system(mingw_prefix + 'objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) - os.system(mingw_prefix + 'strip --strip-debug --strip-unneeded {0}'.format(target[0])) - os.system(mingw_prefix + 'objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) +from platform_methods import run_in_subprocess +import platform_windows_builders common_win = [ "context_gl_win.cpp", @@ -40,4 +33,4 @@ if env['vsproj']: if not os.getenv("VCINSTALLDIR"): if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]: - env.AddPostAction(prog, make_debug_mingw) + env.AddPostAction(prog, run_in_subprocess(platform_windows_builders.make_debug_mingw)) diff --git a/platform/windows/lang_table.h b/platform/windows/lang_table.h index 1a966b502a..78bfadfeae 100644 --- a/platform/windows/lang_table.h +++ b/platform/windows/lang_table.h @@ -186,6 +186,7 @@ static const _WinLocale _win_locales[] = { { "zh_CN", LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED }, { "zh_HK", LANG_CHINESE, SUBLANG_CHINESE_HONGKONG }, { "zh_SG", LANG_CHINESE, SUBLANG_CHINESE_SINGAPORE }, + { "zh_TW", LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL }, { 0, 0, 0 }, }; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index e083fd7323..d6cfd039d9 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2299,7 +2299,7 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Vector<CharType> modstr; //windows wants to change this no idea why modstr.resize(cmdline.size()); for (int i = 0; i < cmdline.size(); i++) - modstr[i] = cmdline[i]; + modstr.write[i] = cmdline[i]; int ret = CreateProcessW(NULL, modstr.ptrw(), NULL, NULL, 0, NORMAL_PRIORITY_CLASS, NULL, NULL, si_w, &pi.pi); ERR_FAIL_COND_V(ret == 0, ERR_CANT_FORK); @@ -2309,6 +2309,8 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, if (r_exitcode) *r_exitcode = ret; + CloseHandle(pi.pi.hProcess); + CloseHandle(pi.pi.hThread); } else { ProcessID pid = pi.pi.dwProcessId; @@ -2322,17 +2324,15 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments, Error OS_Windows::kill(const ProcessID &p_pid) { - HANDLE h; + ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); - if (process_map->has(p_pid)) { - h = (*process_map)[p_pid].pi.hProcess; - process_map->erase(p_pid); - } else { + const PROCESS_INFORMATION pi = (*process_map)[p_pid].pi; + process_map->erase(p_pid); - ERR_FAIL_COND_V(!process_map->has(p_pid), FAILED); - }; + const int ret = TerminateProcess(pi.hProcess, 0); - int ret = TerminateProcess(h, 0); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); return ret != 0 ? OK : FAILED; }; @@ -2370,7 +2370,7 @@ void OS_Windows::set_icon(const Ref<Image> &p_icon) { int icon_len = 40 + h * w * 4; Vector<BYTE> v; v.resize(icon_len); - BYTE *icon_bmp = &v[0]; + BYTE *icon_bmp = v.ptrw(); encode_uint32(40, &icon_bmp[0]); encode_uint32(w, &icon_bmp[4]); @@ -2789,23 +2789,17 @@ bool OS_Windows::is_disable_crash_handler() const { } Error OS_Windows::move_to_trash(const String &p_path) { - SHFILEOPSTRUCTA sf; - TCHAR *from = new TCHAR[p_path.length() + 2]; - strcpy(from, p_path.utf8().get_data()); - from[p_path.length()] = 0; - from[p_path.length() + 1] = 0; - + SHFILEOPSTRUCTW sf; sf.hwnd = hWnd; sf.wFunc = FO_DELETE; - sf.pFrom = from; + sf.pFrom = p_path.c_str(); sf.pTo = NULL; sf.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; sf.fAnyOperationsAborted = FALSE; sf.hNameMappings = NULL; sf.lpszProgressTitle = NULL; - int ret = SHFileOperation(&sf); - delete[] from; + int ret = SHFileOperationW(&sf); if (ret) { ERR_PRINTS("SHFileOperation error: " + itos(ret)); diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py new file mode 100644 index 0000000000..a1ad3b8b50 --- /dev/null +++ b/platform/windows/platform_windows_builders.py @@ -0,0 +1,22 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_mingw(target, source, env): + mingw_prefix = "" + if (env["bits"] == "32"): + mingw_prefix = env["mingw_prefix_32"] + else: + mingw_prefix = env["mingw_prefix_64"] + os.system(mingw_prefix + 'objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) + os.system(mingw_prefix + 'strip --strip-debug --strip-unneeded {0}'.format(target[0])) + os.system(mingw_prefix + 'objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) + + +if __name__ == '__main__': + subprocess_main(globals()) diff --git a/platform/x11/SCsub b/platform/x11/SCsub index d0f77892ef..d3901eb798 100644 --- a/platform/x11/SCsub +++ b/platform/x11/SCsub @@ -3,10 +3,8 @@ import os Import('env') -def make_debug(target, source, env): - os.system('objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) - os.system('strip --strip-debug --strip-unneeded {0}'.format(target[0])) - os.system('objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) +from platform_methods import run_in_subprocess +import platform_x11_builders common_x11 = [ "context_gl_x11.cpp", @@ -20,4 +18,4 @@ common_x11 = [ prog = env.add_program('#bin/godot', ['godot_x11.cpp'] + common_x11) if (env["debug_symbols"] == "full" or env["debug_symbols"] == "yes") and env["separate_debug_symbols"]: - env.AddPostAction(prog, make_debug) + env.AddPostAction(prog, run_in_subprocess(platform_x11_builders.make_debug_x11)) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 260ce57732..9d1e3291b7 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1838,8 +1838,8 @@ void OS_X11::process_xevents() { GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime); } #ifdef TOUCH_ENABLED - // Grab touch devices to avoid OS gesture interference - /*for (int i = 0; i < touch.devices.size(); ++i) { + // Grab touch devices to avoid OS gesture interference + /*for (int i = 0; i < touch.devices.size(); ++i) { XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); }*/ #endif @@ -2105,7 +2105,7 @@ void OS_X11::process_xevents() { Vector<String> files = String((char *)p.data).split("\n", false); for (int i = 0; i < files.size(); i++) { - files[i] = files[i].replace("file://", "").replace("%20", " ").strip_escapes(); + files.write[i] = files[i].replace("file://", "").replace("%20", " ").strip_escapes(); } main_loop->drop_files(files); @@ -2587,12 +2587,12 @@ void OS_X11::set_icon(const Ref<Image> &p_icon) { pd.resize(2 + w * h); - pd[0] = w; - pd[1] = h; + pd.write[0] = w; + pd.write[1] = h; PoolVector<uint8_t>::Read r = img->get_data().read(); - long *wr = &pd[2]; + long *wr = &pd.write[2]; uint8_t const *pr = r.ptr(); for (int i = 0; i < w * h; i++) { diff --git a/platform/x11/platform_x11_builders.py b/platform/x11/platform_x11_builders.py new file mode 100644 index 0000000000..5ff0c6fb14 --- /dev/null +++ b/platform/x11/platform_x11_builders.py @@ -0,0 +1,17 @@ +"""Functions used to generate source files during build time + +All such functions are invoked in a subprocess on Windows to prevent build flakiness. + +""" +import os +from platform_methods import subprocess_main + + +def make_debug_x11(target, source, env): + os.system('objcopy --only-keep-debug {0} {0}.debugsymbols'.format(target[0])) + os.system('strip --strip-debug --strip-unneeded {0}'.format(target[0])) + os.system('objcopy --add-gnu-debuglink={0}.debugsymbols {0}'.format(target[0])) + + +if __name__ == '__main__': + subprocess_main(globals()) |