summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/SCsub2
-rw-r--r--platform/android/android_keys_utils.h4
-rw-r--r--platform/android/api/java_class_wrapper.h4
-rw-r--r--platform/android/audio_driver_opensl.cpp2
-rw-r--r--platform/android/audio_driver_opensl.h12
-rw-r--r--platform/android/detect.py2
-rw-r--r--platform/android/dir_access_jandroid.cpp4
-rw-r--r--platform/android/display_server_android.cpp52
-rw-r--r--platform/android/display_server_android.h21
-rw-r--r--platform/android/export/export.cpp6
-rw-r--r--platform/android/file_access_android.cpp5
-rw-r--r--platform/android/file_access_android.h9
-rw-r--r--platform/android/file_access_jandroid.cpp197
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java5
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java7
-rw-r--r--platform/android/java_godot_lib_jni.cpp10
-rw-r--r--platform/android/java_godot_view_wrapper.cpp66
-rw-r--r--platform/android/java_godot_view_wrapper.h (renamed from platform/android/file_access_jandroid.h)63
-rw-r--r--platform/android/java_godot_wrapper.cpp10
-rw-r--r--platform/android/java_godot_wrapper.h4
-rw-r--r--platform/android/os_android.cpp11
-rw-r--r--platform/iphone/export/export.cpp14
-rw-r--r--platform/javascript/SCsub6
-rw-r--r--platform/javascript/audio_driver_javascript.cpp4
-rw-r--r--platform/javascript/detect.py53
-rw-r--r--platform/javascript/export/export.cpp23
-rw-r--r--platform/javascript/godot_audio.h2
-rw-r--r--platform/javascript/js/libs/library_godot_audio.js26
-rw-r--r--platform/javascript/os_javascript.cpp2
-rw-r--r--platform/linuxbsd/detect_prime_x11.cpp2
-rw-r--r--platform/linuxbsd/display_server_x11.h30
-rw-r--r--platform/linuxbsd/joypad_linux.cpp9
-rw-r--r--platform/linuxbsd/joypad_linux.h13
-rw-r--r--platform/osx/display_server_osx.h14
-rw-r--r--platform/osx/export/export.cpp2
-rw-r--r--platform/osx/joypad_osx.cpp8
-rw-r--r--platform/osx/joypad_osx.h18
-rw-r--r--platform/osx/os_osx.mm2
-rw-r--r--platform/server/os_server.cpp8
-rw-r--r--platform/server/os_server.h14
-rw-r--r--platform/uwp/context_egl_uwp.cpp3
-rw-r--r--platform/uwp/export/export.cpp6
-rw-r--r--platform/uwp/joypad_uwp.h21
-rw-r--r--platform/uwp/os_uwp.h14
-rw-r--r--platform/windows/context_gl_windows.cpp1
-rw-r--r--platform/windows/crash_handler_windows.cpp2
-rw-r--r--platform/windows/detect.py2
-rw-r--r--platform/windows/joypad_windows.h20
-rw-r--r--platform/windows/os_windows.cpp14
51 files changed, 368 insertions, 471 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub
index ec42bc42b5..d8013b0baf 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -6,7 +6,6 @@ android_files = [
"os_android.cpp",
"file_access_android.cpp",
"audio_driver_opensl.cpp",
- "file_access_jandroid.cpp",
"dir_access_jandroid.cpp",
"thread_jandroid.cpp",
"net_socket_android.cpp",
@@ -14,6 +13,7 @@ android_files = [
"java_godot_lib_jni.cpp",
"java_class_wrapper.cpp",
"java_godot_wrapper.cpp",
+ "java_godot_view_wrapper.cpp",
"java_godot_io_wrapper.cpp",
"jni_utils.cpp",
"android_keys_utils.cpp",
diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h
index a10afa1df8..4a34e77324 100644
--- a/platform/android/android_keys_utils.h
+++ b/platform/android/android_keys_utils.h
@@ -35,8 +35,8 @@
#include <core/os/keyboard.h>
struct _WinTranslatePair {
- unsigned int keysym;
- unsigned int keycode;
+ unsigned int keysym = 0;
+ unsigned int keycode = 0;
};
static _WinTranslatePair _ak_to_keycode[] = {
diff --git a/platform/android/api/java_class_wrapper.h b/platform/android/api/java_class_wrapper.h
index 64da049407..63d71f5cf1 100644
--- a/platform/android/api/java_class_wrapper.h
+++ b/platform/android/api/java_class_wrapper.h
@@ -66,10 +66,10 @@ class JavaClass : public Reference {
Map<StringName, Variant> constant_map;
struct MethodInfo {
- bool _static;
+ bool _static = false;
Vector<uint32_t> param_types;
Vector<StringName> param_sigs;
- uint32_t return_type;
+ uint32_t return_type = 0;
jmethodID method;
};
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index 740e9a3132..e96e80e967 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -339,6 +339,4 @@ void AudioDriverOpenSL::set_pause(bool p_pause) {
AudioDriverOpenSL::AudioDriverOpenSL() {
s_ad = this;
- pause = false;
- active = false;
}
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index b30711705b..999cbe4657 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -38,19 +38,19 @@
#include <SLES/OpenSLES_Android.h>
class AudioDriverOpenSL : public AudioDriver {
- bool active;
+ bool active = false;
Mutex mutex;
enum {
BUFFER_COUNT = 2
};
- bool pause;
+ bool pause = false;
- uint32_t buffer_size;
- int16_t *buffers[BUFFER_COUNT];
- int32_t *mixdown_buffer;
- int last_free;
+ uint32_t buffer_size = 0;
+ int16_t *buffers[BUFFER_COUNT] = {};
+ int32_t *mixdown_buffer = nullptr;
+ int last_free = 0;
Vector<int16_t> rec_buffer;
diff --git a/platform/android/detect.py b/platform/android/detect.py
index 60d4146712..650606ff8b 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -334,6 +334,6 @@ def get_ndk_version(path):
key_value = list(map(lambda x: x.strip(), line.split("=")))
if key_value[0] == "Pkg.Revision":
return key_value[1]
- except:
+ except Exception:
print("Could not read source prop file '%s'" % prop_file_path)
return None
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index ba75a4b10c..ac619973d2 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -30,7 +30,7 @@
#include "dir_access_jandroid.h"
#include "core/string/print_string.h"
-#include "file_access_jandroid.h"
+#include "file_access_android.h"
#include "string_android.h"
#include "thread_jandroid.h"
@@ -146,7 +146,7 @@ bool DirAccessJAndroid::file_exists(String p_file) {
else
sd = current_dir.plus_file(p_file);
- FileAccessJAndroid *f = memnew(FileAccessJAndroid);
+ FileAccessAndroid *f = memnew(FileAccessAndroid);
bool exists = f->file_exists(sd);
memdelete(f);
diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp
index c8ed44d699..8711a4333c 100644
--- a/platform/android/display_server_android.cpp
+++ b/platform/android/display_server_android.cpp
@@ -686,7 +686,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) {
}
}
-void DisplayServerAndroid::process_mouse_event(int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
+void DisplayServerAndroid::process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor, float event_horizontal_factor) {
int event_buttons_mask = _android_button_mask_to_godot_button_mask(event_android_buttons_mask);
switch (event_action) {
case AMOTION_EVENT_ACTION_BUTTON_PRESS:
@@ -694,8 +694,13 @@ void DisplayServerAndroid::process_mouse_event(int event_action, int event_andro
Ref<InputEventMouseButton> ev;
ev.instance();
_set_key_modifier_state(ev);
- ev->set_position(event_pos);
- ev->set_global_position(event_pos);
+ if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
+ ev->set_position(event_pos);
+ ev->set_global_position(event_pos);
+ } else {
+ ev->set_position(hover_prev_pos);
+ ev->set_global_position(hover_prev_pos);
+ }
ev->set_pressed(event_action == AMOTION_EVENT_ACTION_BUTTON_PRESS);
int changed_button_mask = buttons_state ^ event_buttons_mask;
@@ -710,18 +715,29 @@ void DisplayServerAndroid::process_mouse_event(int event_action, int event_andro
Ref<InputEventMouseMotion> ev;
ev.instance();
_set_key_modifier_state(ev);
- ev->set_position(event_pos);
- ev->set_global_position(event_pos);
- ev->set_relative(event_pos - hover_prev_pos);
+ if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
+ ev->set_position(event_pos);
+ ev->set_global_position(event_pos);
+ ev->set_relative(event_pos - hover_prev_pos);
+ hover_prev_pos = event_pos;
+ } else {
+ ev->set_position(hover_prev_pos);
+ ev->set_global_position(hover_prev_pos);
+ ev->set_relative(event_pos);
+ }
ev->set_button_mask(event_buttons_mask);
Input::get_singleton()->accumulate_input_event(ev);
- hover_prev_pos = event_pos;
} break;
case AMOTION_EVENT_ACTION_SCROLL: {
Ref<InputEventMouseButton> ev;
ev.instance();
- ev->set_position(event_pos);
- ev->set_global_position(event_pos);
+ if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
+ ev->set_position(event_pos);
+ ev->set_global_position(event_pos);
+ } else {
+ ev->set_position(hover_prev_pos);
+ ev->set_global_position(hover_prev_pos);
+ }
ev->set_pressed(true);
buttons_state = event_buttons_mask;
if (event_vertical_factor > 0) {
@@ -809,6 +825,24 @@ void DisplayServerAndroid::process_gyroscope(const Vector3 &p_gyroscope) {
Input::get_singleton()->set_gyroscope(p_gyroscope);
}
+void DisplayServerAndroid::mouse_set_mode(MouseMode p_mode) {
+ if (mouse_mode == p_mode) {
+ return;
+ }
+
+ if (p_mode == MouseMode::MOUSE_MODE_CAPTURED) {
+ OS_Android::get_singleton()->get_godot_java()->get_godot_view()->request_pointer_capture();
+ } else {
+ OS_Android::get_singleton()->get_godot_java()->get_godot_view()->release_pointer_capture();
+ }
+
+ mouse_mode = p_mode;
+}
+
+DisplayServer::MouseMode DisplayServerAndroid::mouse_get_mode() const {
+ return mouse_mode;
+}
+
Point2i DisplayServerAndroid::mouse_get_position() const {
return hover_prev_pos;
}
diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h
index aa5a2c1185..f1f1a6a278 100644
--- a/platform/android/display_server_android.h
+++ b/platform/android/display_server_android.h
@@ -41,7 +41,7 @@ class RenderingDeviceVulkan;
class DisplayServerAndroid : public DisplayServer {
public:
struct TouchPos {
- int id;
+ int id = 0;
Point2 pos;
};
@@ -52,12 +52,12 @@ public:
};
struct JoypadEvent {
- int device;
- int type;
- int index;
- bool pressed;
- float value;
- int hat;
+ int device = 0;
+ int type = 0;
+ int index = 0;
+ bool pressed = false;
+ float value = 0;
+ int hat = 0;
};
private:
@@ -70,6 +70,8 @@ private:
int buttons_state;
+ MouseMode mouse_mode;
+
bool keep_screen_on;
Vector<TouchPos> touch;
@@ -172,12 +174,15 @@ public:
void process_gyroscope(const Vector3 &p_gyroscope);
void process_touch(int p_event, int p_pointer, const Vector<TouchPos> &p_points);
void process_hover(int p_type, Point2 p_pos);
- void process_mouse_event(int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor = 0, float event_horizontal_factor = 0);
+ void process_mouse_event(int input_device, int event_action, int event_android_buttons_mask, Point2 event_pos, float event_vertical_factor = 0, float event_horizontal_factor = 0);
void process_double_tap(int event_android_button_mask, Point2 p_pos);
void process_scroll(Point2 p_pos);
void process_joy_event(JoypadEvent p_event);
void process_key_event(int p_keycode, int p_scancode, int p_unicode_char, bool p_pressed);
+ void mouse_set_mode(MouseMode p_mode);
+ MouseMode mouse_get_mode() const;
+
static DisplayServer *create_func(const String &p_rendering_driver, WindowMode p_mode, uint32_t p_flags, const Vector2i &p_resolution, Error &r_error);
static Vector<String> get_rendering_drivers_func();
static void register_android_driver();
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index d24c96f87a..eed3b226c8 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -205,7 +205,7 @@ static const char *SPLASH_BG_COLOR_PATH = "res/drawable/splash_bg_color.png";
struct LauncherIcon {
const char *export_path;
- int dimensions;
+ int dimensions = 0;
};
static const int icon_densities_count = 6;
@@ -250,12 +250,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String id;
String name;
String description;
- int api_level;
+ int api_level = 0;
};
struct APKExportData {
zipFile apk;
- EditorProgress *ep;
+ EditorProgress *ep = nullptr;
};
Vector<PluginConfig> plugins;
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index 2446ca2829..0d933fb858 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -157,11 +157,6 @@ bool FileAccessAndroid::file_exists(const String &p_path) {
return true;
}
-FileAccessAndroid::FileAccessAndroid() {
- a = nullptr;
- eof = false;
-}
-
FileAccessAndroid::~FileAccessAndroid() {
close();
}
diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h
index a347c63ffb..7fc7d8c83d 100644
--- a/platform/android/file_access_android.h
+++ b/platform/android/file_access_android.h
@@ -39,10 +39,10 @@
class FileAccessAndroid : public FileAccess {
static FileAccess *create_android();
- mutable AAsset *a;
- mutable size_t len;
- mutable size_t pos;
- mutable bool eof;
+ mutable AAsset *a = nullptr;
+ mutable size_t len = 0;
+ mutable size_t pos = 0;
+ mutable bool eof = false;
public:
static AAssetManager *asset_manager;
@@ -74,7 +74,6 @@ public:
//static void make_default();
- FileAccessAndroid();
~FileAccessAndroid();
};
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
deleted file mode 100644
index df8b57fd3a..0000000000
--- a/platform/android/file_access_jandroid.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*************************************************************************/
-/* file_access_jandroid.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 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 "file_access_jandroid.h"
-#include "core/os/os.h"
-#include "thread_jandroid.h"
-#include <unistd.h>
-
-jobject FileAccessJAndroid::io = nullptr;
-jclass FileAccessJAndroid::cls;
-jmethodID FileAccessJAndroid::_file_open = 0;
-jmethodID FileAccessJAndroid::_file_get_size = 0;
-jmethodID FileAccessJAndroid::_file_seek = 0;
-jmethodID FileAccessJAndroid::_file_read = 0;
-jmethodID FileAccessJAndroid::_file_tell = 0;
-jmethodID FileAccessJAndroid::_file_eof = 0;
-jmethodID FileAccessJAndroid::_file_close = 0;
-
-FileAccess *FileAccessJAndroid::create_jandroid() {
- return memnew(FileAccessJAndroid);
-}
-
-Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) {
- if (is_open())
- close();
-
- String path = fix_path(p_path).simplify_path();
- if (path.begins_with("/"))
- path = path.substr(1, path.length());
- else if (path.begins_with("res://"))
- path = path.substr(6, path.length());
-
- JNIEnv *env = ThreadAndroid::get_env();
-
- jstring js = env->NewStringUTF(path.utf8().get_data());
- int res = env->CallIntMethod(io, _file_open, js, (p_mode_flags & WRITE) ? true : false);
- env->DeleteLocalRef(js);
-
- OS::get_singleton()->print("fopen: '%s' ret %i\n", path.utf8().get_data(), res);
-
- if (res <= 0)
- return ERR_FILE_CANT_OPEN;
- id = res;
-
- return OK;
-}
-
-void FileAccessJAndroid::close() {
- if (!is_open())
- return;
-
- JNIEnv *env = ThreadAndroid::get_env();
-
- env->CallVoidMethod(io, _file_close, id);
- id = 0;
-}
-
-bool FileAccessJAndroid::is_open() const {
- return id != 0;
-}
-
-void FileAccessJAndroid::seek(size_t p_position) {
- JNIEnv *env = ThreadAndroid::get_env();
-
- ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
- env->CallVoidMethod(io, _file_seek, id, p_position);
-}
-
-void FileAccessJAndroid::seek_end(int64_t p_position) {
- ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use.");
-
- seek(get_len());
-}
-
-size_t FileAccessJAndroid::get_position() const {
- JNIEnv *env = ThreadAndroid::get_env();
- ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
- return env->CallIntMethod(io, _file_tell, id);
-}
-
-size_t FileAccessJAndroid::get_len() const {
- JNIEnv *env = ThreadAndroid::get_env();
- ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
- return env->CallIntMethod(io, _file_get_size, id);
-}
-
-bool FileAccessJAndroid::eof_reached() const {
- JNIEnv *env = ThreadAndroid::get_env();
- ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
- return env->CallIntMethod(io, _file_eof, id);
-}
-
-uint8_t FileAccessJAndroid::get_8() const {
- ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
- uint8_t byte;
- get_buffer(&byte, 1);
- return byte;
-}
-
-int FileAccessJAndroid::get_buffer(uint8_t *p_dst, int p_length) const {
- ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use.");
- if (p_length == 0)
- return 0;
- JNIEnv *env = ThreadAndroid::get_env();
-
- jbyteArray jca = (jbyteArray)env->CallObjectMethod(io, _file_read, id, p_length);
-
- int len = env->GetArrayLength(jca);
- env->GetByteArrayRegion(jca, 0, len, (jbyte *)p_dst);
- env->DeleteLocalRef((jobject)jca);
-
- return len;
-}
-
-Error FileAccessJAndroid::get_error() const {
- if (eof_reached())
- return ERR_FILE_EOF;
- return OK;
-}
-
-void FileAccessJAndroid::flush() {
-}
-
-void FileAccessJAndroid::store_8(uint8_t p_dest) {
-}
-
-bool FileAccessJAndroid::file_exists(const String &p_path) {
- JNIEnv *env = ThreadAndroid::get_env();
-
- String path = fix_path(p_path).simplify_path();
- if (path.begins_with("/"))
- path = path.substr(1, path.length());
- else if (path.begins_with("res://"))
- path = path.substr(6, path.length());
-
- jstring js = env->NewStringUTF(path.utf8().get_data());
- int res = env->CallIntMethod(io, _file_open, js, false);
- if (res <= 0) {
- env->DeleteLocalRef(js);
- return false;
- }
- env->CallVoidMethod(io, _file_close, res);
- env->DeleteLocalRef(js);
- return true;
-}
-
-void FileAccessJAndroid::setup(jobject p_io) {
- io = p_io;
- JNIEnv *env = ThreadAndroid::get_env();
-
- jclass c = env->GetObjectClass(io);
- cls = (jclass)env->NewGlobalRef(c);
-
- _file_open = env->GetMethodID(cls, "file_open", "(Ljava/lang/String;Z)I");
- _file_get_size = env->GetMethodID(cls, "file_get_size", "(I)I");
- _file_tell = env->GetMethodID(cls, "file_tell", "(I)I");
- _file_eof = env->GetMethodID(cls, "file_eof", "(I)Z");
- _file_seek = env->GetMethodID(cls, "file_seek", "(II)V");
- _file_read = env->GetMethodID(cls, "file_read", "(II)[B");
- _file_close = env->GetMethodID(cls, "file_close", "(I)V");
-}
-
-FileAccessJAndroid::FileAccessJAndroid() {
- id = 0;
-}
-
-FileAccessJAndroid::~FileAccessJAndroid() {
- if (is_open())
- close();
-}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
index 3bbe35091c..ad1dc53bc0 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -988,4 +988,9 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
public void initInputDevices() {
mRenderView.initInputDevices();
}
+
+ @Keep
+ private GodotRenderView getRenderView() { // used by native side to get renderView
+ return mRenderView;
+ }
}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
index d731e080c4..2cd67933ee 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java
@@ -144,6 +144,11 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView
return inputHandler.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
}
+ @Override
+ public boolean onCapturedPointerEvent(MotionEvent event) {
+ return inputHandler.onGenericMotionEvent(event);
+ }
+
private void init(XRMode xrMode, boolean translucent, int depth, int stencil) {
setPreserveEGLContextOnPause(true);
setFocusableInTouchMode(true);
diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
index 6cd5ca7b4e..d5e0345a9c 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java
@@ -120,6 +120,11 @@ public class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderV
}
@Override
+ public boolean onCapturedPointerEvent(MotionEvent event) {
+ return mInputHandler.onGenericMotionEvent(event);
+ }
+
+ @Override
public void onResume() {
super.onResume();
diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
index 6d5be312f1..b052cd9d92 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java
@@ -245,7 +245,7 @@ public class GodotInputHandler implements InputDeviceListener {
}
});
return true;
- } else if ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) {
+ } else if (event.isFromSource(InputDevice.SOURCE_MOUSE) || event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return handleMouseEvent(event);
}
@@ -462,6 +462,11 @@ public class GodotInputHandler implements InputDeviceListener {
}
});
}
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_UP: {
+ // we can safely ignore these cases because they are always come beside ACTION_BUTTON_PRESS and ACTION_BUTTON_RELEASE
+ return true;
+ }
}
return false;
}
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 5dc773fae2..48b8171222 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -43,7 +43,6 @@
#include "dir_access_jandroid.h"
#include "display_server_android.h"
#include "file_access_android.h"
-#include "file_access_jandroid.h"
#include "jni_utils.h"
#include "main/main.h"
#include "net_socket_android.h"
@@ -89,14 +88,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
godot_io_java = new GodotIOJavaWrapper(env, godot_java->get_member_object("io", "Lorg/godotengine/godot/GodotIO;", env));
ThreadAndroid::make_default(jvm);
-#ifdef USE_JAVA_FILE_ACCESS
- FileAccessJAndroid::setup(godot_io_java->get_instance());
-#else
jobject amgr = env->NewGlobalRef(p_asset_manager);
FileAccessAndroid::asset_manager = AAssetManager_fromJava(env, amgr);
-#endif
DirAccessJAndroid::setup(godot_io_java->get_instance());
AudioDriverAndroid::setup(godot_io_java->get_instance());
@@ -251,9 +246,8 @@ void touch_preprocessing(JNIEnv *env, jclass clazz, jint input_device, jint ev,
tp.id = (int)p[0];
points.push_back(tp);
}
-
- if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE) {
- DisplayServerAndroid::get_singleton()->process_mouse_event(ev, buttons_mask, points[0].pos, vertical_factor, horizontal_factor);
+ if ((input_device & AINPUT_SOURCE_MOUSE) == AINPUT_SOURCE_MOUSE || (input_device & AINPUT_SOURCE_MOUSE_RELATIVE) == AINPUT_SOURCE_MOUSE_RELATIVE) {
+ DisplayServerAndroid::get_singleton()->process_mouse_event(input_device, ev, buttons_mask, points[0].pos, vertical_factor, horizontal_factor);
} else {
DisplayServerAndroid::get_singleton()->process_touch(ev, pointer, points);
}
diff --git a/platform/android/java_godot_view_wrapper.cpp b/platform/android/java_godot_view_wrapper.cpp
new file mode 100644
index 0000000000..6655dd9895
--- /dev/null
+++ b/platform/android/java_godot_view_wrapper.cpp
@@ -0,0 +1,66 @@
+/*************************************************************************/
+/* java_godot_view_wrapper.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 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 "java_godot_view_wrapper.h"
+
+#include "thread_jandroid.h"
+
+GodotJavaViewWrapper::GodotJavaViewWrapper(jobject godot_view) {
+ JNIEnv *env = ThreadAndroid::get_env();
+
+ _godot_view = env->NewGlobalRef(godot_view);
+
+ _cls = (jclass)env->NewGlobalRef(env->GetObjectClass(godot_view));
+
+ if (android_get_device_api_level() >= __ANDROID_API_O__) {
+ _request_pointer_capture = env->GetMethodID(_cls, "requestPointerCapture", "()V");
+ _release_pointer_capture = env->GetMethodID(_cls, "releasePointerCapture", "()V");
+ }
+}
+
+void GodotJavaViewWrapper::request_pointer_capture() {
+ if (_request_pointer_capture != 0) {
+ JNIEnv *env = ThreadAndroid::get_env();
+ env->CallVoidMethod(_godot_view, _request_pointer_capture);
+ }
+}
+
+void GodotJavaViewWrapper::release_pointer_capture() {
+ if (_request_pointer_capture != 0) {
+ JNIEnv *env = ThreadAndroid::get_env();
+ env->CallVoidMethod(_godot_view, _release_pointer_capture);
+ }
+}
+
+GodotJavaViewWrapper::~GodotJavaViewWrapper() {
+ JNIEnv *env = ThreadAndroid::get_env();
+ env->DeleteGlobalRef(_godot_view);
+ env->DeleteGlobalRef(_cls);
+}
diff --git a/platform/android/file_access_jandroid.h b/platform/android/java_godot_view_wrapper.h
index e252a4d3ac..4c8f6edad0 100644
--- a/platform/android/file_access_jandroid.h
+++ b/platform/android/java_godot_view_wrapper.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* file_access_jandroid.h */
+/* java_godot_view_wrapper.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,56 +28,29 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef FILE_ACCESS_JANDROID_H
-#define FILE_ACCESS_JANDROID_H
+#ifndef GODOT_JAVA_GODOT_VIEW_WRAPPER_H
+#define GODOT_JAVA_GODOT_VIEW_WRAPPER_H
-#include "core/os/file_access.h"
-#include "java_godot_lib_jni.h"
-class FileAccessJAndroid : public FileAccess {
- static jobject io;
- static jclass cls;
+#include <android/log.h>
+#include <jni.h>
- static jmethodID _file_open;
- static jmethodID _file_get_size;
- static jmethodID _file_seek;
- static jmethodID _file_tell;
- static jmethodID _file_eof;
- static jmethodID _file_read;
- static jmethodID _file_close;
+// Class that makes functions in java/src/org/godotengine/godot/GodotView.java callable from C++
+class GodotJavaViewWrapper {
+private:
+ jclass _cls;
- int id;
- static FileAccess *create_jandroid();
+ jobject _godot_view;
-public:
- virtual Error _open(const String &p_path, int p_mode_flags); ///< open a file
- virtual void close(); ///< close a file
- virtual bool is_open() const; ///< true when file is open
-
- virtual void seek(size_t p_position); ///< seek to a given position
- virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file
- virtual size_t get_position() const; ///< get position in the file
- virtual size_t get_len() const; ///< get size of the file
-
- virtual bool eof_reached() const; ///< reading passed EOF
-
- virtual uint8_t get_8() const; ///< get a byte
- virtual int get_buffer(uint8_t *p_dst, int p_length) const;
+ jmethodID _request_pointer_capture = 0;
+ jmethodID _release_pointer_capture = 0;
- virtual Error get_error() const; ///< get last error
-
- virtual void flush();
- virtual void store_8(uint8_t p_dest); ///< store a byte
-
- virtual bool file_exists(const String &p_path); ///< return true if a file exists
-
- static void setup(jobject p_io);
+public:
+ GodotJavaViewWrapper(jobject godot_view);
- virtual uint64_t _get_modified_time(const String &p_file) { return 0; }
- virtual uint32_t _get_unix_permissions(const String &p_file) { return 0; }
- virtual Error _set_unix_permissions(const String &p_file, uint32_t p_permissions) { return FAILED; }
+ void request_pointer_capture();
+ void release_pointer_capture();
- FileAccessJAndroid();
- ~FileAccessJAndroid();
+ ~GodotJavaViewWrapper();
};
-#endif // FILE_ACCESS_JANDROID_H
+#endif //GODOT_JAVA_GODOT_VIEW_WRAPPER_H
diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp
index cff591d903..7919e47b5c 100644
--- a/platform/android/java_godot_wrapper.cpp
+++ b/platform/android/java_godot_wrapper.cpp
@@ -109,6 +109,16 @@ jobject GodotJavaWrapper::get_class_loader() {
}
}
+GodotJavaViewWrapper *GodotJavaWrapper::get_godot_view() {
+ if (_godot_view != nullptr) {
+ return _godot_view;
+ }
+ JNIEnv *env = ThreadAndroid::get_env();
+ jmethodID godot_view_getter = env->GetMethodID(godot_class, "getRenderView", "()Lorg/godotengine/godot/GodotRenderView;");
+ _godot_view = new GodotJavaViewWrapper(env->CallObjectMethod(godot_instance, godot_view_getter));
+ return _godot_view;
+}
+
void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
if (_on_video_init)
if (p_env == nullptr)
diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h
index e0c3809a64..c212e107cb 100644
--- a/platform/android/java_godot_wrapper.h
+++ b/platform/android/java_godot_wrapper.h
@@ -37,6 +37,7 @@
#include <android/log.h>
#include <jni.h>
+#include "java_godot_view_wrapper.h"
#include "string_android.h"
// Class that makes functions in java/src/org/godotengine/godot/Godot.java callable from C++
@@ -47,6 +48,8 @@ private:
jclass godot_class;
jclass activity_class;
+ GodotJavaViewWrapper *_godot_view = nullptr;
+
jmethodID _on_video_init = 0;
jmethodID _restart = 0;
jmethodID _finish = 0;
@@ -74,6 +77,7 @@ public:
jobject get_member_object(const char *p_name, const char *p_class, JNIEnv *p_env = nullptr);
jobject get_class_loader();
+ GodotJavaViewWrapper *get_godot_view();
void on_video_init(JNIEnv *p_env = nullptr);
void on_godot_main_loop_started(JNIEnv *p_env = nullptr);
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 00733f6dbb..b90fb3ce6e 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -31,15 +31,13 @@
#include "os_android.h"
#include "core/config/project_settings.h"
-#include "core/io/file_access_buffered_fa.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
-#include "file_access_android.h"
#include "main/main.h"
#include "platform/android/display_server_android.h"
#include "dir_access_jandroid.h"
-#include "file_access_jandroid.h"
+#include "file_access_android.h"
#include "net_socket_android.h"
#include <dlfcn.h>
@@ -62,16 +60,10 @@ void OS_Android::initialize_core() {
if (use_apk_expansion)
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
else {
-#ifdef USE_JAVA_FILE_ACCESS
- FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid>>(FileAccess::ACCESS_RESOURCES);
-#else
- //FileAccess::make_default<FileAccessBufferedFA<FileAccessAndroid> >(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessAndroid>(FileAccess::ACCESS_RESOURCES);
-#endif
}
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
- //FileAccessBufferedFA<FileAccessUnix>::make_default();
if (use_apk_expansion)
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
else
@@ -314,6 +306,7 @@ OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_god
#if defined(OPENGL_ENABLED)
gl_extensions = nullptr;
use_gl2 = false;
+ use_16bits_fbo = false;
#endif
#if defined(VULKAN_ENABLED)
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index fff82c9467..3406c75c35 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -94,8 +94,8 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
struct IOSExportAsset {
String exported_path;
- bool is_framework; // framework is anything linked to the binary, otherwise it's a resource
- bool should_embed;
+ bool is_framework = false; // framework is anything linked to the binary, otherwise it's a resource
+ bool should_embed = false;
};
String _get_additional_plist_content();
@@ -314,9 +314,9 @@ Vector<EditorExportPlatformIOS::ExportArchitecture> EditorExportPlatformIOS::_ge
struct LoadingScreenInfo {
const char *preset_key;
const char *export_name;
- int width;
- int height;
- bool rotate;
+ int width = 0;
+ int height = 0;
+ bool rotate = false;
};
static const LoadingScreenInfo loading_screen_infos[] = {
@@ -667,7 +667,7 @@ struct IconInfo {
const char *actual_size_side;
const char *scale;
const char *unscaled_size;
- bool is_required;
+ bool is_required = false;
};
static const IconInfo icon_infos[] = {
@@ -962,7 +962,7 @@ Error EditorExportPlatformIOS::_walk_dir_recursive(DirAccess *p_da, FileHandler
struct CodesignData {
const Ref<EditorExportPreset> &preset;
- bool debug;
+ bool debug = false;
CodesignData(const Ref<EditorExportPreset> &p_preset, bool p_debug) :
preset(p_preset),
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index 59f3dce3ad..7a8005fe30 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -99,6 +99,12 @@ elif env["threads_enabled"]:
in_files.append(build[2]) # Worker
out_files.append(zip_dir.File(binary_name + ".worker.js"))
+if env["tools"]:
+ in_files.append("#misc/dist/html/logo.svg")
+ out_files.append(zip_dir.File("logo.svg"))
+ in_files.append("#icon.png")
+ out_files.append(zip_dir.File("favicon.png"))
+
zip_files = env.InstallAs(out_files, in_files)
env.Zip(
"#bin/godot",
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index dd982bc3a8..78fbed6d0f 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -189,7 +189,9 @@ Error AudioDriverJavaScript::capture_start() {
lock();
input_buffer_init(buffer_length);
unlock();
- godot_audio_capture_start();
+ if (godot_audio_capture_start()) {
+ return FAILED;
+ }
return OK;
}
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index f4fa5fb218..d53c774e77 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -1,6 +1,8 @@
import os
+import sys
from emscripten_helpers import run_closure_compiler, create_engine_file, add_js_libraries
+from methods import get_compiler_version
from SCons.Util import WhereIs
@@ -20,6 +22,13 @@ def get_opts():
from SCons.Variables import BoolVariable
return [
+ ("initial_memory", "Initial WASM memory (in MiB)", 16),
+ BoolVariable("use_assertions", "Use Emscripten runtime assertions", False),
+ BoolVariable("use_thinlto", "Use ThinLTO", False),
+ BoolVariable("use_ubsan", "Use Emscripten undefined behavior sanitizer (UBSAN)", False),
+ BoolVariable("use_asan", "Use Emscripten address sanitizer (ASAN)", False),
+ BoolVariable("use_lsan", "Use Emscripten leak sanitizer (LSAN)", False),
+ BoolVariable("use_safe_heap", "Use Emscripten SAFE_HEAP sanitizer", False),
# eval() can be a security concern, so it can be disabled.
BoolVariable("javascript_eval", "Enable JavaScript eval interface", True),
BoolVariable("threads_enabled", "Enable WebAssembly Threads support (limited browser support)", False),
@@ -41,6 +50,9 @@ def get_flags():
def configure(env):
+ if not isinstance(env["initial_memory"], int):
+ print("Initial memory must be a valid integer")
+ sys.exit(255)
## Build type
@@ -63,15 +75,18 @@ def configure(env):
env.Append(CPPDEFINES=["DEBUG_ENABLED"])
env.Append(CCFLAGS=["-O1", "-g"])
env.Append(LINKFLAGS=["-O1", "-g"])
+ env["use_assertions"] = True
+
+ if env["use_assertions"]:
env.Append(LINKFLAGS=["-s", "ASSERTIONS=1"])
if env["tools"]:
if not env["threads_enabled"]:
- raise RuntimeError(
- "Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option"
- )
- # Tools need more memory. Initial stack memory in bytes. See `src/settings.js` in emscripten repository (will be renamed to INITIAL_MEMORY).
- env.Append(LINKFLAGS=["-s", "TOTAL_MEMORY=33554432"])
+ print("Threads must be enabled to build the editor. Please add the 'threads_enabled=yes' option")
+ sys.exit(255)
+ if env["initial_memory"] < 32:
+ print("Editor build requires at least 32MiB of initial memory. Forcing it.")
+ env["initial_memory"] = 32
elif env["builtin_icu"]:
env.Append(CCFLAGS=["-frtti"])
else:
@@ -81,14 +96,33 @@ def configure(env):
# Don't use dynamic_cast, necessary with no-rtti.
env.Append(CPPDEFINES=["NO_SAFE_CAST"])
+ env.Append(LINKFLAGS=["-s", "INITIAL_MEMORY=%sMB" % env["initial_memory"]])
+
## Copy env variables.
env["ENV"] = os.environ
# LTO
- if env["use_lto"]:
+ if env["use_thinlto"]:
+ env.Append(CCFLAGS=["-flto=thin"])
+ env.Append(LINKFLAGS=["-flto=thin"])
+ elif env["use_lto"]:
env.Append(CCFLAGS=["-flto=full"])
env.Append(LINKFLAGS=["-flto=full"])
+ # Sanitizers
+ if env["use_ubsan"]:
+ env.Append(CCFLAGS=["-fsanitize=undefined"])
+ env.Append(LINKFLAGS=["-fsanitize=undefined"])
+ if env["use_asan"]:
+ env.Append(CCFLAGS=["-fsanitize=address"])
+ env.Append(LINKFLAGS=["-fsanitize=address"])
+ if env["use_lsan"]:
+ env.Append(CCFLAGS=["-fsanitize=leak"])
+ env.Append(LINKFLAGS=["-fsanitize=leak"])
+ if env["use_safe_heap"]:
+ env.Append(CCFLAGS=["-s", "SAFE_HEAP=1"])
+ env.Append(LINKFLAGS=["-s", "SAFE_HEAP=1"])
+
# Closure compiler
if env["use_closure_compiler"]:
# For emscripten support code.
@@ -135,7 +169,8 @@ def configure(env):
env.Append(CPPDEFINES=["JAVASCRIPT_EVAL_ENABLED"])
if env["threads_enabled"] and env["gdnative_enabled"]:
- raise Exception("Threads and GDNative support can't be both enabled due to WebAssembly limitations")
+ print("Threads and GDNative support can't be both enabled due to WebAssembly limitations")
+ sys.exit(255)
# Thread support (via SharedArrayBuffer).
if env["threads_enabled"]:
@@ -149,6 +184,10 @@ def configure(env):
env.Append(CPPDEFINES=["NO_THREADS"])
if env["gdnative_enabled"]:
+ major, minor, patch = get_compiler_version(env)
+ if major < 2 or (major == 2 and minor == 0 and patch < 10):
+ print("GDNative support requires emscripten >= 2.0.10, detected: %s.%s.%s" % (major, minor, patch))
+ sys.exit(255)
env.Append(CCFLAGS=["-s", "RELOCATABLE=1"])
env.Append(LINKFLAGS=["-s", "RELOCATABLE=1"])
env.extra_suffix = ".gdnative" + env.extra_suffix
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index f77bf6ab97..37681b2484 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -37,16 +37,13 @@
#include "platform/javascript/logo.gen.h"
#include "platform/javascript/run_icon.gen.h"
-#define EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE "webassembly_release.zip"
-#define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip"
-
class EditorHTTPServer : public Reference {
private:
Ref<TCP_Server> server;
Ref<StreamPeerTCP> connection;
- uint64_t time;
+ uint64_t time = 0;
uint8_t req_buf[4096];
- int req_pos;
+ int req_pos = 0;
void _clear_client() {
connection = Ref<StreamPeerTCP>();
@@ -211,7 +208,12 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
Ref<ImageTexture> logo;
Ref<ImageTexture> run_icon;
Ref<ImageTexture> stop_icon;
- int menu_options;
+ int menu_options = 0;
+
+ Ref<EditorHTTPServer> server;
+ bool server_quit = false;
+ Mutex server_lock;
+ Thread *server_thread = nullptr;
enum ExportMode {
EXPORT_MODE_NORMAL = 0,
@@ -241,12 +243,6 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, int p_flags, const Vector<SharedObject> p_shared_objects);
-private:
- Ref<EditorHTTPServer> server;
- bool server_quit;
- Mutex server_lock;
- Thread *server_thread;
-
static void _server_thread_poll(void *data);
public:
@@ -685,7 +681,6 @@ void EditorExportPlatformJavaScript::_server_thread_poll(void *data) {
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
server.instance();
- server_quit = false;
server_thread = Thread::create(_server_thread_poll, this);
Ref<Image> img = memnew(Image(_javascript_logo));
@@ -702,8 +697,6 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
} else {
stop_icon.instance();
}
-
- menu_options = 0;
}
EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
diff --git a/platform/javascript/godot_audio.h b/platform/javascript/godot_audio.h
index 0ba6849715..aeb234269e 100644
--- a/platform/javascript/godot_audio.h
+++ b/platform/javascript/godot_audio.h
@@ -41,7 +41,7 @@ extern int godot_audio_is_available();
extern int godot_audio_init(int p_mix_rate, int p_latency, void (*_state_cb)(int), void (*_latency_cb)(float));
extern void godot_audio_resume();
-extern void godot_audio_capture_start();
+extern int godot_audio_capture_start();
extern void godot_audio_capture_stop();
// Worklet
diff --git a/platform/javascript/js/libs/library_godot_audio.js b/platform/javascript/js/libs/library_godot_audio.js
index 416e987513..d01b8d887b 100644
--- a/platform/javascript/js/libs/library_godot_audio.js
+++ b/platform/javascript/js/libs/library_godot_audio.js
@@ -77,28 +77,37 @@ const GodotAudio = {
create_input: function (callback) {
if (GodotAudio.input) {
- return; // Already started.
+ return 0; // Already started.
}
function gotMediaInput(stream) {
- GodotAudio.input = GodotAudio.ctx.createMediaStreamSource(stream);
- callback(GodotAudio.input);
+ try {
+ GodotAudio.input = GodotAudio.ctx.createMediaStreamSource(stream);
+ callback(GodotAudio.input);
+ } catch (e) {
+ GodotRuntime.error('Failed creaating input.', e);
+ }
}
- if (navigator.mediaDevices.getUserMedia) {
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({
'audio': true,
}).then(gotMediaInput, function (e) {
- GodotRuntime.print(e);
+ GodotRuntime.error('Error getting user media.', e);
});
} else {
if (!navigator.getUserMedia) {
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
}
+ if (!navigator.getUserMedia) {
+ GodotRuntime.error('getUserMedia not available.');
+ return 1;
+ }
navigator.getUserMedia({
'audio': true,
}, gotMediaInput, function (e) {
GodotRuntime.print(e);
});
}
+ return 0;
},
close_async: function (resolve, reject) {
@@ -161,12 +170,9 @@ const GodotAudio = {
},
godot_audio_capture_start__proxy: 'sync',
- godot_audio_capture_start__sig: 'v',
+ godot_audio_capture_start__sig: 'i',
godot_audio_capture_start: function () {
- if (GodotAudio.input) {
- return; // Already started.
- }
- GodotAudio.create_input(function (input) {
+ return GodotAudio.create_input(function (input) {
input.connect(GodotAudio.driver.get_node());
});
},
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index ebfcd7293e..8c976da58e 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -31,7 +31,6 @@
#include "os_javascript.h"
#include "core/debugger/engine_debugger.h"
-#include "core/io/file_access_buffered_fa.h"
#include "core/io/json.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
@@ -52,7 +51,6 @@
// Lifecycle
void OS_JavaScript::initialize() {
OS_Unix::initialize_core();
- FileAccess::make_default<FileAccessBufferedFA<FileAccessUnix>>(FileAccess::ACCESS_RESOURCES);
DisplayServerJavaScript::register_javascript_driver();
#ifdef MODULE_WEBSOCKET_ENABLED
diff --git a/platform/linuxbsd/detect_prime_x11.cpp b/platform/linuxbsd/detect_prime_x11.cpp
index e5a9bb4737..709523e836 100644
--- a/platform/linuxbsd/detect_prime_x11.cpp
+++ b/platform/linuxbsd/detect_prime_x11.cpp
@@ -56,7 +56,7 @@ typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLX
struct vendor {
const char *glxvendor;
- int priority;
+ int priority = 0;
};
vendor vendormap[] = {
diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h
index 3c6f462e92..0507ef3fff 100644
--- a/platform/linuxbsd/display_server_x11.h
+++ b/platform/linuxbsd/display_server_x11.h
@@ -63,25 +63,25 @@
// Hints for X11 fullscreen
typedef struct {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
- long inputMode;
- unsigned long status;
+ unsigned long flags = 0;
+ unsigned long functions = 0;
+ unsigned long decorations = 0;
+ long inputMode = 0;
+ unsigned long status = 0;
} Hints;
typedef struct _xrr_monitor_info {
Atom name;
- Bool primary;
- Bool automatic;
- int noutput;
- int x;
- int y;
- int width;
- int height;
- int mwidth;
- int mheight;
- RROutput *outputs;
+ Bool primary = false;
+ Bool automatic = false;
+ int noutput = 0;
+ int x = 0;
+ int y = 0;
+ int width = 0;
+ int height = 0;
+ int mwidth = 0;
+ int mheight = 0;
+ RROutput *outputs = nullptr;
} xrr_monitor_info;
#undef CursorShape
diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp
index 4a9d0a8181..0676587f7a 100644
--- a/platform/linuxbsd/joypad_linux.cpp
+++ b/platform/linuxbsd/joypad_linux.cpp
@@ -49,15 +49,6 @@
static const char *ignore_str = "/dev/input/js";
#endif
-JoypadLinux::Joypad::Joypad() {
- fd = -1;
- dpad = 0;
- devpath = "";
- for (int i = 0; i < MAX_ABS; i++) {
- abs_info[i] = nullptr;
- }
-}
-
JoypadLinux::Joypad::~Joypad() {
for (int i = 0; i < MAX_ABS; i++) {
if (abs_info[i]) {
diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h
index 0d175193a5..71eab78f99 100644
--- a/platform/linuxbsd/joypad_linux.h
+++ b/platform/linuxbsd/joypad_linux.h
@@ -56,17 +56,16 @@ private:
Input::JoyAxis curr_axis[MAX_ABS];
int key_map[MAX_KEY];
int abs_map[MAX_ABS];
- int dpad;
- int fd;
+ int dpad = 0;
+ int fd = -1;
String devpath;
- input_absinfo *abs_info[MAX_ABS];
+ input_absinfo *abs_info[MAX_ABS] = {};
- bool force_feedback;
- int ff_effect_id;
- uint64_t ff_effect_timestamp;
+ bool force_feedback = false;
+ int ff_effect_id = 0;
+ uint64_t ff_effect_timestamp = 0;
- Joypad();
~Joypad();
void reset();
};
diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h
index 073d35008b..ea55a3ff28 100644
--- a/platform/osx/display_server_osx.h
+++ b/platform/osx/display_server_osx.h
@@ -77,13 +77,13 @@ public:
struct KeyEvent {
WindowID window_id;
- unsigned int osx_state;
- bool pressed;
- bool echo;
- bool raw;
- uint32_t keycode;
- uint32_t physical_keycode;
- uint32_t unicode;
+ unsigned int osx_state = false;
+ bool pressed = false;
+ bool echo = false;
+ bool raw = false;
+ uint32_t keycode = 0;
+ uint32_t physical_keycode = 0;
+ uint32_t unicode = 0;
};
struct WarpEvent {
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index f5aad91946..eecd2ed641 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -48,7 +48,7 @@
class EditorExportPlatformOSX : public EditorExportPlatform {
GDCLASS(EditorExportPlatformOSX, EditorExportPlatform);
- int version_code;
+ int version_code = 0;
Ref<ImageTexture> logo;
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index cfc371710b..b2871b261e 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -37,14 +37,6 @@
static JoypadOSX *self = nullptr;
joypad::joypad() {
- device_ref = nullptr;
- ff_device = nullptr;
- ff_axes = nullptr;
- ff_directions = nullptr;
- ffservice = 0;
- ff_timestamp = 0;
- id = 0;
-
ff_constant_force.lMagnitude = 10000;
ff_effect.dwDuration = 0;
ff_effect.dwSamplePeriod = 0;
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index dc238e68e4..6c2a1ea70b 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -46,10 +46,10 @@ struct rec_element {
IOHIDElementRef ref;
IOHIDElementCookie cookie;
- uint32_t usage;
+ uint32_t usage = 0;
- int min;
- int max;
+ int min = 0;
+ int max = 0;
struct Comparator {
bool operator()(const rec_element p_a, const rec_element p_b) const { return p_a.usage < p_b.usage; }
@@ -57,22 +57,22 @@ struct rec_element {
};
struct joypad {
- IOHIDDeviceRef device_ref;
+ IOHIDDeviceRef device_ref = nullptr;
Vector<rec_element> axis_elements;
Vector<rec_element> button_elements;
Vector<rec_element> hat_elements;
- int id;
+ int id = 0;
- io_service_t ffservice; /* Interface for force feedback, 0 = no ff */
+ io_service_t ffservice = 0; /* Interface for force feedback, 0 = no ff */
FFCONSTANTFORCE ff_constant_force;
FFDeviceObjectReference ff_device;
FFEffectObjectReference ff_object;
- uint64_t ff_timestamp;
- LONG *ff_directions;
+ uint64_t ff_timestamp = 0;
+ LONG *ff_directions = nullptr;
FFEFFECT ff_effect;
- DWORD *ff_axes;
+ DWORD *ff_axes = nullptr;
void add_hid_elements(CFArrayRef p_array);
void add_hid_element(IOHIDElementRef p_element);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 399a29cbe0..ed03e953a5 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -286,7 +286,7 @@ Error OS_OSX::shell_open(String p_uri) {
String OS_OSX::get_locale() const {
NSString *locale_code = [[NSLocale preferredLanguages] objectAtIndex:0];
- return [locale_code UTF8String];
+ return String([locale_code UTF8String]).replace("-", "_");
}
String OS_OSX::get_executable_path() const {
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index 22af8ba985..f8b420b1c8 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -49,14 +49,6 @@ const char *OS_Server::get_video_driver_name(int p_driver) const {
return "Dummy";
}
-int OS_Server::get_audio_driver_count() const {
- return 1;
-}
-
-const char *OS_Server::get_audio_driver_name(int p_driver) const {
- return "Dummy";
-}
-
int OS_Server::get_current_video_driver() const {
return video_driver_index;
}
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index a4ae6a0bf6..95b6b5143b 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -47,22 +47,22 @@
#undef CursorShape
class OS_Server : public OS_Unix {
- RenderingServer *rendering_server;
+ RenderingServer *rendering_server = nullptr;
VideoMode current_videomode;
List<String> args;
- MainLoop *main_loop;
+ MainLoop *main_loop = nullptr;
- bool grab;
+ bool grab = false;
virtual void delete_main_loop();
- bool force_quit;
+ bool force_quit = false;
- InputDefault *input;
+ InputDefault *input = nullptr;
CrashHandler crash_handler;
- int video_driver_index;
+ int video_driver_index = 0;
Ref<ResourceFormatDummyTexture> resource_loader_dummy;
@@ -70,8 +70,6 @@ protected:
virtual int get_video_driver_count() const;
virtual const char *get_video_driver_name(int p_driver) const;
virtual int get_current_video_driver() const;
- virtual int get_audio_driver_count() const;
- virtual const char *get_audio_driver_name(int p_driver) const;
virtual void initialize_core();
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
diff --git a/platform/uwp/context_egl_uwp.cpp b/platform/uwp/context_egl_uwp.cpp
index 2da6c5897a..a6607ed42c 100644
--- a/platform/uwp/context_egl_uwp.cpp
+++ b/platform/uwp/context_egl_uwp.cpp
@@ -204,7 +204,8 @@ ContextEGL_UWP::ContextEGL_UWP(CoreWindow ^ p_window, Driver p_driver) :
mEglContext(EGL_NO_CONTEXT),
mEglSurface(EGL_NO_SURFACE),
driver(p_driver),
- window(p_window) {}
+ window(p_window),
+ vsync(false) {}
ContextEGL_UWP::~ContextEGL_UWP() {
cleanup();
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index 30568241a9..00b57c48f3 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -108,7 +108,7 @@ class AppxPackager {
struct BlockHash {
String base64_hash;
- size_t compressed_size;
+ size_t compressed_size = 0;
};
struct FileMeta {
@@ -120,12 +120,10 @@ class AppxPackager {
Vector<BlockHash> hashes;
uLong file_crc32 = 0;
ZPOS64_T zip_offset = 0;
-
- FileMeta() {}
};
String progress_task;
- FileAccess *package;
+ FileAccess *package = nullptr;
Set<String> mime_types;
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index 13f246a438..2df87d6fd5 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -58,21 +58,12 @@ private:
struct ControllerDevice {
Windows::Gaming::Input::IGameController ^ controller_reference;
- int id;
- bool connected;
- ControllerType type;
- float ff_timestamp;
- float ff_end_timestamp;
- bool vibrating;
-
- ControllerDevice() {
- id = -1;
- connected = false;
- type = ControllerType::GAMEPAD_CONTROLLER;
- ff_timestamp = 0.0f;
- ff_end_timestamp = 0.0f;
- vibrating = false;
- }
+ int id = -1;
+ bool connected = false;
+ ControllerType type = ControllerType::GAMEPAD_CONTROLLER;
+ float ff_timestamp = 0;
+ float ff_end_timestamp = 0;
+ bool vibrating = false;
};
ControllerDevice controllers[MAX_CONTROLLERS];
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index c2d1acf8a0..fd25cefe2b 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -55,13 +55,13 @@ public:
CHAR_EVENT_MESSAGE
};
- bool alt, shift, control;
- MessageType type;
- bool pressed;
- unsigned int keycode;
- unsigned int physical_keycode;
- unsigned int unicode;
- bool echo;
+ bool alt = false, shift = false, control = false;
+ MessageType type = KEY_EVENT_MESSAGE;
+ bool pressed = false;
+ unsigned int keycode = 0;
+ unsigned int physical_keycode = 0;
+ unsigned int unicode = 0;
+ bool echo = false;
CorePhysicalKeyStatus status;
};
diff --git a/platform/windows/context_gl_windows.cpp b/platform/windows/context_gl_windows.cpp
index 1c32639a38..54251fc66c 100644
--- a/platform/windows/context_gl_windows.cpp
+++ b/platform/windows/context_gl_windows.cpp
@@ -211,6 +211,7 @@ ContextGL_Windows::ContextGL_Windows(HWND hwnd, bool p_opengl_3_context) {
hWnd = hwnd;
use_vsync = false;
vsync_via_compositor = false;
+ pixel_format = 0;
}
ContextGL_Windows::~ContextGL_Windows() {
diff --git a/platform/windows/crash_handler_windows.cpp b/platform/windows/crash_handler_windows.cpp
index 7abf451062..0f2f49c5ce 100644
--- a/platform/windows/crash_handler_windows.cpp
+++ b/platform/windows/crash_handler_windows.cpp
@@ -57,7 +57,7 @@
struct module_data {
std::string image_name;
std::string module_name;
- void *base_address;
+ void *base_address = nullptr;
DWORD load_size;
};
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index ee13e3c774..859051ede9 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -95,7 +95,7 @@ def build_res_file(target, source, env):
out = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE).communicate()
if len(out[1]):
return 1
- except:
+ except Exception:
return 1
return 0
diff --git a/platform/windows/joypad_windows.h b/platform/windows/joypad_windows.h
index 223b44fcd6..08adc6b663 100644
--- a/platform/windows/joypad_windows.h
+++ b/platform/windows/joypad_windows.h
@@ -92,21 +92,13 @@ private:
};
struct xinput_gamepad {
- int id;
- bool attached;
- bool vibrating;
- DWORD last_packet;
+ int id = 0;
+ bool attached = false;
+ bool vibrating = false;
+ DWORD last_packet = 0;
XINPUT_STATE state;
- uint64_t ff_timestamp;
- uint64_t ff_end_timestamp;
-
- xinput_gamepad() {
- attached = false;
- vibrating = false;
- ff_timestamp = 0;
- ff_end_timestamp = 0;
- last_packet = 0;
- }
+ uint64_t ff_timestamp = 0;
+ uint64_t ff_end_timestamp = 0;
};
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex, XINPUT_STATE *pState);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index ae6b54513d..451f3bf18c 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -183,7 +183,6 @@ void OS_Windows::initialize() {
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_FILESYSTEM);
- //FileAccessBufferedFA<FileAccessWindows>::make_default();
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_RESOURCES);
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM);
@@ -562,21 +561,21 @@ String OS_Windows::get_locale() const {
LANGID langid = GetUserDefaultUILanguage();
String neutral;
- int lang = langid & ((1 << 9) - 1);
- int sublang = langid & ~((1 << 9) - 1);
+ int lang = PRIMARYLANGID(langid);
+ int sublang = SUBLANGID(langid);
while (wl->locale) {
if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL)
neutral = wl->locale;
if (lang == wl->main_lang && sublang == wl->sublang)
- return wl->locale;
+ return String(wl->locale).replace("-", "_");
wl++;
}
if (neutral != "")
- return neutral;
+ return String(neutral).replace("-", "_");
return "en";
}
@@ -802,6 +801,11 @@ void OS_Windows::set_current_tablet_driver(const String &p_driver) {
}
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
+ ticks_per_second = 0;
+ ticks_start = 0;
+ main_loop = nullptr;
+ process_map = nullptr;
+
//Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
HMODULE wintab_lib = LoadLibraryW(L"wintab32.dll");
if (wintab_lib) {