summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/file_access_jandroid.cpp2
-rw-r--r--platform/android/java_godot_lib_jni.cpp8
-rw-r--r--platform/iphone/camera_ios.mm16
-rw-r--r--platform/iphone/export/export.cpp8
-rw-r--r--platform/javascript/detect.py9
-rw-r--r--platform/javascript/os_javascript.cpp17
-rw-r--r--platform/javascript/os_javascript.h1
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm18
-rw-r--r--platform/windows/os_windows.cpp18
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/godot_x11.cpp1
-rw-r--r--platform/x11/os_x11.cpp18
-rw-r--r--platform/x11/os_x11.h1
14 files changed, 110 insertions, 9 deletions
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index 63bc5f69d1..5b8cf01138 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -62,7 +62,7 @@ Error FileAccessJAndroid::_open(const String &p_path, int p_mode_flags) {
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);
+ 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);
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index 466f79c215..77f077456e 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -289,7 +289,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
PoolVector<int>::Write w = sarr.write();
env->GetIntArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<int>::Write();
+ w.release();
return sarr;
};
@@ -302,7 +302,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
PoolVector<uint8_t>::Write w = sarr.write();
env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast<signed char *>(w.ptr()));
- w = PoolVector<uint8_t>::Write();
+ w.release();
return sarr;
};
@@ -514,7 +514,7 @@ public:
PoolVector<int>::Write w = sarr.write();
env->GetIntArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<int>::Write();
+ w.release();
ret = sarr;
env->DeleteLocalRef(arr);
} break;
@@ -528,7 +528,7 @@ public:
PoolVector<float>::Write w = sarr.write();
env->GetFloatArrayRegion(arr, 0, fCount, w.ptr());
- w = PoolVector<float>::Write();
+ w.release();
ret = sarr;
env->DeleteLocalRef(arr);
} break;
diff --git a/platform/iphone/camera_ios.mm b/platform/iphone/camera_ios.mm
index 5a54eaee9b..029ce6debf 100644
--- a/platform/iphone/camera_ios.mm
+++ b/platform/iphone/camera_ios.mm
@@ -397,6 +397,22 @@ void CameraIOS::update_feeds() {
};
CameraIOS::CameraIOS() {
+ // check if we have our usage description
+ NSString *usage_desc = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"];
+ if (usage_desc == NULL) {
+ // don't initialise if we don't get anything
+ print_line("No NSCameraUsageDescription key in pList, no access to cameras.");
+ return;
+ } else if (usage_desc.length == 0) {
+ // don't initialise if we don't get anything
+ print_line("Empty NSCameraUsageDescription key in pList, no access to cameras.");
+ return;
+ }
+
+ // now we'll request access.
+ // If this is the first time the user will be prompted with the string (iOS will read it).
+ // Once a decision is made it is returned. If the user wants to change it later on they
+ // need to go into setting.
print_line("Requesting Camera permissions");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index 99ce2e8f87..85a45d62f8 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -268,8 +268,9 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/in_app_purchases"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "capabilities/push_notifications"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description"), "Godot would like to use your camera"));
- r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description"), "Godot would like to use your photos"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/camera_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the camera"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/microphone_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need to use the microphone"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "privacy/photolibrary_usage_description", PROPERTY_HINT_PLACEHOLDER_TEXT, "Provide a message if you need access to the photo library"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/portrait"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "orientation/landscape_left"), true));
@@ -398,6 +399,9 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
} else if (lines[i].find("$camera_usage_description") != -1) {
String description = p_preset->get("privacy/camera_usage_description");
strnew += lines[i].replace("$camera_usage_description", description) + "\n";
+ } else if (lines[i].find("$microphone_usage_description") != -1) {
+ String description = p_preset->get("privacy/microphone_usage_description");
+ strnew += lines[i].replace("$microphone_usage_description", description) + "\n";
} else if (lines[i].find("$photolibrary_usage_description") != -1) {
String description = p_preset->get("privacy/photolibrary_usage_description");
strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n";
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index c6afa02c6d..10680ad1f5 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -69,9 +69,14 @@ def configure(env):
exec(f.read(), em_config)
except StandardError as e:
raise RuntimeError("Emscripten configuration file '%s' is invalid:\n%s" % (em_config_file, e))
- if 'BINARYEN_ROOT' not in em_config and 'EMSCRIPTEN_ROOT' not in em_config:
+ if 'BINARYEN_ROOT' in em_config and os.path.isdir(os.path.join(em_config.get('BINARYEN_ROOT'), 'emscripten')):
+ # New style, emscripten path as a subfolder of BINARYEN_ROOT
+ env.PrependENVPath('PATH', os.path.join(em_config.get('BINARYEN_ROOT'), 'emscripten'))
+ elif 'EMSCRIPTEN_ROOT' in em_config:
+ # Old style (but can be there as a result from previous activation, so do last)
+ env.PrependENVPath('PATH', em_config.get('EMSCRIPTEN_ROOT'))
+ else:
raise RuntimeError("'BINARYEN_ROOT' or 'EMSCRIPTEN_ROOT' missing in Emscripten configuration file '%s'" % em_config_file)
- env.PrependENVPath('PATH', em_config.get('BINARYEN_ROOT', em_config.get('EMSCRIPTEN_ROOT')))
env['CC'] = 'emcc'
env['CXX'] = 'em++'
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index d96ffc3a55..5363cd4af7 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -448,6 +448,18 @@ void OS_JavaScript::set_cursor_shape(CursorShape p_shape) {
void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ set_cursor_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
Ref<Texture> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
@@ -551,6 +563,11 @@ void OS_JavaScript::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_s
cursors[p_shape] = url;
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
} else if (cursors[p_shape] != "") {
/* clang-format off */
EM_ASM({
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 9635465c0d..10676c49f7 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -52,6 +52,7 @@ class OS_JavaScript : public OS_Unix {
Ref<InputEventKey> deferred_key_event;
CursorShape cursor_shape;
String cursors[CURSOR_MAX];
+ Map<CursorShape, Vector<Variant> > cursors_cache;
Point2 touches[32];
Point2i last_click_pos;
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 1e996608af..a83d5084ed 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -119,6 +119,7 @@ public:
CursorShape cursor_shape;
NSCursor *cursors[CURSOR_MAX];
+ Map<CursorShape, Vector<Variant> > cursors_cache;
MouseMode mouse_mode;
String title;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 4f84ae9c50..726882438b 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1770,7 +1770,20 @@ OS::CursorShape OS_OSX::get_cursor_shape() const {
}
void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+
if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ set_cursor_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
Ref<Texture> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
@@ -1855,6 +1868,11 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
[cursors[p_shape] release];
cursors[p_shape] = cursor;
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
if (p_shape == cursor_shape) {
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
[cursor set];
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 0a9cfc0214..745f3ce379 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2367,7 +2367,20 @@ OS::CursorShape OS_Windows::get_cursor_shape() const {
}
void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+
if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ set_cursor_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
Ref<Texture> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
@@ -2450,6 +2463,11 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
cursors[p_shape] = CreateIconIndirect(&iconinfo);
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
if (p_shape == cursor_shape) {
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
SetCursor(cursors[p_shape]);
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index fc8ad1b188..ce55328173 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -155,6 +155,7 @@ class OS_Windows : public OS {
HCURSOR cursors[CURSOR_MAX] = { NULL };
CursorShape cursor_shape;
+ Map<CursorShape, Vector<Variant> > cursors_cache;
InputDefault *input;
JoypadWindows *joypad;
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index 9baa4d6dca..755ef7a84f 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -43,6 +43,7 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
char *cwd = (char *)malloc(PATH_MAX);
+ ERR_FAIL_COND_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/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 624efe8815..9b35648046 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -2878,7 +2878,20 @@ OS::CursorShape OS_X11::get_cursor_shape() const {
}
void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
+
if (p_cursor.is_valid()) {
+
+ Map<CursorShape, Vector<Variant> >::Element *cursor_c = cursors_cache.find(p_shape);
+
+ if (cursor_c) {
+ if (cursor_c->get()[0] == p_cursor && cursor_c->get()[1] == p_hotspot) {
+ set_cursor_shape(p_shape);
+ return;
+ }
+
+ cursors_cache.erase(p_shape);
+ }
+
Ref<Texture> texture = p_cursor;
Ref<AtlasTexture> atlas_texture = p_cursor;
Ref<Image> image;
@@ -2947,6 +2960,11 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
// Save it for a further usage
cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image);
+ Vector<Variant> params;
+ params.push_back(p_cursor);
+ params.push_back(p_hotspot);
+ cursors_cache.insert(p_shape, params);
+
if (p_shape == current_cursor) {
if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 510487b599..a4c22cf08a 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -170,6 +170,7 @@ class OS_X11 : public OS_Unix {
Cursor cursors[CURSOR_MAX];
Cursor null_cursor;
CursorShape current_cursor;
+ Map<CursorShape, Vector<Variant> > cursors_cache;
InputDefault *input;