diff options
Diffstat (limited to 'platform')
22 files changed, 150 insertions, 99 deletions
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index f6a0776017..bd194478d9 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -292,7 +292,7 @@ void AndroidInputHandler::_release_mouse_event_info(bool p_source_mouse_relative mouse_event_info.valid = false; } -void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_android_buttons_mask, Point2 p_event_pos, Vector2 p_delta, bool p_double_click, bool p_source_mouse_relative) { +void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_android_buttons_mask, Point2 p_event_pos, Vector2 p_delta, bool p_double_click, bool p_source_mouse_relative, float p_pressure, Vector2 p_tilt) { BitField<MouseButtonMask> event_buttons_mask = _android_button_mask_to_godot_button_mask(p_event_android_buttons_mask); switch (p_event_action) { case AMOTION_EVENT_ACTION_HOVER_MOVE: // hover move @@ -349,6 +349,8 @@ void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_an hover_prev_pos = p_event_pos; } ev->set_button_mask(event_buttons_mask); + ev->set_pressure(p_pressure); + ev->set_tilt(p_tilt); Input::get_singleton()->parse_input_event(ev); } break; diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h index c74c5020e3..78a484cf05 100644 --- a/platform/android/android_input_handler.h +++ b/platform/android/android_input_handler.h @@ -96,7 +96,7 @@ private: void _cancel_all_touch(); public: - void process_mouse_event(int p_event_action, int p_event_android_buttons_mask, Point2 p_event_pos, Vector2 p_delta, bool p_double_click, bool p_source_mouse_relative); + void process_mouse_event(int p_event_action, int p_event_android_buttons_mask, Point2 p_event_pos, Vector2 p_delta, bool p_double_click, bool p_source_mouse_relative, float p_pressure, Vector2 p_tilt); void process_touch_event(int p_event, int p_pointer, const Vector<TouchPos> &p_points, bool p_double_tap); void process_magnify(Point2 p_pos, float p_factor); void process_pan(Point2 p_pos, Vector2 p_delta); diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 6bd09fe00a..d24d3fa389 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -67,7 +67,7 @@ String DirAccessJAndroid::get_next() { ERR_FAIL_COND_V(id == 0, ""); if (_dir_next) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ""); + ERR_FAIL_NULL_V(env, ""); jstring str = (jstring)env->CallObjectMethod(dir_access_handler, _dir_next, get_access_type(), id); if (!str) { return ""; @@ -84,7 +84,7 @@ String DirAccessJAndroid::get_next() { bool DirAccessJAndroid::current_is_dir() const { if (_dir_is_dir) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(dir_access_handler, _dir_is_dir, get_access_type(), id); } else { return false; @@ -94,7 +94,7 @@ bool DirAccessJAndroid::current_is_dir() const { bool DirAccessJAndroid::current_is_hidden() const { if (_current_is_hidden) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(dir_access_handler, _current_is_hidden, get_access_type(), id); } return false; @@ -112,7 +112,7 @@ void DirAccessJAndroid::list_dir_end() { int DirAccessJAndroid::get_drive_count() { if (_get_drive_count) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); return env->CallIntMethod(dir_access_handler, _get_drive_count, get_access_type()); } else { return 0; @@ -122,7 +122,7 @@ int DirAccessJAndroid::get_drive_count() { String DirAccessJAndroid::get_drive(int p_drive) { if (_get_drive) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ""); + ERR_FAIL_NULL_V(env, ""); jstring j_drive = (jstring)env->CallObjectMethod(dir_access_handler, _get_drive, get_access_type(), p_drive); if (!j_drive) { return ""; @@ -191,7 +191,7 @@ String DirAccessJAndroid::get_absolute_path(String p_path) { bool DirAccessJAndroid::file_exists(String p_file) { if (_file_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = get_absolute_path(p_file); jstring j_path = env->NewStringUTF(path.utf8().get_data()); @@ -206,7 +206,7 @@ bool DirAccessJAndroid::file_exists(String p_file) { bool DirAccessJAndroid::dir_exists(String p_dir) { if (_dir_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = get_absolute_path(p_dir); jstring j_path = env->NewStringUTF(path.utf8().get_data()); @@ -226,7 +226,7 @@ Error DirAccessJAndroid::make_dir_recursive(String p_dir) { if (_make_dir) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = get_absolute_path(p_dir); jstring j_dir = env->NewStringUTF(path.utf8().get_data()); @@ -249,7 +249,7 @@ Error DirAccessJAndroid::make_dir(String p_dir) { Error DirAccessJAndroid::rename(String p_from, String p_to) { if (_rename) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String from_path = get_absolute_path(p_from); jstring j_from = env->NewStringUTF(from_path.utf8().get_data()); @@ -273,7 +273,7 @@ Error DirAccessJAndroid::rename(String p_from, String p_to) { Error DirAccessJAndroid::remove(String p_name) { if (_remove) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = get_absolute_path(p_name); jstring j_name = env->NewStringUTF(path.utf8().get_data()); @@ -292,7 +292,7 @@ Error DirAccessJAndroid::remove(String p_name) { uint64_t DirAccessJAndroid::get_space_left() { if (_get_space_left) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); return env->CallLongMethod(dir_access_handler, _get_space_left, get_access_type()); } else { return 0; @@ -331,7 +331,7 @@ DirAccessJAndroid::~DirAccessJAndroid() { int DirAccessJAndroid::dir_open(String p_path) { if (_dir_open) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); String path = get_absolute_path(p_path); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -346,7 +346,7 @@ int DirAccessJAndroid::dir_open(String p_path) { void DirAccessJAndroid::dir_close(int p_id) { if (_dir_close) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(dir_access_handler, _dir_close, get_access_type(), p_id); } } diff --git a/platform/android/file_access_filesystem_jandroid.cpp b/platform/android/file_access_filesystem_jandroid.cpp index a1865fb1d4..beea73fd61 100644 --- a/platform/android/file_access_filesystem_jandroid.cpp +++ b/platform/android/file_access_filesystem_jandroid.cpp @@ -69,7 +69,7 @@ Error FileAccessFilesystemJAndroid::open_internal(const String &p_path, int p_mo if (_file_open) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); String path = fix_path(p_path).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -103,7 +103,7 @@ void FileAccessFilesystemJAndroid::_close() { if (_file_close) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(file_access_handler, _file_close, id); } id = 0; @@ -116,7 +116,7 @@ bool FileAccessFilesystemJAndroid::is_open() const { void FileAccessFilesystemJAndroid::seek(uint64_t p_position) { if (_file_seek) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_seek, id, p_position); } @@ -125,7 +125,7 @@ void FileAccessFilesystemJAndroid::seek(uint64_t p_position) { void FileAccessFilesystemJAndroid::seek_end(int64_t p_position) { if (_file_seek_end) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_seek_end, id, p_position); } @@ -134,7 +134,7 @@ void FileAccessFilesystemJAndroid::seek_end(int64_t p_position) { uint64_t FileAccessFilesystemJAndroid::get_position() const { if (_file_tell) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use."); return env->CallLongMethod(file_access_handler, _file_tell, id); } else { @@ -145,7 +145,7 @@ uint64_t FileAccessFilesystemJAndroid::get_position() const { uint64_t FileAccessFilesystemJAndroid::get_length() const { if (_file_get_size) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); ERR_FAIL_COND_V_MSG(!is_open(), 0, "File must be opened before use."); return env->CallLongMethod(file_access_handler, _file_get_size, id); } else { @@ -156,7 +156,7 @@ uint64_t FileAccessFilesystemJAndroid::get_length() const { bool FileAccessFilesystemJAndroid::eof_reached() const { if (_file_eof) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); ERR_FAIL_COND_V_MSG(!is_open(), false, "File must be opened before use."); return env->CallBooleanMethod(file_access_handler, _file_eof, id); } else { @@ -169,7 +169,7 @@ void FileAccessFilesystemJAndroid::_set_eof(bool eof) { ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(file_access_handler, _file_set_eof, id, eof); } } @@ -235,7 +235,7 @@ uint64_t FileAccessFilesystemJAndroid::get_buffer(uint8_t *p_dst, uint64_t p_len } JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, 0); + ERR_FAIL_NULL_V(env, 0); jobject j_buffer = env->NewDirectByteBuffer(p_dst, p_length); int length = env->CallIntMethod(file_access_handler, _file_read, id, j_buffer); @@ -258,7 +258,7 @@ void FileAccessFilesystemJAndroid::store_buffer(const uint8_t *p_src, uint64_t p } JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); jobject j_buffer = env->NewDirectByteBuffer((void *)p_src, p_length); env->CallVoidMethod(file_access_handler, _file_write, id, j_buffer); @@ -276,7 +276,7 @@ Error FileAccessFilesystemJAndroid::get_error() const { void FileAccessFilesystemJAndroid::flush() { if (_file_flush) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); ERR_FAIL_COND_MSG(!is_open(), "File must be opened before use."); env->CallVoidMethod(file_access_handler, _file_flush, id); } @@ -285,7 +285,7 @@ void FileAccessFilesystemJAndroid::flush() { bool FileAccessFilesystemJAndroid::file_exists(const String &p_path) { if (_file_exists) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = fix_path(p_path).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); @@ -300,7 +300,7 @@ bool FileAccessFilesystemJAndroid::file_exists(const String &p_path) { uint64_t FileAccessFilesystemJAndroid::_get_modified_time(const String &p_file) { if (_file_last_modified) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); String path = fix_path(p_file).simplify_path(); jstring js = env->NewStringUTF(path.utf8().get_data()); diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index b9ecd6971d..fee50e93c2 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -114,7 +114,7 @@ public class GodotLib { /** * Dispatch mouse events */ - public static native void dispatchMouseEvent(int event, int buttonMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative); + public static native void dispatchMouseEvent(int event, int buttonMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative, float pressure, float tiltX, float tiltY); public static native void magnify(float x, float y, float factor); diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java index a7064dfc1d..3070a8a207 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java @@ -33,6 +33,7 @@ package org.godotengine.godot.input; import org.godotengine.godot.*; import android.content.Context; +import android.content.res.Configuration; import android.os.Handler; import android.os.Message; import android.text.InputFilter; @@ -209,6 +210,13 @@ public class GodotEditText extends EditText { mRenderView.getView().requestFocus(); } + // When a hardware keyboard is connected, all key events come through so we can route them + // directly to the engine. + // This is not the case when using a soft keyboard, requiring extra processing from this class. + if (hasHardwareKeyboard()) { + return mRenderView.getInputHandler().onKeyDown(keyCode, keyEvent); + } + // pass event to godot in special cases if (needHandlingInGodot(keyCode, keyEvent) && mRenderView.getInputHandler().onKeyDown(keyCode, keyEvent)) { return true; @@ -219,6 +227,13 @@ public class GodotEditText extends EditText { @Override public boolean onKeyUp(int keyCode, KeyEvent keyEvent) { + // When a hardware keyboard is connected, all key events come through so we can route them + // directly to the engine. + // This is not the case when using a soft keyboard, requiring extra processing from this class. + if (hasHardwareKeyboard()) { + return mRenderView.getInputHandler().onKeyUp(keyCode, keyEvent); + } + if (needHandlingInGodot(keyCode, keyEvent) && mRenderView.getInputHandler().onKeyUp(keyCode, keyEvent)) { return true; } else { @@ -235,10 +250,20 @@ public class GodotEditText extends EditText { isModifiedKey; } + boolean hasHardwareKeyboard() { + Configuration config = getResources().getConfiguration(); + return config.keyboard != Configuration.KEYBOARD_NOKEYS && + config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO; + } + // =========================================================== // Methods // =========================================================== public void showKeyboard(String p_existing_text, VirtualKeyboardType p_type, int p_max_input_length, int p_cursor_start, int p_cursor_end) { + if (hasHardwareKeyboard()) { + return; + } + int maxInputLength = (p_max_input_length <= 0) ? Integer.MAX_VALUE : p_max_input_length; if (p_cursor_start == -1) { // cursor position not given this.mOriginText = p_existing_text; @@ -262,6 +287,10 @@ public class GodotEditText extends EditText { } public void hideKeyboard() { + if (hasHardwareKeyboard()) { + return; + } + final Message msg = new Message(); msg.what = HANDLER_CLOSE_IME_KEYBOARD; msg.obj = this; 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 1a25be0460..c8b222254e 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 @@ -433,7 +433,7 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { } private static boolean isMouseEvent(int eventSource) { - boolean mouseSource = ((eventSource & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) || ((eventSource & (InputDevice.SOURCE_TOUCHSCREEN | InputDevice.SOURCE_STYLUS)) == InputDevice.SOURCE_STYLUS); + boolean mouseSource = ((eventSource & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) || ((eventSource & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mouseSource = mouseSource || ((eventSource & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE); } @@ -470,13 +470,27 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { final float y = event.getY(); final int buttonsMask = event.getButtonState(); + final float pressure = event.getPressure(); + + // Orientation is returned as a radian value between 0 to pi clockwise or 0 to -pi counterclockwise. + final float orientation = event.getOrientation(); + + // Tilt is zero is perpendicular to the screen and pi/2 is flat on the surface. + final float tilt = event.getAxisValue(MotionEvent.AXIS_TILT); + + float tiltMult = (float)Math.sin(tilt); + + // To be consistent with expected tilt. + final float tiltX = (float)-Math.sin(orientation) * tiltMult; + final float tiltY = (float)Math.cos(orientation) * tiltMult; + final float verticalFactor = event.getAxisValue(MotionEvent.AXIS_VSCROLL); final float horizontalFactor = event.getAxisValue(MotionEvent.AXIS_HSCROLL); boolean sourceMouseRelative = false; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { sourceMouseRelative = event.isFromSource(InputDevice.SOURCE_MOUSE_RELATIVE); } - return handleMouseEvent(eventAction, buttonsMask, x, y, horizontalFactor, verticalFactor, false, sourceMouseRelative); + return handleMouseEvent(eventAction, buttonsMask, x, y, horizontalFactor, verticalFactor, false, sourceMouseRelative, pressure, tiltX, tiltY); } static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y) { @@ -484,6 +498,10 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { } static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative) { + return handleMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative, 1, 0, 0); + } + + static boolean handleMouseEvent(int eventAction, int buttonsMask, float x, float y, float deltaX, float deltaY, boolean doubleClick, boolean sourceMouseRelative, float pressure, float tiltX, float tiltY) { // Fix the buttonsMask switch (eventAction) { case MotionEvent.ACTION_CANCEL: @@ -511,7 +529,7 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { case MotionEvent.ACTION_HOVER_MOVE: case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_SCROLL: { - GodotLib.dispatchMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative); + GodotLib.dispatchMouseEvent(eventAction, buttonsMask, x, y, deltaX, deltaY, doubleClick, sourceMouseRelative, pressure, tiltX, tiltY); return true; } } diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 74605e3377..50075ed3f5 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -274,12 +274,12 @@ JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, } // Called on the UI thread -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y) { if (step.get() <= 0) { return; } - input_handler->process_mouse_event(p_event_type, p_button_mask, Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y), p_double_click, p_source_mouse_relative); + input_handler->process_mouse_event(p_event_type, p_button_mask, Point2(p_x, p_y), Vector2(p_delta_x, p_delta_y), p_double_click, p_source_mouse_relative, p_pressure, Vector2(p_tilt_x, p_tilt_y)); } // Called on the UI thread diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h index ee6a19034c..1ddda6c1c8 100644 --- a/platform/android/java_godot_lib_jni.h +++ b/platform/android/java_godot_lib_jni.h @@ -45,7 +45,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_ttsCallback(JNIEnv *env, jclass clazz, jint event, jint id, jint pos); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jclass clazz); -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JNIEnv *env, jclass clazz, jint p_event_type, jint p_button_mask, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y, jboolean p_double_click, jboolean p_source_mouse_relative, jfloat p_pressure, jfloat p_tilt_x, jfloat p_tilt_y); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jboolean p_double_tap); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnify(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_factor); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_pan(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y); diff --git a/platform/android/tts_android.cpp b/platform/android/tts_android.cpp index aef59c2584..93517d8045 100644 --- a/platform/android/tts_android.cpp +++ b/platform/android/tts_android.cpp @@ -54,7 +54,7 @@ void TTS_Android::setup(jobject p_tts) { bool tts_enabled = GLOBAL_GET("audio/general/text_to_speech"); if (tts_enabled) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); tts = env->NewGlobalRef(p_tts); @@ -103,7 +103,7 @@ bool TTS_Android::is_speaking() { if (_is_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(tts, _is_speaking); } else { return false; @@ -115,7 +115,7 @@ bool TTS_Android::is_paused() { if (_is_paused) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, false); + ERR_FAIL_NULL_V(env, false); return env->CallBooleanMethod(tts, _is_paused); } else { return false; @@ -127,7 +127,7 @@ Array TTS_Android::get_voices() { Array list; if (_get_voices) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND_V(env == nullptr, list); + ERR_FAIL_NULL_V(env, list); jobject voices_object = env->CallObjectMethod(tts, _get_voices); jobjectArray *arr = reinterpret_cast<jobjectArray *>(&voices_object); @@ -165,7 +165,7 @@ void TTS_Android::speak(const String &p_text, const String &p_voice, int p_volum if (_speak) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); jstring jStrT = env->NewStringUTF(p_text.utf8().get_data()); jstring jStrV = env->NewStringUTF(p_voice.utf8().get_data()); @@ -178,7 +178,7 @@ void TTS_Android::pause() { if (_pause_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _pause_speaking); } } @@ -188,7 +188,7 @@ void TTS_Android::resume() { if (_resume_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _resume_speaking); } } @@ -203,7 +203,7 @@ void TTS_Android::stop() { if (_stop_speaking) { JNIEnv *env = get_jni_env(); - ERR_FAIL_COND(env == nullptr); + ERR_FAIL_NULL(env); env->CallVoidMethod(tts, _stop_speaking); } } diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 50102e02cc..68e6d4c934 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -257,7 +257,7 @@ Error OS_IOS::open_dynamic_library(const String p_path, void *&p_library_handle, } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); - ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); + ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); if (r_resolved_path != nullptr) { *r_resolved_path = path; diff --git a/platform/linuxbsd/godot_linuxbsd.cpp b/platform/linuxbsd/godot_linuxbsd.cpp index d059d60b72..efad9c8594 100644 --- a/platform/linuxbsd/godot_linuxbsd.cpp +++ b/platform/linuxbsd/godot_linuxbsd.cpp @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) { TEST_MAIN_OVERRIDE char *cwd = (char *)malloc(PATH_MAX); - ERR_FAIL_COND_V(!cwd, ERR_OUT_OF_MEMORY); + ERR_FAIL_NULL_V(cwd, ERR_OUT_OF_MEMORY); char *ret = getcwd(cwd, PATH_MAX); Error err = Main::setup(argv[0], argc - 1, &argv[1]); diff --git a/platform/linuxbsd/tts_linux.cpp b/platform/linuxbsd/tts_linux.cpp index 8bc83f5b9c..96745ab8ae 100644 --- a/platform/linuxbsd/tts_linux.cpp +++ b/platform/linuxbsd/tts_linux.cpp @@ -186,7 +186,7 @@ bool TTS_Linux::is_paused() const { Array TTS_Linux::get_voices() const { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND_V(!synth, Array()); + ERR_FAIL_NULL_V(synth, Array()); const_cast<TTS_Linux *>(this)->_load_voices(); Array list; @@ -204,7 +204,7 @@ Array TTS_Linux::get_voices() const { void TTS_Linux::speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); if (p_interrupt) { stop(); } @@ -233,7 +233,7 @@ void TTS_Linux::speak(const String &p_text, const String &p_voice, int p_volume, void TTS_Linux::pause() { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); if (spd_pause(synth) == 0) { paused = true; } @@ -242,7 +242,7 @@ void TTS_Linux::pause() { void TTS_Linux::resume() { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); spd_resume(synth); paused = false; } @@ -250,7 +250,7 @@ void TTS_Linux::resume() { void TTS_Linux::stop() { _THREAD_SAFE_METHOD_ - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); for (DisplayServer::TTSUtterance &message : queue) { DisplayServer::get_singleton()->tts_post_utterance_event(DisplayServer::TTS_UTTERANCE_CANCELED, message.id); } diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index f38a9dd278..d20a591299 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -307,37 +307,37 @@ void DisplayServerX11::_flush_mouse_motion() { #ifdef SPEECHD_ENABLED bool DisplayServerX11::tts_is_speaking() const { - ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->is_speaking(); } bool DisplayServerX11::tts_is_paused() const { - ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->is_paused(); } TypedArray<Dictionary> DisplayServerX11::tts_get_voices() const { - ERR_FAIL_COND_V_MSG(!tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->get_voices(); } void DisplayServerX11::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->speak(p_text, p_voice, p_volume, p_pitch, p_rate, p_utterance_id, p_interrupt); } void DisplayServerX11::tts_pause() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->pause(); } void DisplayServerX11::tts_resume() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->resume(); } void DisplayServerX11::tts_stop() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->stop(); } @@ -5100,7 +5100,7 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V XVisualInfo vInfoTemplate = {}; vInfoTemplate.screen = DefaultScreen(x11_display); XVisualInfo *vi_list = XGetVisualInfo(x11_display, visualMask, &vInfoTemplate, &numberOfVisuals); - ERR_FAIL_COND_V(!vi_list, INVALID_WINDOW_ID); + ERR_FAIL_NULL_V(vi_list, INVALID_WINDOW_ID); visualInfo = vi_list[0]; if (OS::get_singleton()->is_layered_allowed()) { diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index f24bac5e19..13b5dedb1e 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -103,7 +103,7 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) { GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (GLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte *)"glXCreateContextAttribsARB"); - ERR_FAIL_COND_V(!glXCreateContextAttribsARB, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(glXCreateContextAttribsARB, ERR_UNCONFIGURED); static int visual_attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, @@ -134,7 +134,7 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) { if (OS::get_singleton()->is_layered_allowed()) { GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs_layered, &fbcount); - ERR_FAIL_COND_V(!fbc, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(fbc, ERR_UNCONFIGURED); for (int i = 0; i < fbcount; i++) { vi = (XVisualInfo *)glXGetVisualFromFBConfig(x11_display, fbc[i]); @@ -156,10 +156,10 @@ Error GLManager_X11::_create_context(GLDisplay &gl_display) { } XFree(fbc); - ERR_FAIL_COND_V(!fbconfig, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(fbconfig, ERR_UNCONFIGURED); } else { GLXFBConfig *fbc = glXChooseFBConfig(x11_display, DefaultScreen(x11_display), visual_attribs, &fbcount); - ERR_FAIL_COND_V(!fbc, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(fbc, ERR_UNCONFIGURED); vi = glXGetVisualFromFBConfig(x11_display, fbc[0]); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index e79d6acc3f..bc78f343ee 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -1451,7 +1451,7 @@ void DisplayServerMacOS::global_menu_set_item_checkable(const String &p_menu_roo NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->checkable_type = (p_checkable) ? CHECKABLE_TYPE_CHECK_BOX : CHECKABLE_TYPE_NONE; } } @@ -1470,7 +1470,7 @@ void DisplayServerMacOS::global_menu_set_item_radio_checkable(const String &p_me NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->checkable_type = (p_checkable) ? CHECKABLE_TYPE_RADIO_BUTTON : CHECKABLE_TYPE_NONE; } } @@ -1489,7 +1489,7 @@ void DisplayServerMacOS::global_menu_set_item_callback(const String &p_menu_root NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->callback = p_callback; } } @@ -1508,7 +1508,7 @@ void DisplayServerMacOS::global_menu_set_item_key_callback(const String &p_menu_ NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->key_callback = p_key_callback; } } @@ -1527,7 +1527,7 @@ void DisplayServerMacOS::global_menu_set_item_tag(const String &p_menu_root, int NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->meta = p_tag; } } @@ -1642,7 +1642,7 @@ void DisplayServerMacOS::global_menu_set_item_state(const String &p_menu_root, i NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->state = p_state; } } @@ -1661,7 +1661,7 @@ void DisplayServerMacOS::global_menu_set_item_max_states(const String &p_menu_ro NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); obj->max_states = p_max_states; } } @@ -1680,7 +1680,7 @@ void DisplayServerMacOS::global_menu_set_item_icon(const String &p_menu_root, in NSMenuItem *menu_item = [menu itemAtIndex:p_idx]; if (menu_item) { GodotMenuItem *obj = [menu_item representedObject]; - ERR_FAIL_COND(!obj); + ERR_FAIL_NULL(obj); if (p_icon.is_valid()) { obj->img = p_icon->get_image(); obj->img = obj->img->duplicate(); @@ -3826,10 +3826,10 @@ void DisplayServerMacOS::set_native_icon(const String &p_filename) { @try { NSData *icon_data = [[NSData alloc] initWithBytes:&data.write[0] length:len]; - ERR_FAIL_COND_MSG(!icon_data, "Error reading icon data."); + ERR_FAIL_NULL_MSG(icon_data, "Error reading icon data."); NSImage *icon = [[NSImage alloc] initWithData:icon_data]; - ERR_FAIL_COND_MSG(!icon, "Error loading icon."); + ERR_FAIL_NULL_MSG(icon, "Error loading icon."); [NSApp setApplicationIconImage:icon]; } @catch (NSException *exception) { diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index c17ea95f4f..1b8ca0134d 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -231,7 +231,7 @@ Error OS_MacOS::open_dynamic_library(const String p_path, void *&p_library_handl } p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); - ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); + ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); if (r_resolved_path != nullptr) { *r_resolved_path = path; diff --git a/platform/web/detect.py b/platform/web/detect.py index 7b2e5646d6..3e2bb5cd30 100644 --- a/platform/web/detect.py +++ b/platform/web/detect.py @@ -118,11 +118,6 @@ def configure(env: "Environment"): else: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto"]) - # Workaround https://github.com/emscripten-core/emscripten/issues/19781. - cc_version = get_compiler_version(env) - cc_semver = (int(cc_version["major"]), int(cc_version["minor"]), int(cc_version["patch"])) - if cc_semver >= (3, 1, 42): - env.Append(LINKFLAGS=["-Wl,-u,scalbnf"]) # Sanitizers if env["use_ubsan"]: @@ -204,9 +199,16 @@ def configure(env: "Environment"): env.Append(LINKFLAGS=["-s", "PTHREAD_POOL_SIZE=8"]) env.Append(LINKFLAGS=["-s", "WASM_MEM_MAX=2048MB"]) + # Get version info for checks below. + cc_version = get_compiler_version(env) + cc_semver = (int(cc_version["major"]), int(cc_version["minor"]), int(cc_version["patch"])) + + if env["lto"] != "none": + # Workaround https://github.com/emscripten-core/emscripten/issues/19781. + if cc_semver >= (3, 1, 42) and cc_semver < (3, 1, 46): + env.Append(LINKFLAGS=["-Wl,-u,scalbnf"]) + if env["dlink_enabled"]: - cc_version = get_compiler_version(env) - cc_semver = (int(cc_version["major"]), int(cc_version["minor"]), int(cc_version["patch"])) if cc_semver < (3, 1, 14): print("GDExtension support requires emscripten >= 3.1.14, detected: %s.%s.%s" % cc_semver) sys.exit(255) diff --git a/platform/web/os_web.cpp b/platform/web/os_web.cpp index 9ee8f90e89..f038f0248a 100644 --- a/platform/web/os_web.cpp +++ b/platform/web/os_web.cpp @@ -232,7 +232,7 @@ bool OS_Web::is_userfs_persistent() const { Error OS_Web::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) { String path = p_path.get_file(); p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); - ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); + ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror())); if (r_resolved_path != nullptr) { *r_resolved_path = path; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 5863a75324..7a24e887b0 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -184,37 +184,37 @@ void DisplayServerWindows::_register_raw_input_devices(WindowID p_target_window) } bool DisplayServerWindows::tts_is_speaking() const { - ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->is_speaking(); } bool DisplayServerWindows::tts_is_paused() const { - ERR_FAIL_COND_V_MSG(!tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, false, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->is_paused(); } TypedArray<Dictionary> DisplayServerWindows::tts_get_voices() const { - ERR_FAIL_COND_V_MSG(!tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_V_MSG(tts, TypedArray<Dictionary>(), "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); return tts->get_voices(); } void DisplayServerWindows::tts_speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->speak(p_text, p_voice, p_volume, p_pitch, p_rate, p_utterance_id, p_interrupt); } void DisplayServerWindows::tts_pause() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->pause(); } void DisplayServerWindows::tts_resume() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->resume(); } void DisplayServerWindows::tts_stop() { - ERR_FAIL_COND_MSG(!tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); + ERR_FAIL_NULL_MSG(tts, "Enable the \"audio/general/text_to_speech\" project setting to use text-to-speech."); tts->stop(); } @@ -413,7 +413,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { Char16String utf16 = text.utf16(); HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (utf16.length() + 1) * sizeof(WCHAR)); - ERR_FAIL_COND_MSG(mem == nullptr, "Unable to allocate memory for clipboard contents."); + ERR_FAIL_NULL_MSG(mem, "Unable to allocate memory for clipboard contents."); LPWSTR lptstrCopy = (LPWSTR)GlobalLock(mem); memcpy(lptstrCopy, utf16.get_data(), (utf16.length() + 1) * sizeof(WCHAR)); @@ -424,7 +424,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { // Set the CF_TEXT version (not needed?). CharString utf8 = text.utf8(); mem = GlobalAlloc(GMEM_MOVEABLE, utf8.length() + 1); - ERR_FAIL_COND_MSG(mem == nullptr, "Unable to allocate memory for clipboard contents."); + ERR_FAIL_NULL_MSG(mem, "Unable to allocate memory for clipboard contents."); LPTSTR ptr = (LPTSTR)GlobalLock(mem); memcpy(ptr, utf8.get_data(), utf8.length()); @@ -2465,7 +2465,7 @@ void DisplayServerWindows::set_icon(const Ref<Image> &p_icon) { } HICON hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000); - ERR_FAIL_COND(!hicon); + ERR_FAIL_NULL(hicon); icon = img; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index b661222dfe..1d3b80e21e 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -395,7 +395,7 @@ Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_han } } #else - ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, format_error_message(GetLastError()))); + ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, format_error_message(GetLastError()))); #endif if (cookie) { @@ -1678,7 +1678,7 @@ Error OS_Windows::move_to_trash(const String &p_path) { String OS_Windows::get_system_ca_certificates() { HCERTSTORE cert_store = CertOpenSystemStoreA(0, "ROOT"); - ERR_FAIL_COND_V_MSG(!cert_store, "", "Failed to read the root certificate store."); + ERR_FAIL_NULL_V_MSG(cert_store, "", "Failed to read the root certificate store."); FILETIME curr_time; GetSystemTimeAsFileTime(&curr_time); diff --git a/platform/windows/tts_windows.cpp b/platform/windows/tts_windows.cpp index 907096d890..11d63d85ee 100644 --- a/platform/windows/tts_windows.cpp +++ b/platform/windows/tts_windows.cpp @@ -114,7 +114,7 @@ void TTS_Windows::_update_tts() { } bool TTS_Windows::is_speaking() const { - ERR_FAIL_COND_V(!synth, false); + ERR_FAIL_NULL_V(synth, false); SPVOICESTATUS status; synth->GetStatus(&status, nullptr); @@ -122,7 +122,7 @@ bool TTS_Windows::is_speaking() const { } bool TTS_Windows::is_paused() const { - ERR_FAIL_COND_V(!synth, false); + ERR_FAIL_NULL_V(synth, false); return paused; } @@ -185,7 +185,7 @@ Array TTS_Windows::get_voices() const { } void TTS_Windows::speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt) { - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); if (p_interrupt) { stop(); } @@ -212,7 +212,7 @@ void TTS_Windows::speak(const String &p_text, const String &p_voice, int p_volum } void TTS_Windows::pause() { - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); if (!paused) { if (synth->Pause() == S_OK) { paused = true; @@ -221,13 +221,13 @@ void TTS_Windows::pause() { } void TTS_Windows::resume() { - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); synth->Resume(); paused = false; } void TTS_Windows::stop() { - ERR_FAIL_COND(!synth); + ERR_FAIL_NULL(synth); SPVOICESTATUS status; synth->GetStatus(&status, nullptr); |