summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/AndroidManifest.xml.template5
-rw-r--r--platform/android/audio_driver_opensl.cpp113
-rw-r--r--platform/android/audio_driver_opensl.h17
-rw-r--r--platform/android/detect.py6
-rw-r--r--platform/android/dir_access_jandroid.cpp3
-rw-r--r--platform/android/export/export.cpp34
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java52
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotIO.java13
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotInstrumentation.java50
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotLib.java5
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java10
-rw-r--r--platform/android/java_class_wrapper.cpp11
-rw-r--r--platform/android/java_glue.cpp105
-rw-r--r--platform/android/java_glue.h5
-rw-r--r--platform/android/os_android.cpp27
-rw-r--r--platform/android/os_android.h8
-rw-r--r--platform/android/string_android.h58
-rw-r--r--platform/haiku/os_haiku.cpp2
-rw-r--r--platform/iphone/app_delegate.mm24
-rw-r--r--platform/iphone/detect.py8
-rw-r--r--platform/iphone/export/export.cpp31
-rw-r--r--platform/iphone/gl_view.mm32
-rw-r--r--platform/iphone/os_iphone.cpp4
-rw-r--r--platform/javascript/audio_driver_javascript.cpp2
-rw-r--r--platform/javascript/detect.py8
-rw-r--r--platform/javascript/engine.js3
-rw-r--r--platform/javascript/export/export.cpp40
-rw-r--r--platform/javascript/http_request.js6
-rw-r--r--platform/javascript/javascript_eval.cpp4
-rw-r--r--platform/javascript/os_javascript.cpp16
-rw-r--r--platform/osx/export/export.cpp4
-rw-r--r--platform/osx/os_osx.mm98
-rw-r--r--platform/server/detect.py74
-rw-r--r--platform/uwp/export/export.cpp4
-rw-r--r--platform/uwp/os_uwp.cpp6
-rw-r--r--platform/windows/godot.natvis147
-rw-r--r--platform/windows/os_windows.cpp65
-rw-r--r--platform/windows/os_windows.h4
-rw-r--r--platform/x11/detect.py18
-rw-r--r--platform/x11/detect_prime.cpp4
-rw-r--r--platform/x11/joypad_linux.cpp10
-rw-r--r--platform/x11/os_x11.cpp37
42 files changed, 823 insertions, 350 deletions
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template
index d8fb9326ea..daaf847f11 100644
--- a/platform/android/AndroidManifest.xml.template
+++ b/platform/android/AndroidManifest.xml.template
@@ -36,4 +36,9 @@ $$ADD_APPLICATION_CHUNKS$$
</application>
+ <instrumentation android:icon="@drawable/icon"
+ android:label="@string/godot_project_name_string"
+ android:name="org.godotengine.godot.GodotInstrumentation"
+ android:targetPackage="com.godot.game" />
+
</manifest>
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index e259380a63..8913950fac 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -211,6 +211,119 @@ void AudioDriverOpenSL::start() {
active = true;
}
+void AudioDriverOpenSL::_record_buffer_callback(SLAndroidSimpleBufferQueueItf queueItf) {
+
+ for (int i = 0; i < rec_buffer.size(); i++) {
+ int32_t sample = rec_buffer[i] << 16;
+ input_buffer_write(sample);
+ input_buffer_write(sample); // call twice to convert to Stereo
+ }
+
+ SLresult res = (*recordBufferQueueItf)->Enqueue(recordBufferQueueItf, rec_buffer.ptrw(), rec_buffer.size() * sizeof(int16_t));
+ ERR_FAIL_COND(res != SL_RESULT_SUCCESS);
+}
+
+void AudioDriverOpenSL::_record_buffer_callbacks(SLAndroidSimpleBufferQueueItf queueItf, void *pContext) {
+
+ AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext;
+
+ ad->_record_buffer_callback(queueItf);
+}
+
+Error AudioDriverOpenSL::capture_init_device() {
+
+ SLDataLocator_IODevice loc_dev = {
+ SL_DATALOCATOR_IODEVICE,
+ SL_IODEVICE_AUDIOINPUT,
+ SL_DEFAULTDEVICEID_AUDIOINPUT,
+ NULL
+ };
+ SLDataSource recSource = { &loc_dev, NULL };
+
+ SLDataLocator_AndroidSimpleBufferQueue loc_bq = {
+ SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
+ 2
+ };
+ SLDataFormat_PCM format_pcm = {
+ SL_DATAFORMAT_PCM,
+ 1,
+ SL_SAMPLINGRATE_44_1,
+ SL_PCMSAMPLEFORMAT_FIXED_16,
+ SL_PCMSAMPLEFORMAT_FIXED_16,
+ SL_SPEAKER_FRONT_CENTER,
+ SL_BYTEORDER_LITTLEENDIAN
+ };
+ SLDataSink recSnk = { &loc_bq, &format_pcm };
+
+ const SLInterfaceID ids[2] = { SL_IID_ANDROIDSIMPLEBUFFERQUEUE, SL_IID_ANDROIDCONFIGURATION };
+ const SLboolean req[2] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
+
+ SLresult res = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorder, &recSource, &recSnk, 2, ids, req);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recorder)->Realize(recorder, SL_BOOLEAN_FALSE);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recorder)->GetInterface(recorder, SL_IID_RECORD, (void *)&recordItf);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recorder)->GetInterface(recorder, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, (void *)&recordBufferQueueItf);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recordBufferQueueItf)->RegisterCallback(recordBufferQueueItf, _record_buffer_callbacks, this);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ SLuint32 state;
+ res = (*recordItf)->GetRecordState(recordItf, &state);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ if (state != SL_RECORDSTATE_STOPPED) {
+ res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recordBufferQueueItf)->Clear(recordBufferQueueItf);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+ }
+
+ const int rec_buffer_frames = 2048;
+ rec_buffer.resize(rec_buffer_frames);
+ input_buffer_init(rec_buffer_frames);
+
+ res = (*recordBufferQueueItf)->Enqueue(recordBufferQueueItf, rec_buffer.ptrw(), rec_buffer.size() * sizeof(int16_t));
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_RECORDING);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ return OK;
+}
+
+Error AudioDriverOpenSL::capture_start() {
+
+ if (OS::get_singleton()->request_permission("RECORD_AUDIO")) {
+ return capture_init_device();
+ }
+
+ return OK;
+}
+
+Error AudioDriverOpenSL::capture_stop() {
+
+ SLuint32 state;
+ SLresult res = (*recordItf)->GetRecordState(recordItf, &state);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ if (state != SL_RECORDSTATE_STOPPED) {
+ res = (*recordItf)->SetRecordState(recordItf, SL_RECORDSTATE_STOPPED);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+
+ res = (*recordBufferQueueItf)->Clear(recordBufferQueueItf);
+ ERR_FAIL_COND_V(res != SL_RESULT_SUCCESS, ERR_CANT_OPEN);
+ }
+
+ return OK;
+}
+
int AudioDriverOpenSL::get_mix_rate() const {
return 44100;
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index 77e16e507a..2981073cec 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -54,13 +54,18 @@ class AudioDriverOpenSL : public AudioDriver {
int32_t *mixdown_buffer;
int last_free;
+ Vector<int16_t> rec_buffer;
+
SLPlayItf playItf;
+ SLRecordItf recordItf;
SLObjectItf sl;
SLEngineItf EngineItf;
SLObjectItf OutputMix;
SLVolumeItf volumeItf;
SLObjectItf player;
+ SLObjectItf recorder;
SLAndroidSimpleBufferQueueItf bufferQueueItf;
+ SLAndroidSimpleBufferQueueItf recordBufferQueueItf;
SLDataSource audioSource;
SLDataFormat_PCM pcm;
SLDataSink audioSink;
@@ -76,6 +81,15 @@ class AudioDriverOpenSL : public AudioDriver {
SLAndroidSimpleBufferQueueItf queueItf,
void *pContext);
+ void _record_buffer_callback(
+ SLAndroidSimpleBufferQueueItf queueItf);
+
+ static void _record_buffer_callbacks(
+ SLAndroidSimpleBufferQueueItf queueItf,
+ void *pContext);
+
+ virtual Error capture_init_device();
+
public:
void set_singleton();
@@ -91,6 +105,9 @@ public:
virtual void set_pause(bool p_pause);
+ virtual Error capture_start();
+ virtual Error capture_stop();
+
AudioDriverOpenSL();
};
diff --git a/platform/android/detect.py b/platform/android/detect.py
index aa48252435..80cda68a9e 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -298,12 +298,6 @@ def configure(env):
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL'])
env.Append(LIBS=['OpenSLES', 'EGL', 'GLESv3', 'android', 'log', 'z', 'dl'])
- # TODO: Move that to opus module's config
- if 'module_opus_enabled' in env and env['module_opus_enabled']:
- if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"):
- env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
- env.opus_fixed_point = "yes"
-
# Return NDK version string in source.properties (adapted from the Chromium project).
def get_ndk_version(path):
if path is None:
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index 4b3d93aaa7..8c464465ca 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -31,6 +31,7 @@
#include "dir_access_jandroid.h"
#include "core/print_string.h"
#include "file_access_jandroid.h"
+#include "string_android.h"
#include "thread_jandroid.h"
jobject DirAccessJAndroid::io = NULL;
@@ -69,7 +70,7 @@ String DirAccessJAndroid::get_next() {
if (!str)
return "";
- String ret = String::utf8(env->GetStringUTFChars((jstring)str, NULL));
+ String ret = jstring_to_string((jstring)str, env);
env->DeleteLocalRef((jobject)str);
return ret;
}
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 60cc33e6bf..e489bce3f8 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -301,10 +301,10 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
args.push_back(d.id);
args.push_back("shell");
args.push_back("getprop");
- int ec;
+ int ec2;
String dp;
- OS::get_singleton()->execute(adb, args, true, NULL, &dp, &ec);
+ OS::get_singleton()->execute(adb, args, true, NULL, &dp, &ec2);
Vector<String> props = dp.split("\n");
String vendor;
@@ -658,6 +658,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
int orientation = p_preset->get("screen/orientation");
+ bool min_gles3 = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name") == "GLES3" &&
+ !ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2");
bool screen_support_small = p_preset->get("screen/support_small");
bool screen_support_normal = p_preset->get("screen/support_normal");
bool screen_support_large = p_preset->get("screen/support_large");
@@ -815,6 +817,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}
+ if (tname == "uses-feature" && attrname == "glEsVersion") {
+
+ encode_uint32(min_gles3 ? 0x00030000 : 0x00020000, &p_manifest.write[iofs + 16]);
+ }
+
iofs += 20;
}
@@ -1114,17 +1121,14 @@ public:
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- // Re-enable when a GLES 2.0 backend is read
- /*int api = p_preset->get("graphics/api");
- if (api == 0)
- r_features->push_back("etc");
- else*/
String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
- if (driver == "GLES2" || driver == "GLES3") {
+ if (driver == "GLES2") {
r_features->push_back("etc");
- }
- if (driver == "GLES3") {
+ } else if (driver == "GLES3") {
r_features->push_back("etc2");
+ if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
+ r_features->push_back("etc");
+ }
}
Vector<String> abis = get_enabled_abis(p_preset);
@@ -1453,6 +1457,12 @@ public:
err += TTR("Invalid package name:") + " " + pn_err + "\n";
}
+ String etc_error = test_etc2();
+ if (etc_error != String()) {
+ valid = false;
+ err += etc_error;
+ }
+
r_error = err;
return valid;
}
@@ -1489,6 +1499,10 @@ public:
}
}
+ if (!DirAccess::exists(p_path.get_base_dir())) {
+ return ERR_FILE_BAD_PATH;
+ }
+
FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index a10d7876f4..e42099ba0b 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -38,12 +38,14 @@ import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ClipboardManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ConfigurationInfo;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Point;
import android.graphics.Rect;
@@ -51,11 +53,13 @@ import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
+import android.Manifest;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Messenger;
import android.provider.Settings.Secure;
+import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
@@ -98,6 +102,7 @@ import javax.microedition.khronos.opengles.GL10;
public class Godot extends Activity implements SensorEventListener, IDownloaderClient {
static final int MAX_SINGLETONS = 64;
+ static final int REQUEST_RECORD_AUDIO_PERMISSION = 1;
private IStub mDownloaderClientStub;
private IDownloaderService mRemoteService;
private TextView mStatusText;
@@ -258,6 +263,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
for (int i = 0; i < singleton_count; i++) {
singletons[i].onMainRequestPermissionsResult(requestCode, permissions, grantResults);
}
+
+ for (int i = 0; i < permissions.length; i++) {
+ GodotLib.requestPermissionResult(permissions[i], grantResults[i] == PackageManager.PERMISSION_GRANTED);
+ }
};
public void onVideoInit() {
@@ -318,6 +327,23 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
});
}
+ public void restart() {
+ // HACK:
+ //
+ // Currently it's very hard to properly deinitialize Godot on Android to restart the game
+ // from scratch. Therefore, we need to kill the whole app process and relaunch it.
+ //
+ // Restarting only the activity, wouldn't be enough unless it did proper cleanup (including
+ // releasing and reloading native libs or resetting their state somehow and clearing statics).
+ //
+ // Using instrumentation is a way of making the whole app process restart, because Android
+ // will kill any process of the same package which was already running.
+ //
+ Bundle args = new Bundle();
+ args.putParcelable("intent", mCurrentIntent);
+ startInstrumentation(new ComponentName(Godot.this, GodotInstrumentation.class), null, args);
+ }
+
public void alert(final String message, final String title) {
final Activity activity = this;
runOnUiThread(new Runnable() {
@@ -415,7 +441,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME);
- GodotLib.initialize(this, io.needsReloadHooks(), getAssets(), use_apk_expansion);
+ GodotLib.initialize(this, getAssets(), use_apk_expansion);
result_callback = null;
@@ -918,13 +944,27 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
*/
- // Audio
+ public boolean requestPermission(String p_name) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
+ // Not necessary, asked on install already
+ return true;
+ }
+
+ if (p_name.equals("RECORD_AUDIO")) {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[] { Manifest.permission.RECORD_AUDIO }, REQUEST_RECORD_AUDIO_PERMISSION);
+ return false;
+ }
+ }
+
+ return true;
+ }
/**
- * The download state should trigger changes in the UI --- it may be useful
- * to show the state as being indeterminate at times. This sample can be
- * considered a guideline.
- */
+ * The download state should trigger changes in the UI --- it may be useful
+ * to show the state as being indeterminate at times. This sample can be
+ * considered a guideline.
+ */
@Override
public void onDownloadStateChanged(int newState) {
setState(newState);
diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java
index 8cee20e435..1b2ff61314 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java
@@ -500,11 +500,6 @@ public class GodotIO {
return (int)(metrics.density * 160f);
}
- public boolean needsReloadHooks() {
-
- return false;
- }
-
public void showKeyboard(String p_existing_text) {
if (edit != null)
edit.showKeyboard(p_existing_text);
@@ -516,14 +511,6 @@ public class GodotIO {
public void hideKeyboard() {
if (edit != null)
edit.hideKeyboard();
-
- InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
- View v = activity.getCurrentFocus();
- if (v != null) {
- inputMgr.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- } else {
- inputMgr.hideSoftInputFromWindow(new View(activity).getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- }
};
public void setScreenOrientation(int p_orientation) {
diff --git a/platform/android/java/src/org/godotengine/godot/GodotInstrumentation.java b/platform/android/java/src/org/godotengine/godot/GodotInstrumentation.java
new file mode 100644
index 0000000000..0466f380e8
--- /dev/null
+++ b/platform/android/java/src/org/godotengine/godot/GodotInstrumentation.java
@@ -0,0 +1,50 @@
+/*************************************************************************/
+/* GodotInstrumentation.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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. */
+/*************************************************************************/
+
+package org.godotengine.godot;
+
+import android.app.Instrumentation;
+import android.content.Intent;
+import android.os.Bundle;
+
+public class GodotInstrumentation extends Instrumentation {
+ private Intent intent;
+
+ @Override
+ public void onCreate(Bundle arguments) {
+ intent = arguments.getParcelable("intent");
+ start();
+ }
+
+ @Override
+ public void onStart() {
+ startActivitySync(intent);
+ }
+}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java
index 29e7918645..6e6b398a5d 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java
@@ -45,9 +45,9 @@ public class GodotLib {
* @param height the current view height
*/
- public static native void initialize(Godot p_instance, boolean need_reload_hook, Object p_asset_manager, boolean use_apk_expansion);
+ public static native void initialize(Godot p_instance, Object p_asset_manager, boolean use_apk_expansion);
public static native void setup(String[] p_cmdline);
- public static native void resize(int width, int height, boolean reload);
+ public static native void resize(int width, int height);
public static native void newcontext(boolean p_32_bits);
public static native void back();
public static native void step();
@@ -69,6 +69,7 @@ public class GodotLib {
public static native String getGlobal(String p_key);
public static native void callobject(int p_ID, String p_method, Object[] p_params);
public static native void calldeferred(int p_ID, String p_method, Object[] p_params);
+ public static native void requestPermissionResult(String p_permission, boolean p_result);
public static native void setVirtualKeyboardHeight(int p_height);
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index ba8e8bd07b..ccf78f26f3 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -79,7 +79,6 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
private Context ctx;
private GodotIO io;
- private static boolean firsttime = true;
private static boolean use_gl3 = false;
private static boolean use_32 = false;
private static boolean use_debug_opengl = false;
@@ -97,10 +96,8 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
activity = p_activity;
- if (!p_io.needsReloadHooks()) {
- //will only work on SDK 11+!!
- setPreserveEGLContextOnPause(true);
- }
+ setPreserveEGLContextOnPause(true);
+
mInputManager = InputManagerCompat.Factory.getInputManager(this.getContext());
mInputManager.registerInputDeviceListener(this, null);
init(false, 16, 0);
@@ -718,8 +715,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
public void onSurfaceChanged(GL10 gl, int width, int height) {
- GodotLib.resize(width, height, !firsttime);
- firsttime = false;
+ GodotLib.resize(width, height);
for (int i = 0; i < Godot.singleton_count; i++) {
Godot.singletons[i].onGLSurfaceChanged(gl, width, height);
}
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index 4be1106967..2bed1f0892 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "java_class_wrapper.h"
+#include "string_android.h"
#include "thread_jandroid.h"
bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error, Variant &ret) {
@@ -553,7 +554,7 @@ void JavaClassWrapper::_bind_methods() {
bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, String &strsig) {
jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName);
- String str_type = env->GetStringUTFChars(name2, NULL);
+ String str_type = jstring_to_string(name2, env);
env->DeleteLocalRef(name2);
uint32_t t = 0;
@@ -697,7 +698,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
} break;
case ARG_TYPE_STRING: {
- var = String::utf8(env->GetStringUTFChars((jstring)obj, NULL));
+ var = jstring_to_string((jstring)obj, env);
return true;
} break;
case ARG_TYPE_CLASS: {
@@ -1030,7 +1031,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va
if (!o)
ret.push_back(Variant());
else {
- String val = String::utf8(env->GetStringUTFChars((jstring)o, NULL));
+ String val = jstring_to_string((jstring)o, env);
ret.push_back(val);
}
env->DeleteLocalRef(o);
@@ -1075,7 +1076,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
ERR_CONTINUE(!obj);
jstring name = (jstring)env->CallObjectMethod(obj, getName);
- String str_method = env->GetStringUTFChars(name, NULL);
+ String str_method = jstring_to_string(name, env);
env->DeleteLocalRef(name);
Vector<String> params;
@@ -1204,7 +1205,7 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) {
ERR_CONTINUE(!obj);
jstring name = (jstring)env->CallObjectMethod(obj, Field_getName);
- String str_field = env->GetStringUTFChars(name, NULL);
+ String str_field = jstring_to_string(name, env);
env->DeleteLocalRef(name);
int mods = env->CallIntMethod(obj, Field_getModifiers);
if ((mods & 0x8) && (mods & 0x10) && (mods & 0x1)) { //static final public!
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 885fb185a7..e9c0e5564f 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -41,6 +41,7 @@
#include "main/input_default.h"
#include "main/main.h"
#include "os_android.h"
+#include "string_android.h"
#include "thread_jandroid.h"
#include <unistd.h>
@@ -223,7 +224,7 @@ String _get_class_name(JNIEnv *env, jclass cls, bool *array) {
jboolean isarr = env->CallBooleanMethod(cls, isArray);
(*array) = isarr ? true : false;
}
- String name = env->GetStringUTFChars(clsName, NULL);
+ String name = jstring_to_string(clsName, env);
env->DeleteLocalRef(clsName);
return name;
@@ -241,7 +242,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
if (name == "java.lang.String") {
- return String::utf8(env->GetStringUTFChars((jstring)obj, NULL));
+ return jstring_to_string((jstring)obj, env);
};
if (name == "[Ljava.lang.String;") {
@@ -252,7 +253,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
for (int i = 0; i < stringCount; i++) {
jstring string = (jstring)env->GetObjectArrayElement(arr, i);
- sarr.push_back(String::utf8(env->GetStringUTFChars(string, NULL)));
+ sarr.push_back(jstring_to_string(string, env));
env->DeleteLocalRef(string);
}
@@ -487,7 +488,7 @@ public:
case Variant::STRING: {
jobject o = env->CallObjectMethodA(instance, E->get().method, v);
- ret = String::utf8(env->GetStringUTFChars((jstring)o, NULL));
+ ret = jstring_to_string((jstring)o, env);
env->DeleteLocalRef(o);
} break;
case Variant::POOL_STRING_ARRAY: {
@@ -598,6 +599,7 @@ static jobject godot_io;
typedef void (*GFXInitFunc)(void *ud, bool gl2);
static jmethodID _on_video_init = 0;
+static jmethodID _restart = 0;
static jobject _godot_instance;
static jmethodID _openURI = 0;
@@ -619,6 +621,7 @@ static jmethodID _pauseVideo = 0;
static jmethodID _stopVideo = 0;
static jmethodID _setKeepScreenOn = 0;
static jmethodID _alertDialog = 0;
+static jmethodID _requestPermission = 0;
static void _gfx_init_func(void *ud, bool gl2) {
}
@@ -634,20 +637,20 @@ static String _get_user_data_dir() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getDataDir);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static String _get_locale() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getLocale);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static String _get_clipboard() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(_godot_instance, _getClipboard);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static void _set_clipboard(const String &p_text) {
@@ -661,7 +664,7 @@ static String _get_model() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getModel);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static int _get_screen_dpi() {
@@ -674,7 +677,7 @@ static String _get_unique_id() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getUniqueID);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static void _show_vk(const String &p_existing) {
@@ -694,7 +697,7 @@ static String _get_system_dir(int p_dir) {
JNIEnv *env = ThreadAndroid::get_env();
jstring s = (jstring)env->CallObjectMethod(godot_io, _getSystemDir, p_dir);
- return String(env->GetStringUTFChars(s, NULL));
+ return jstring_to_string(s, env);
}
static int _get_gles_version_code() {
@@ -744,6 +747,12 @@ static void _alert(const String &p_message, const String &p_title) {
env->CallVoidMethod(_godot_instance, _alertDialog, jStrMessage, jStrTitle);
}
+static bool _request_permission(const String &p_name) {
+ JNIEnv *env = ThreadAndroid::get_env();
+ jstring jStrName = env->NewStringUTF(p_name.utf8().get_data());
+ return env->CallBooleanMethod(_godot_instance, _requestPermission, jStrName);
+}
+
// volatile because it can be changed from non-main thread and we need to
// ensure the change is immediately visible to other threads.
static volatile int virtual_keyboard_height;
@@ -756,7 +765,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHei
virtual_keyboard_height = p_height;
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jboolean p_need_reload_hook, jobject p_asset_manager, jboolean p_use_apk_expansion) {
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jobject p_asset_manager, jboolean p_use_apk_expansion) {
initialized = true;
@@ -782,11 +791,13 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
godot_io = gob;
_on_video_init = env->GetMethodID(cls, "onVideoInit", "()V");
+ _restart = env->GetMethodID(cls, "restart", "()V");
_setKeepScreenOn = env->GetMethodID(cls, "setKeepScreenOn", "(Z)V");
_alertDialog = env->GetMethodID(cls, "alert", "(Ljava/lang/String;Ljava/lang/String;)V");
_getGLESVersionCode = env->GetMethodID(cls, "getGLESVersionCode", "()I");
_getClipboard = env->GetMethodID(cls, "getClipboard", "()Ljava/lang/String;");
_setClipboard = env->GetMethodID(cls, "setClipboard", "(Ljava/lang/String;)V");
+ _requestPermission = env->GetMethodID(cls, "requestPermission", "(Ljava/lang/String;)Z");
if (cls) {
jclass c = env->GetObjectClass(gob);
@@ -819,8 +830,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
AudioDriverAndroid::setup(gob);
}
- os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_user_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _get_vk_height, _set_screen_orient, _get_unique_id, _get_system_dir, _get_gles_version_code, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, _set_clipboard, _get_clipboard, p_use_apk_expansion);
- os_android->set_need_reload_hooks(p_need_reload_hook);
+ os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_user_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _get_vk_height, _set_screen_orient, _get_unique_id, _get_system_dir, _get_gles_version_code, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, _set_clipboard, _get_clipboard, _request_permission, p_use_apk_expansion);
char wd[500];
getcwd(wd, 500);
@@ -831,7 +841,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
static void _initialize_java_modules() {
if (!ProjectSettings::get_singleton()->has_setting("android/modules")) {
- print_line("Android modules: Nothing to load, aborting");
return;
}
@@ -851,19 +860,16 @@ static void _initialize_java_modules() {
jmethodID getClassLoader = env->GetMethodID(activityClass, "getClassLoader", "()Ljava/lang/ClassLoader;");
jobject cls = env->CallObjectMethod(_godot_instance, getClassLoader);
- //cls=env->NewGlobalRef(cls);
jclass classLoader = env->FindClass("java/lang/ClassLoader");
- //classLoader=(jclass)env->NewGlobalRef(classLoader);
jmethodID findClass = env->GetMethodID(classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
for (int i = 0; i < mods.size(); i++) {
String m = mods[i];
- //jclass singletonClass = env->FindClass(m.utf8().get_data());
- print_line("Loading module: " + m);
+ print_line("Loading Android module: " + m);
jstring strClassName = env->NewStringUTF(m.utf8().get_data());
jclass singletonClass = (jclass)env->CallObjectMethod(cls, findClass, strClassName);
@@ -872,7 +878,6 @@ static void _initialize_java_modules() {
ERR_EXPLAIN("Couldn't find singleton for class: " + m);
ERR_CONTINUE(!singletonClass);
}
- //singletonClass=(jclass)env->NewGlobalRef(singletonClass);
jmethodID initialize = env->GetStaticMethodID(singletonClass, "initialize", "(Landroid/app/Activity;)Lorg/godotengine/godot/Godot$SingletonBase;");
@@ -891,12 +896,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo
ThreadAndroid::setup_thread();
const char **cmdline = NULL;
+ jstring *j_cmdline = NULL;
int cmdlen = 0;
if (p_cmdline) {
cmdlen = env->GetArrayLength(p_cmdline);
if (cmdlen) {
- cmdline = (const char **)malloc((env->GetArrayLength(p_cmdline) + 1) * sizeof(const char *));
+ cmdline = (const char **)malloc((cmdlen + 1) * sizeof(const char *));
cmdline[cmdlen] = NULL;
+ j_cmdline = (jstring *)malloc(cmdlen * sizeof(jstring));
for (int i = 0; i < cmdlen; i++) {
@@ -904,12 +911,19 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo
const char *rawString = env->GetStringUTFChars(string, 0);
cmdline[i] = rawString;
+ j_cmdline[i] = string;
}
}
}
Error err = Main::setup("apk", cmdlen, (char **)cmdline, false);
if (cmdline) {
+ if (j_cmdline) {
+ for (int i = 0; i < cmdlen; ++i) {
+ env->ReleaseStringUTFChars(j_cmdline[i], cmdline[i]);
+ }
+ free(j_cmdline);
+ }
free(cmdline);
}
@@ -922,7 +936,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo
_initialize_java_modules();
}
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height, jboolean reload) {
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height) {
if (os_android)
os_android->set_display_size(Size2(width, height));
@@ -931,12 +945,15 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, j
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits) {
if (os_android) {
- os_android->set_context_is_16_bits(!p_32_bits);
- }
-
- if (os_android && step > 0) {
-
- os_android->reload_gfx();
+ if (step == 0) {
+ // During startup
+ os_android->set_context_is_16_bits(!p_32_bits);
+ } else {
+ // GL context recreated because it was lost; restart app to let it reload everything
+ os_android->main_loop_end();
+ env->CallVoidMethod(_godot_instance, _restart);
+ step = -1; // Ensure no further steps are attempted
+ }
}
}
@@ -948,6 +965,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, job
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jobject obj) {
+ if (step == -1)
+ return;
+
if (step == 0) {
// Since Godot is initialized on the UI thread, _main_thread_id was set to that thread's id,
@@ -1313,7 +1333,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jobject obj, jint p_device, jboolean p_connected, jstring p_name) {
if (os_android) {
- String name = env->GetStringUTFChars(p_name, NULL);
+ String name = jstring_to_string(p_name, env);
os_android->joy_connection_changed(p_device, p_connected, name);
}
}
@@ -1386,7 +1406,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jo
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv *env, jobject obj, jstring name, jobject p_object) {
- String singname = env->GetStringUTFChars(name, NULL);
+ String singname = jstring_to_string(name, env);
JNISingleton *s = memnew(JNISingleton);
s->set_instance(env->NewGlobalRef(p_object));
jni_singletons[singname] = s;
@@ -1463,21 +1483,21 @@ static const char *get_jni_sig(const String &p_type) {
JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jobject obj, jstring path) {
- String js = env->GetStringUTFChars(path, NULL);
+ String js = jstring_to_string(path, env);
return env->NewStringUTF(ProjectSettings::get_singleton()->get(js).operator String().utf8().get_data());
}
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, jobject obj, jstring sname, jstring name, jstring ret, jobjectArray args) {
- String singname = env->GetStringUTFChars(sname, NULL);
+ String singname = jstring_to_string(sname, env);
ERR_FAIL_COND(!jni_singletons.has(singname));
JNISingleton *s = jni_singletons.get(singname);
- String mname = env->GetStringUTFChars(name, NULL);
- String retval = env->GetStringUTFChars(ret, NULL);
+ String mname = jstring_to_string(name, env);
+ String retval = jstring_to_string(ret, env);
Vector<Variant::Type> types;
String cs = "(";
@@ -1486,9 +1506,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, j
for (int i = 0; i < stringCount; i++) {
jstring string = (jstring)env->GetObjectArrayElement(args, i);
- const char *rawString = env->GetStringUTFChars(string, 0);
- types.push_back(get_jni_type(String(rawString)));
- cs += get_jni_sig(String(rawString));
+ const String rawString = jstring_to_string(string, env);
+ types.push_back(get_jni_type(rawString));
+ cs += get_jni_sig(rawString);
}
cs += ")";
@@ -1511,7 +1531,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *en
int res = env->PushLocalFrame(16);
ERR_FAIL_COND(res != 0);
- String str_method = env->GetStringUTFChars(method, NULL);
+ String str_method = jstring_to_string(method, env);
int count = env->GetArrayLength(params);
Variant *vlist = (Variant *)alloca(sizeof(Variant) * count);
@@ -1543,7 +1563,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
int res = env->PushLocalFrame(16);
ERR_FAIL_COND(res != 0);
- String str_method = env->GetStringUTFChars(method, NULL);
+ String str_method = jstring_to_string(method, env);
int count = env->GetArrayLength(params);
Variant args[VARIANT_ARG_MAX];
@@ -1561,6 +1581,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *
env->PopLocalFrame(NULL);
}
-//Main::cleanup();
-
-//return os.get_exit_code();
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jobject p_obj, jstring p_permission, jboolean p_result) {
+ String permission = jstring_to_string(p_permission, env);
+ if (permission == "android.permission.RECORD_AUDIO" && p_result) {
+ AudioDriver::get_singleton()->capture_start();
+ }
+}
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index e8d0d55bb3..3b93c9b42a 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -35,9 +35,9 @@
#include <jni.h>
extern "C" {
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jboolean p_need_reload_hook, jobject p_asset_manager, jboolean p_use_apk_expansion);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jobject p_asset_manager, jboolean p_use_apk_expansion);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jobject obj, jobjectArray p_cmdline);
-JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height, jboolean reload);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_resize(JNIEnv *env, jobject obj, jint width, jint height);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *env, jobject obj, bool p_32_bits);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jobject obj);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jobject obj);
@@ -60,6 +60,7 @@ JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params);
JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jobject obj, jint p_height);
+JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jobject p_obj, jstring p_permission, jboolean p_result);
}
#endif // JAVA_GLUE_H
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 3ba8468e0b..837713f9c9 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -131,7 +131,7 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
use_gl3 = false;
continue;
@@ -202,6 +202,12 @@ void OS_Android::alert(const String &p_alert, const String &p_title) {
alert_func(p_alert, p_title);
}
+bool OS_Android::request_permission(const String &p_name) {
+ if (request_permission_func)
+ return request_permission_func(p_name);
+ return false;
+}
+
Error OS_Android::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) {
p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW);
if (!p_library_handle) {
@@ -548,14 +554,6 @@ void OS_Android::set_display_size(Size2 p_size) {
default_videomode.height = p_size.y;
}
-void OS_Android::reload_gfx() {
-
- if (gfx_init_func)
- gfx_init_func(gfx_init_ud, use_gl2);
- //if (rasterizer)
- // rasterizer->reload_vram();
-}
-
Error OS_Android::shell_open(String p_uri) {
if (open_uri_func)
@@ -607,11 +605,6 @@ int OS_Android::get_screen_dpi(int p_screen) const {
return 160;
}
-void OS_Android::set_need_reload_hooks(bool p_needs_them) {
-
- use_reload_hooks = p_needs_them;
-}
-
String OS_Android::get_user_data_dir() const {
if (data_dir_cache != String())
@@ -706,7 +699,7 @@ String OS_Android::get_joy_guid(int p_device) const {
}
bool OS_Android::_check_internal_feature_support(const String &p_feature) {
- if (p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2") {
+ if (p_feature == "mobile") {
//TODO support etc2 only if GLES3 driver is selected
return true;
}
@@ -726,7 +719,7 @@ bool OS_Android::_check_internal_feature_support(const String &p_feature) {
return false;
}
-OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, GetGLVersionCodeFunc p_get_gl_version_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, SetClipboardFunc p_set_clipboard_func, GetClipboardFunc p_get_clipboard_func, bool p_use_apk_expansion) {
+OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, GetGLVersionCodeFunc p_get_gl_version_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, SetClipboardFunc p_set_clipboard_func, GetClipboardFunc p_get_clipboard_func, RequestPermissionFunc p_request_permission, bool p_use_apk_expansion) {
use_apk_expansion = p_use_apk_expansion;
default_videomode.width = 800;
@@ -765,7 +758,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI
set_screen_orientation_func = p_screen_orient;
set_keep_screen_on_func = p_set_keep_screen_on_func;
alert_func = p_alert_func;
- use_reload_hooks = false;
+ request_permission_func = p_request_permission;
Vector<Logger *> loggers;
loggers.push_back(memnew(AndroidLogger));
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 1e5b89e24d..44c5a206d4 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -63,6 +63,7 @@ typedef void (*VideoStopFunc)();
typedef void (*SetKeepScreenOnFunc)(bool p_enabled);
typedef void (*AlertFunc)(const String &, const String &);
typedef int (*VirtualKeyboardHeightFunc)();
+typedef bool (*RequestPermissionFunc)(const String &);
class OS_Android : public OS_Unix {
public:
@@ -94,7 +95,6 @@ private:
void *gfx_init_ud;
bool use_gl2;
- bool use_reload_hooks;
bool use_apk_expansion;
bool use_16bits_fbo;
@@ -133,6 +133,7 @@ private:
VideoStopFunc video_stop_func;
SetKeepScreenOnFunc set_keep_screen_on_func;
AlertFunc alert_func;
+ RequestPermissionFunc request_permission_func;
//PowerAndroid *power_manager;
int video_driver_index;
@@ -160,6 +161,7 @@ public:
static OS *get_singleton();
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");
+ virtual bool request_permission(const String &p_name);
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false);
@@ -203,10 +205,8 @@ public:
void set_opengl_extensions(const char *p_gl_extensions);
void set_display_size(Size2 p_size);
- void reload_gfx();
void set_context_is_16_bits(bool p_is_16);
- void set_need_reload_hooks(bool p_needs_them);
virtual void set_screen_orientation(ScreenOrientation p_orientation);
virtual Error shell_open(String p_uri);
@@ -241,7 +241,7 @@ public:
void joy_connection_changed(int p_device, bool p_connected, String p_name);
virtual bool _check_internal_feature_support(const String &p_feature);
- OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, GetGLVersionCodeFunc p_get_gl_version_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, SetClipboardFunc p_set_clipboard, GetClipboardFunc p_get_clipboard, bool p_use_apk_expansion);
+ OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, GetGLVersionCodeFunc p_get_gl_version_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, SetClipboardFunc p_set_clipboard, GetClipboardFunc p_get_clipboard, RequestPermissionFunc p_request_permission, bool p_use_apk_expansion);
~OS_Android();
};
diff --git a/platform/android/string_android.h b/platform/android/string_android.h
new file mode 100644
index 0000000000..fe627a3e0c
--- /dev/null
+++ b/platform/android/string_android.h
@@ -0,0 +1,58 @@
+/*************************************************************************/
+/* string_android.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef STRING_ANDROID_H
+#define STRING_ANDROID_H
+#include "core/ustring.h"
+#include "thread_jandroid.h"
+#include <jni.h>
+
+/**
+ * Converts JNI jstring to Godot String.
+ * @param source Source JNI string. If null an empty string is returned.
+ * @param env JNI environment instance. If null obtained by ThreadAndroid::get_env().
+ * @return Godot string instance.
+ */
+static inline String jstring_to_string(jstring source, JNIEnv *env = NULL) {
+ String result;
+ if (source) {
+ if (!env) {
+ env = ThreadAndroid::get_env();
+ }
+ const char *const source_utf8 = env->GetStringUTFChars(source, NULL);
+ if (source_utf8) {
+ result.parse_utf8(source_utf8);
+ env->ReleaseStringUTFChars(source, source_utf8);
+ }
+ }
+ return result;
+}
+
+#endif // STRING_ANDROID_H
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index a5b2e66a22..a6d5a00852 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -322,7 +322,7 @@ String OS_Haiku::get_executable_path() const {
bool OS_Haiku::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
String OS_Haiku::get_config_path() const {
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index bb0c11c767..64405bfa5b 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -598,8 +598,10 @@ static int frame_count = 0;
};
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
- OS::get_singleton()->get_main_loop()->notification(
- MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
+ if (OS::get_singleton()->get_main_loop()) {
+ OS::get_singleton()->get_main_loop()->notification(
+ MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
+ }
};
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@@ -613,18 +615,6 @@ static int frame_count = 0;
// Create a full-screen window
window = [[UIWindow alloc] initWithFrame:rect];
- // window.autoresizesSubviews = YES;
- //[window setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
- // UIViewAutoresizingFlexibleWidth];
-
- // Create the OpenGL ES view and add it to the window
- GLView *glView = [[GLView alloc] initWithFrame:rect];
- printf("glview is %p\n", glView);
- //[window addSubview:glView];
- glView.delegate = self;
- // glView.autoresizesSubviews = YES;
- //[glView setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
- // UIViewAutoresizingFlexibleWidth];
OS::VideoMode vm = _get_video_mode();
@@ -639,6 +629,12 @@ static int frame_count = 0;
return FALSE;
};
+ // WARNING: We must *always* create the GLView after we have constructed the
+ // OS with iphone_main. This allows the GLView to access project settings so
+ // it can properly initialize the OpenGL context
+ GLView *glView = [[GLView alloc] initWithFrame:rect];
+ glView.delegate = self;
+
view_controller = [[ViewController alloc] init];
view_controller.view = glView;
window.rootViewController = view_controller;
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index d0e6a4cefe..172572bcb4 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -174,11 +174,3 @@ def configure(env):
env.Append(CPPPATH=['#platform/iphone'])
env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DCOREAUDIO_ENABLED'])
-
- # TODO: Move that to opus module's config
- if 'module_opus_enabled' in env and env['module_opus_enabled']:
- env.opus_fixed_point = "yes"
- if (env["arch"] == "arm"):
- env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
- elif (env["arch"] == "arm64"):
- env.Append(CFLAGS=["-DOPUS_ARM64_OPT"])
diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp
index d234ddac27..85d4b9e847 100644
--- a/platform/iphone/export/export.cpp
+++ b/platform/iphone/export/export.cpp
@@ -196,15 +196,16 @@ public:
void EditorExportPlatformIOS::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- if (p_preset->get("texture_format/s3tc")) {
- r_features->push_back("s3tc");
- }
- if (p_preset->get("texture_format/etc")) {
+ String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
+ if (driver == "GLES2") {
r_features->push_back("etc");
- }
- if (p_preset->get("texture_format/etc2")) {
+ } else if (driver == "GLES3") {
r_features->push_back("etc2");
+ if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
+ r_features->push_back("etc");
+ }
}
+
Vector<String> architectures = _get_preset_architectures(p_preset);
for (int i = 0; i < architectures.size(); ++i) {
r_features->push_back(architectures[i]);
@@ -268,7 +269,6 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
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/microphone_usage_description"), "Godot would like to use your microphone"));
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::BOOL, "orientation/portrait"), true));
@@ -290,10 +290,6 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options)
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), ""));
}
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), true));
-
Vector<ExportArchitecture> architectures = _get_supported_architectures();
for (int i = 0; i < architectures.size(); ++i) {
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architectures/" + architectures[i].name), architectures[i].is_default));
@@ -402,9 +398,6 @@ 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";
@@ -846,6 +839,10 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
}
}
+ if (!DirAccess::exists(dest_dir)) {
+ return ERR_FILE_BAD_PATH;
+ }
+
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (da) {
String current_dir = da->get_current_dir();
@@ -1150,6 +1147,12 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset
}
}
+ String etc_error = test_etc2();
+ if (etc_error != String()) {
+ valid = false;
+ err += etc_error;
+ }
+
if (!err.empty())
r_error = err;
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 6f4d0ddb57..1cb8d0e44e 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -284,19 +284,37 @@ static void clear_touches() {
kEAGLColorFormatRGBA8,
kEAGLDrawablePropertyColorFormat,
nil];
+ bool fallback_gl2 = false;
+ // Create a GL ES 3 context based on the gl driver from project settings
+ if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3") {
+ context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
+ NSLog(@"Setting up an OpenGL ES 3.0 context. Based on Project Settings \"rendering/quality/driver/driver_name\"");
+ if (!context && GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
+ gles3_available = false;
+ fallback_gl2 = true;
+ NSLog(@"Failed to create OpenGL ES 3.0 context. Falling back to OpenGL ES 2.0");
+ }
+ }
- // Create our EAGLContext, and if successful make it current and create our framebuffer.
- context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
-
- if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
+ // Create GL ES 2 context
+ if (GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES2" || fallback_gl2) {
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
- gles3_available = false;
- if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
- [self release];
+ NSLog(@"Setting up an OpenGL ES 2.0 context.");
+ if (!context) {
+ NSLog(@"Failed to create OpenGL ES 2.0 context!");
return nil;
}
}
+ if (![EAGLContext setCurrentContext:context]) {
+ NSLog(@"Failed to set EAGLContext!");
+ return nil;
+ }
+ if (![self createFramebuffer]) {
+ NSLog(@"Failed to create frame buffer!");
+ return nil;
+ }
+
// Default the animation interval to 1/60th of a second.
animationInterval = 1.0 / 60.0;
return self;
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index c939e234b9..7d0fdd2078 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -120,7 +120,7 @@ Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
use_gl3 = false;
continue;
@@ -587,7 +587,7 @@ void OSIPhone::native_video_stop() {
bool OSIPhone::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "mobile" || p_feature == "etc" || p_feature == "pvrtc" || p_feature == "etc2";
+ return p_feature == "mobile";
}
// Initialization order between compilation units is not guaranteed,
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index 16fdc267f3..11104007e2 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -209,7 +209,7 @@ Error AudioDriverJavaScript::capture_start() {
}
function gotMediaInputError(e) {
- console.log(e);
+ out(e);
}
if (navigator.mediaDevices.getUserMedia) {
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index c3f3946ee0..47da8de5df 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -129,10 +129,6 @@ def configure(env):
# us since we don't know requirements at compile-time.
env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
- # Since we use both memory growth and MEMFS preloading,
- # this avoids unnecessary copying on start-up.
- env.Append(LINKFLAGS=['--no-heap-copy'])
-
# This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1.
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
@@ -140,7 +136,3 @@ def configure(env):
# TODO: Reevaluate usage of this setting now that engine.js manages engine runtime.
env.Append(LINKFLAGS=['-s', 'NO_EXIT_RUNTIME=1'])
-
- # TODO: Move that to opus module's config.
- if 'module_opus_enabled' in env and env['module_opus_enabled']:
- env.opus_fixed_point = 'yes'
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js
index 91458eb4c3..860d6707ff 100644
--- a/platform/javascript/engine.js
+++ b/platform/javascript/engine.js
@@ -199,7 +199,8 @@
}
LIBS.FS.mkdirTree(dir);
}
- LIBS.FS.createDataFile('/', file.path, new Uint8Array(file.buffer), true, true, true);
+ // With memory growth, canOwn should be false.
+ LIBS.FS.createDataFile(file.path, null, new Uint8Array(file.buffer), true, true, false);
}, this);
preloadedFiles = null;
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 123c6ae645..487da77b10 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -104,22 +104,27 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- if (p_preset->get("texture_format/s3tc")) {
+ if (p_preset->get("vram_texture_compression/for_desktop")) {
r_features->push_back("s3tc");
}
- if (p_preset->get("texture_format/etc")) {
- r_features->push_back("etc");
- }
- if (p_preset->get("texture_format/etc2")) {
- r_features->push_back("etc2");
+
+ if (p_preset->get("vram_texture_compression/for_mobile")) {
+ String driver = ProjectSettings::get_singleton()->get("rendering/quality/driver/driver_name");
+ if (driver == "GLES2") {
+ r_features->push_back("etc");
+ } else if (driver == "GLES3") {
+ r_features->push_back("etc2");
+ if (ProjectSettings::get_singleton()->get("rendering/quality/driver/fallback_to_gles2")) {
+ r_features->push_back("etc");
+ }
+ }
}
}
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false));
- r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_FILE, "*.html"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), ""));
@@ -167,10 +172,19 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p
}
}
+ r_missing_templates = !valid;
+
+ if (p_preset->get("vram_texture_compression/for_mobile")) {
+ String etc_error = test_etc2();
+ if (etc_error != String()) {
+ valid = false;
+ err += etc_error;
+ }
+ }
+
if (!err.empty())
r_error = err;
- r_missing_templates = !valid;
return valid;
}
@@ -200,6 +214,10 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
}
+ if (!DirAccess::exists(p_path.get_base_dir())) {
+ return ERR_FILE_BAD_PATH;
+ }
+
if (template_path != String() && !FileAccess::exists(template_path)) {
EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path);
return ERR_FILE_NOT_FOUND;
@@ -349,7 +367,7 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese
if (err) {
return err;
}
- OS::get_singleton()->shell_open(path);
+ OS::get_singleton()->shell_open(String("file://") + path);
return OK;
}
diff --git a/platform/javascript/http_request.js b/platform/javascript/http_request.js
index 7acd32d8bf..66dacfc3d4 100644
--- a/platform/javascript/http_request.js
+++ b/platform/javascript/http_request.js
@@ -82,7 +82,7 @@ var GodotHTTPRequest = {
godot_xhr_send_string: function(xhrId, strPtr) {
if (!strPtr) {
- console.warn("Failed to send string per XHR: null pointer");
+ err("Failed to send string per XHR: null pointer");
return;
}
GodotHTTPRequest.requests[xhrId].send(UTF8ToString(strPtr));
@@ -90,11 +90,11 @@ var GodotHTTPRequest = {
godot_xhr_send_data: function(xhrId, ptr, len) {
if (!ptr) {
- console.warn("Failed to send data per XHR: null pointer");
+ err("Failed to send data per XHR: null pointer");
return;
}
if (len < 0) {
- console.warn("Failed to send data per XHR: buffer length less than 0");
+ err("Failed to send data per XHR: buffer length less than 0");
return;
}
GodotHTTPRequest.requests[xhrId].send(HEAPU8.subarray(ptr, ptr + len));
diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp
index bb43e2d46b..dd3eba74e4 100644
--- a/platform/javascript/javascript_eval.cpp
+++ b/platform/javascript/javascript_eval.cpp
@@ -69,7 +69,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
eval_ret = eval(UTF8ToString(CODE));
}
} catch (e) {
- console.warn(e);
+ err(e);
eval_ret = null;
}
@@ -97,7 +97,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) {
if (array_ptr!==0) {
_free(array_ptr)
}
- console.warn(e);
+ err(e);
// fall through
}
break;
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index e820d07a2a..34781ce365 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -829,7 +829,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3 = false;
continue;
@@ -986,8 +986,8 @@ bool OS_JavaScript::main_loop_iterate() {
if (sync_wait_time < 0) {
/* clang-format off */
EM_ASM(
- FS.syncfs(function(err) {
- if (err) { console.warn('Failed to save IDB file system: ' + err.message); }
+ FS.syncfs(function(error) {
+ if (error) { err('Failed to save IDB file system: ' + error.message); }
});
);
/* clang-format on */
@@ -1071,16 +1071,6 @@ bool OS_JavaScript::_check_internal_feature_support(const String &p_feature) {
return true;
#endif
- EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
- // All extensions are already automatically enabled, this function allows
- // checking WebGL extension support without inline JavaScript
- if (p_feature == "s3tc")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_s3tc_srgb");
- if (p_feature == "etc")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc1");
- if (p_feature == "etc2")
- return emscripten_webgl_enable_extension(ctx, "WEBGL_compressed_texture_etc");
-
return false;
}
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index b8f6977b39..5e94bc457b 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -425,6 +425,10 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
}
+ if (!DirAccess::exists(p_path.get_base_dir())) {
+ return ERR_FILE_BAD_PATH;
+ }
+
FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 225e0aee06..7d2116ba7e 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -102,8 +102,6 @@ static void push_to_key_event_buffer(const OS_OSX::KeyEvent &p_event) {
static int mouse_x = 0;
static int mouse_y = 0;
-static int prev_mouse_x = 0;
-static int prev_mouse_y = 0;
static int button_mask = 0;
static bool mouse_down_control = false;
@@ -601,12 +599,13 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
Ref<InputEventMouseButton> mb;
mb.instance();
-
+ const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
+ const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
get_key_modifier_state([event modifierFlags], mb);
mb->set_button_index(index);
mb->set_pressed(pressed);
- mb->set_position(Vector2(mouse_x, mouse_y));
- mb->set_global_position(Vector2(mouse_x, mouse_y));
+ mb->set_position(pos);
+ mb->set_global_position(pos);
mb->set_button_mask(button_mask);
if (index == BUTTON_LEFT && pressed) {
mb->set_doubleclick([event clickCount] == 2);
@@ -642,8 +641,6 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
mm.instance();
mm->set_button_mask(button_mask);
- prev_mouse_x = mouse_x;
- prev_mouse_y = mouse_y;
const CGFloat backingScaleFactor = [[event window] backingScaleFactor];
const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor);
mm->set_position(pos);
@@ -765,9 +762,41 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
[super updateTrackingAreas];
}
+static bool isNumpadKey(unsigned int key) {
+
+ static const unsigned int table[] = {
+ 0x41, /* kVK_ANSI_KeypadDecimal */
+ 0x43, /* kVK_ANSI_KeypadMultiply */
+ 0x45, /* kVK_ANSI_KeypadPlus */
+ 0x47, /* kVK_ANSI_KeypadClear */
+ 0x4b, /* kVK_ANSI_KeypadDivide */
+ 0x4c, /* kVK_ANSI_KeypadEnter */
+ 0x4e, /* kVK_ANSI_KeypadMinus */
+ 0x51, /* kVK_ANSI_KeypadEquals */
+ 0x52, /* kVK_ANSI_Keypad0 */
+ 0x53, /* kVK_ANSI_Keypad1 */
+ 0x54, /* kVK_ANSI_Keypad2 */
+ 0x55, /* kVK_ANSI_Keypad3 */
+ 0x56, /* kVK_ANSI_Keypad4 */
+ 0x57, /* kVK_ANSI_Keypad5 */
+ 0x58, /* kVK_ANSI_Keypad6 */
+ 0x59, /* kVK_ANSI_Keypad7 */
+ 0x5b, /* kVK_ANSI_Keypad8 */
+ 0x5c, /* kVK_ANSI_Keypad9 */
+ 0x5f, /* kVK_JIS_KeypadComma */
+ 0x00
+ };
+ for (int i = 0; table[i] != 0; i++) {
+ if (key == table[i])
+ return true;
+ }
+ return false;
+}
+
// Translates a OS X keycode to a Godot keycode
//
static int translateKey(unsigned int key) {
+
// Keyboard symbol translation table
static const unsigned int table[128] = {
/* 00 */ KEY_A,
@@ -780,7 +809,7 @@ static int translateKey(unsigned int key) {
/* 07 */ KEY_X,
/* 08 */ KEY_C,
/* 09 */ KEY_V,
- /* 0a */ KEY_UNKNOWN,
+ /* 0a */ KEY_SECTION, /* ISO Section */
/* 0b */ KEY_B,
/* 0c */ KEY_Q,
/* 0d */ KEY_W,
@@ -834,7 +863,7 @@ static int translateKey(unsigned int key) {
/* 3d */ KEY_ALT,
/* 3e */ KEY_CONTROL,
/* 3f */ KEY_UNKNOWN, /* Function */
- /* 40 */ KEY_UNKNOWN,
+ /* 40 */ KEY_UNKNOWN, /* F17 */
/* 41 */ KEY_KP_PERIOD,
/* 42 */ KEY_UNKNOWN,
/* 43 */ KEY_KP_MULTIPLY,
@@ -842,16 +871,16 @@ static int translateKey(unsigned int key) {
/* 45 */ KEY_KP_ADD,
/* 46 */ KEY_UNKNOWN,
/* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */
- /* 48 */ KEY_UNKNOWN, /* VolumeUp */
- /* 49 */ KEY_UNKNOWN, /* VolumeDown */
- /* 4a */ KEY_UNKNOWN, /* Mute */
+ /* 48 */ KEY_VOLUMEUP, /* VolumeUp */
+ /* 49 */ KEY_VOLUMEDOWN, /* VolumeDown */
+ /* 4a */ KEY_VOLUMEMUTE, /* Mute */
/* 4b */ KEY_KP_DIVIDE,
/* 4c */ KEY_KP_ENTER,
/* 4d */ KEY_UNKNOWN,
/* 4e */ KEY_KP_SUBTRACT,
- /* 4f */ KEY_UNKNOWN,
- /* 50 */ KEY_UNKNOWN,
- /* 51 */ KEY_EQUAL, //wtf equal?
+ /* 4f */ KEY_UNKNOWN, /* F18 */
+ /* 50 */ KEY_UNKNOWN, /* F19 */
+ /* 51 */ KEY_EQUAL, /* KeypadEqual */
/* 52 */ KEY_KP_0,
/* 53 */ KEY_KP_1,
/* 54 */ KEY_KP_2,
@@ -860,27 +889,27 @@ static int translateKey(unsigned int key) {
/* 57 */ KEY_KP_5,
/* 58 */ KEY_KP_6,
/* 59 */ KEY_KP_7,
- /* 5a */ KEY_UNKNOWN,
+ /* 5a */ KEY_UNKNOWN, /* F20 */
/* 5b */ KEY_KP_8,
/* 5c */ KEY_KP_9,
- /* 5d */ KEY_UNKNOWN,
- /* 5e */ KEY_UNKNOWN,
- /* 5f */ KEY_UNKNOWN,
+ /* 5d */ KEY_YEN, /* JIS Yen */
+ /* 5e */ KEY_UNDERSCORE, /* JIS Underscore */
+ /* 5f */ KEY_COMMA, /* JIS KeypadComma */
/* 60 */ KEY_F5,
/* 61 */ KEY_F6,
/* 62 */ KEY_F7,
/* 63 */ KEY_F3,
/* 64 */ KEY_F8,
/* 65 */ KEY_F9,
- /* 66 */ KEY_UNKNOWN,
+ /* 66 */ KEY_UNKNOWN, /* JIS Eisu */
/* 67 */ KEY_F11,
- /* 68 */ KEY_UNKNOWN,
+ /* 68 */ KEY_UNKNOWN, /* JIS Kana */
/* 69 */ KEY_F13,
/* 6a */ KEY_F16,
/* 6b */ KEY_F14,
/* 6c */ KEY_UNKNOWN,
/* 6d */ KEY_F10,
- /* 6e */ KEY_UNKNOWN,
+ /* 6e */ KEY_MENU,
/* 6f */ KEY_F12,
/* 70 */ KEY_UNKNOWN,
/* 71 */ KEY_F15,
@@ -971,6 +1000,9 @@ static const _KeyCodeMap _keycodes[55] = {
static int remapKey(unsigned int key) {
+ if (isNumpadKey(key))
+ return translateKey(key);
+
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
if (!currentKeyboard)
return translateKey(key);
@@ -1096,6 +1128,7 @@ static int remapKey(unsigned int key) {
inline void sendScrollEvent(int button, double factor, int modifierFlags) {
unsigned int mask = 1 << (button - 1);
+ Vector2 mouse_pos = Vector2(mouse_x, mouse_y);
Ref<InputEventMouseButton> sc;
sc.instance();
@@ -1104,14 +1137,18 @@ inline void sendScrollEvent(int button, double factor, int modifierFlags) {
sc->set_button_index(button);
sc->set_factor(factor);
sc->set_pressed(true);
- Vector2 mouse_pos = Vector2(mouse_x, mouse_y);
sc->set_position(mouse_pos);
sc->set_global_position(mouse_pos);
button_mask |= mask;
sc->set_button_mask(button_mask);
OS_OSX::singleton->push_input(sc);
+ sc.instance();
+ sc->set_button_index(button);
+ sc->set_factor(factor);
sc->set_pressed(false);
+ sc->set_position(mouse_pos);
+ sc->set_global_position(mouse_pos);
button_mask &= ~mask;
sc->set_button_mask(button_mask);
OS_OSX::singleton->push_input(sc);
@@ -1420,7 +1457,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3 = false;
continue;
@@ -2233,12 +2270,12 @@ Size2 OS_OSX::get_window_size() const {
Size2 OS_OSX::get_real_window_size() const {
NSRect frame = [window_object frame];
- return Size2(frame.size.width, frame.size.height);
+ return Size2(frame.size.width, frame.size.height) * _display_scale();
}
void OS_OSX::set_window_size(const Size2 p_size) {
- Size2 size = p_size;
+ Size2 size = p_size / _display_scale();
if (get_borderless_window() == false) {
// NSRect used by setFrame includes the title bar, so add it to our size.y
@@ -2324,7 +2361,8 @@ bool OS_OSX::is_window_maximized() const {
void OS_OSX::move_window_to_foreground() {
- [window_object orderFrontRegardless];
+ [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
+ [window_object makeKeyAndOrderFront:nil];
}
void OS_OSX::set_window_always_on_top(bool p_enabled) {
@@ -2528,6 +2566,8 @@ void OS_OSX::process_events() {
[autoreleasePool drain];
autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ input->flush_accumulated_events();
}
void OS_OSX::process_key_events() {
@@ -2570,7 +2610,7 @@ void OS_OSX::process_key_events() {
void OS_OSX::push_input(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event;
- input->parse_input_event(ev);
+ input->accumulate_input_event(ev);
}
void OS_OSX::force_process_input() {
@@ -2811,7 +2851,7 @@ OS_OSX::OS_OSX() {
}
bool OS_OSX::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
void OS_OSX::disable_crash_handler() {
diff --git a/platform/server/detect.py b/platform/server/detect.py
index 392a987ee9..90a4092412 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -1,7 +1,10 @@
import os
import platform
import sys
+from methods import get_compiler_version, use_gcc
+# This file is mostly based on platform/x11/detect.py.
+# If editing this file, make sure to apply relevant changes here too.
def is_active():
return True
@@ -26,10 +29,16 @@ def can_build():
def get_opts():
- from SCons.Variables import BoolVariable
+ from SCons.Variables import BoolVariable, EnumVariable
return [
BoolVariable('use_llvm', 'Use the LLVM compiler', False),
BoolVariable('use_static_cpp', 'Link libgcc and libstdc++ statically for better portability', False),
+ BoolVariable('use_ubsan', 'Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)', False),
+ BoolVariable('use_asan', 'Use LLVM/GCC compiler address sanitizer (ASAN))', False),
+ BoolVariable('use_lsan', 'Use LLVM/GCC compiler leak sanitizer (LSAN))', False),
+ EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')),
+ BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False),
+ BoolVariable('execinfo', 'Use libexecinfo on systems where glibc is not available', False),
]
@@ -43,13 +52,30 @@ def configure(env):
## Build type
if (env["target"] == "release"):
- env.Append(CCFLAGS=['-O2', '-fomit-frame-pointer'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Prepend(CCFLAGS=['-O3'])
+ else: #optimize for size
+ env.Prepend(CCFLAGS=['-Os'])
+
+ if (env["debug_symbols"] == "yes"):
+ env.Prepend(CCFLAGS=['-g1'])
+ if (env["debug_symbols"] == "full"):
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
+ if (env["optimize"] == "speed"): #optimize for speed (default)
+ env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
+ else: #optimize for size
+ env.Prepend(CCFLAGS=['-Os', '-DDEBUG_ENABLED'])
+
+ if (env["debug_symbols"] == "yes"):
+ env.Prepend(CCFLAGS=['-g1'])
+ if (env["debug_symbols"] == "full"):
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Prepend(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(LINKFLAGS=['-rdynamic'])
## Architecture
@@ -59,6 +85,10 @@ def configure(env):
## Compiler configuration
+ if 'CXX' in env and 'clang' in os.path.basename(env['CXX']):
+ # Convenience check to enforce the use_llvm overrides when CXX is clang(++)
+ env['use_llvm'] = True
+
if env['use_llvm']:
if ('clang++' not in os.path.basename(env['CXX'])):
env["CC"] = "clang"
@@ -67,6 +97,35 @@ def configure(env):
env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND'])
env.extra_suffix = ".llvm" + env.extra_suffix
+
+ if env['use_ubsan'] or env['use_asan'] or env['use_lsan']:
+ env.extra_suffix += "s"
+
+ 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_lto']:
+ env.Append(CCFLAGS=['-flto'])
+ if not env['use_llvm'] and env.GetOption("num_jobs") > 1:
+ env.Append(LINKFLAGS=['-flto=' + str(env.GetOption("num_jobs"))])
+ else:
+ env.Append(LINKFLAGS=['-flto'])
+ if not env['use_llvm']:
+ env['RANLIB'] = 'gcc-ranlib'
+ env['AR'] = 'gcc-ar'
+
+ env.Append(CCFLAGS=['-pipe'])
+ env.Append(LINKFLAGS=['-pipe'])
+
## Dependencies
# FIXME: Check for existence of the libs before parsing their flags with pkg-config
@@ -110,6 +169,10 @@ def configure(env):
env['builtin_libogg'] = False # Needed to link against system libtheora
env['builtin_libvorbis'] = False # Needed to link against system libtheora
env.ParseConfig('pkg-config theora theoradec --cflags --libs')
+ else:
+ list_of_x86 = ['x86_64', 'x86', 'i386', 'i586']
+ if any(platform.machine() in s for s in list_of_x86):
+ env["x86_libtheora_opt_gcc"] = True
if not env['builtin_libvpx']:
env.ParseConfig('pkg-config vpx --cflags --libs')
@@ -163,6 +226,9 @@ def configure(env):
env.Append(LIBS=['dl'])
if (platform.system().find("BSD") >= 0):
+ env["execinfo"] = True
+
+ if env["execinfo"]:
env.Append(LIBS=['execinfo'])
# Link those statically for portability
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index a4655117a7..8ccf122d9f 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -1265,6 +1265,10 @@ public:
}
}
+ if (!DirAccess::exists(p_path.get_base_dir())) {
+ return ERR_FILE_BAD_PATH;
+ }
+
Error err = OK;
FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 520e179611..bc74da8a1b 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -202,7 +202,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
memdelete(gl_context);
gl_context = NULL;
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@@ -224,7 +224,7 @@ Error OS_UWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best") {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
p_video_driver = VIDEO_DRIVER_GLES2;
opengl_api_type = ContextEGL_UWP::GLES_2_0;
continue;
@@ -889,7 +889,7 @@ String OS_UWP::get_user_data_dir() const {
}
bool OS_UWP::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc";
+ return p_feature == "pc";
}
OS::PowerState OS_UWP::get_power_state() {
diff --git a/platform/windows/godot.natvis b/platform/windows/godot.natvis
index 01963035a1..55c83c3f3c 100644
--- a/platform/windows/godot.natvis
+++ b/platform/windows/godot.natvis
@@ -2,92 +2,109 @@
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="Vector&lt;*&gt;">
<Expand>
- <Item Name="size">(_cowdata &amp;&amp; _cowdata-&gt;_ptr) ? (((const unsigned int *)(_cowdata-&gt;_ptr))[-1]) : 0</Item>
+ <Item Name="[size]">_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Item>
<ArrayItems>
- <Size>(_cowdata &amp;&amp; _cowdata-&gt;_ptr) ? (((const unsigned int *)(_cowdata-&gt;_ptr))[-1]) : 0</Size>
- <ValuePointer>(_cowdata) ? (_cowdata-&gt;_ptr) : 0</ValuePointer>
+ <Size>_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Size>
+ <ValuePointer>_cowdata._ptr</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="PoolVector&lt;*&gt;">
<Expand>
- <Item Name="size">alloc ? (alloc-&gt;size / sizeof($T1)) : 0</Item>
+ <Item Name="[size]">alloc ? (alloc-&gt;size / sizeof($T1)) : 0</Item>
<ArrayItems>
<Size>alloc ? (alloc-&gt;size / sizeof($T1)) : 0</Size>
<ValuePointer>alloc ? (($T1 *)alloc-&gt;mem) : 0</ValuePointer>
</ArrayItems>
</Expand>
</Type>
+
+ <Type Name="List&lt;*&gt;">
+ <Expand>
+ <Item Name="[size]">_data ? (_data->size_cache) : 0</Item>
+ <LinkedListItems>
+ <Size>_data ? (_data->size_cache) : 0</Size>
+ <HeadPointer>_data->first</HeadPointer>
+ <NextPointer>next_ptr</NextPointer>
+ <ValueNode>value</ValueNode>
+ </LinkedListItems>
+ </Expand>
+ </Type>
<Type Name="Variant">
- <DisplayString Condition="this-&gt;type == Variant::NIL">nil</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::BOOL">{_data._bool}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::INT">{_data._int}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::REAL">{_data._real}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::AABB">{_data._aabb}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::BASIS">{_data._basis}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::TRANSFORM">{_data._transform}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::STRING &amp;&amp; ((String *)(&amp;_data._mem[0]))-&gt;_cowdata._ptr == 0">""</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::STRING &amp;&amp; ((String *)(&amp;_data._mem[0]))-&gt;_cowdata._ptr != 0">{((String *)(&amp;_data._mem[0]))-&gt;_cowdata._ptr,su}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::_RID">{*(RID *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_BYTE_ARRAY">{*(PoolByteArray *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_INT_ARRAY">{*(PoolIntArray *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_REAL_ARRAY">{*(PoolRealArray *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_STRING_ARRAY">{*(PoolStringArray *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_VECTOR2_ARRAY">{*(PoolVector2Array *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_VECTOR3_ARRAY">{*(PoolVector3Array *)_data._mem}</DisplayString>
- <DisplayString Condition="this-&gt;type == Variant::POOL_COLOR_ARRAY">{*(PoolColorArray *)_data._mem}</DisplayString>
-
- <StringView Condition="this-&gt;type == Variant::STRING &amp;&amp; ((String *)(&amp;_data._mem[0]))-&gt;_cowdata._ptr != 0">((String *)(&amp;_data._mem[0]))-&gt;_cowdata._ptr,su</StringView>
+ <DisplayString Condition="type == Variant::NIL">nil</DisplayString>
+ <DisplayString Condition="type == Variant::BOOL">{_data._bool}</DisplayString>
+ <DisplayString Condition="type == Variant::INT">{_data._int}</DisplayString>
+ <DisplayString Condition="type == Variant::REAL">{_data._real}</DisplayString>
+ <DisplayString Condition="type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString>
+ <DisplayString Condition="type == Variant::AABB">{_data._aabb}</DisplayString>
+ <DisplayString Condition="type == Variant::BASIS">{_data._basis}</DisplayString>
+ <DisplayString Condition="type == Variant::TRANSFORM">{_data._transform}</DisplayString>
+ <DisplayString Condition="type == Variant::STRING">{*(String *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::QUAT">{*(Quat *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::_RID">{*(RID *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_BYTE_ARRAY">{*(PoolByteArray *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_INT_ARRAY">{*(PoolIntArray *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_REAL_ARRAY">{*(PoolRealArray *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_STRING_ARRAY">{*(PoolStringArray *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_VECTOR2_ARRAY">{*(PoolVector2Array *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_VECTOR3_ARRAY">{*(PoolVector3Array *)_data._mem}</DisplayString>
+ <DisplayString Condition="type == Variant::POOL_COLOR_ARRAY">{*(PoolColorArray *)_data._mem}</DisplayString>
+ <StringView Condition="type == Variant::STRING &amp;&amp; ((String *)(_data._mem))->_cowdata._ptr">((String *)(_data._mem))->_cowdata._ptr,su</StringView>
+
<Expand>
- <Item Name="value" Condition="this-&gt;type == Variant::BOOL">_data._bool</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::INT">_data._int</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::REAL">_data._real</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::TRANSFORM2D">_data._transform2d</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::AABB">_data._aabb</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::BASIS">_data._basis</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::TRANSFORM">_data._transform</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::ARRAY">*(Array *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::STRING">*(String *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::RECT2">*(Rect2 *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::PLANE">*(Plane *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::QUAT">*(Quat *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::COLOR">*(Color *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::_RID">*(RID *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::OBJECT">*(Object *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::ARRAY">*(Array *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_BYTE_ARRAY">*(PoolByteArray *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_INT_ARRAY">*(PoolIntArray *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_REAL_ARRAY">*(PoolRealArray *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_STRING_ARRAY">*(PoolStringArray *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_VECTOR2_ARRAY">*(PoolVector2Array *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_VECTOR3_ARRAY">*(PoolVector3Array *)_data._mem</Item>
- <Item Name="value" Condition="this-&gt;type == Variant::POOL_COLOR_ARRAY">*(PoolColorArray *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::BOOL">_data._bool</Item>
+ <Item Name="[value]" Condition="type == Variant::INT">_data._int</Item>
+ <Item Name="[value]" Condition="type == Variant::REAL">_data._real</Item>
+ <Item Name="[value]" Condition="type == Variant::TRANSFORM2D">_data._transform2d</Item>
+ <Item Name="[value]" Condition="type == Variant::AABB">_data._aabb</Item>
+ <Item Name="[value]" Condition="type == Variant::BASIS">_data._basis</Item>
+ <Item Name="[value]" Condition="type == Variant::TRANSFORM">_data._transform</Item>
+ <Item Name="[value]" Condition="type == Variant::STRING">*(String *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::RECT2">*(Rect2 *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::PLANE">*(Plane *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::QUAT">*(Quat *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::COLOR">*(Color *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::_RID">*(RID *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::OBJECT">*(Object *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::ARRAY">*(Array *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_BYTE_ARRAY">*(PoolByteArray *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_INT_ARRAY">*(PoolIntArray *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_REAL_ARRAY">*(PoolRealArray *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_STRING_ARRAY">*(PoolStringArray *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_VECTOR2_ARRAY">*(PoolVector2Array *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_VECTOR3_ARRAY">*(PoolVector3Array *)_data._mem</Item>
+ <Item Name="[value]" Condition="type == Variant::POOL_COLOR_ARRAY">*(PoolColorArray *)_data._mem</Item>
</Expand>
</Type>
<Type Name="String">
- <DisplayString Condition="this-&gt;_cowdata._ptr == 0">empty</DisplayString>
- <DisplayString Condition="this-&gt;_cowdata._ptr != 0">{this->_cowdata._ptr,su}</DisplayString>
- <StringView Condition="this-&gt;_cowdata._ptr != 0">this->_cowdata._ptr,su</StringView>
+ <DisplayString Condition="_cowdata._ptr == 0">[empty]</DisplayString>
+ <DisplayString Condition="_cowdata._ptr != 0">{_cowdata._ptr,su}</DisplayString>
+ <StringView Condition="_cowdata._ptr != 0">_cowdata._ptr,su</StringView>
+ </Type>
+
+ <Type Name="StringName">
+ <DisplayString Condition="_data &amp;&amp; _data->cname">{_data->cname}</DisplayString>
+ <DisplayString Condition="_data &amp;&amp; !_data->cname">{_data->name,su}</DisplayString>
+ <DisplayString Condition="!_data">[empty]</DisplayString>
+ <StringView Condition="_data &amp;&amp; _data->cname">_data->cname</StringView>
+ <StringView Condition="_data &amp;&amp; !_data->cname">_data->name,su</StringView>
</Type>
<Type Name="Vector2">
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 9f15e7aad7..6125455e74 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -271,7 +271,7 @@ void OS_Windows::_touch_event(bool p_pressed, float p_x, float p_y, int idx) {
event->set_position(Vector2(p_x, p_y));
if (main_loop) {
- input->parse_input_event(event);
+ input->accumulate_input_event(event);
}
};
@@ -293,11 +293,21 @@ void OS_Windows::_drag_event(float p_x, float p_y, int idx) {
event->set_position(Vector2(p_x, p_y));
if (main_loop)
- input->parse_input_event(event);
+ input->accumulate_input_event(event);
};
LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
+ if (drop_events) {
+
+ if (user_proc) {
+
+ return CallWindowProcW(user_proc, hWnd, uMsg, wParam, lParam);
+ } else {
+ return DefWindowProcW(hWnd, uMsg, wParam, lParam);
+ }
+ };
+
switch (uMsg) // Check For Windows Messages
{
case WM_SETFOCUS: {
@@ -448,7 +458,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
if (window_has_focus && main_loop && mm->get_relative() != Vector2())
- input->parse_input_event(mm);
+ input->accumulate_input_event(mm);
}
delete[] lpb;
} break;
@@ -535,7 +545,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
old_x = mm->get_position().x;
old_y = mm->get_position().y;
if (window_has_focus && main_loop)
- input->parse_input_event(mm);
+ input->accumulate_input_event(mm);
} break;
case WM_LBUTTONDOWN:
@@ -708,14 +718,14 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
mb->set_global_position(mb->get_position());
if (main_loop) {
- input->parse_input_event(mb);
+ input->accumulate_input_event(mb);
if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) {
//send release for mouse wheel
Ref<InputEventMouseButton> mbd = mb->duplicate();
last_button_state &= ~(1 << (mbd->get_button_index() - 1));
mbd->set_button_mask(last_button_state);
mbd->set_pressed(false);
- input->parse_input_event(mbd);
+ input->accumulate_input_event(mbd);
}
}
} break;
@@ -978,7 +988,7 @@ void OS_Windows::process_key_events() {
if (k->get_unicode() < 32)
k->set_unicode(0);
- input->parse_input_event(k);
+ input->accumulate_input_event(k);
}
//do nothing
@@ -1016,7 +1026,7 @@ void OS_Windows::process_key_events() {
k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30))));
- input->parse_input_event(k);
+ input->accumulate_input_event(k);
} break;
}
@@ -1280,7 +1290,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
memdelete(gl_context);
gl_context = NULL;
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@@ -1302,7 +1312,7 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
gles3_context = false;
continue;
@@ -1395,6 +1405,8 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
+ update_real_mouse_position();
+
return OK;
}
@@ -1596,6 +1608,19 @@ Point2 OS_Windows::get_mouse_position() const {
return Point2(old_x, old_y);
}
+void OS_Windows::update_real_mouse_position() {
+
+ POINT mouse_pos;
+ if (GetCursorPos(&mouse_pos) && ScreenToClient(hWnd, &mouse_pos)) {
+ if (mouse_pos.x > 0 && mouse_pos.y > 0 && mouse_pos.x <= video_mode.width && mouse_pos.y <= video_mode.height) {
+ old_x = mouse_pos.x;
+ old_y = mouse_pos.y;
+ old_invalid = false;
+ input->set_mouse_position(Point2i(mouse_pos.x, mouse_pos.y));
+ }
+ }
+}
+
int OS_Windows::get_mouse_button_state() const {
return last_button_state;
@@ -1738,6 +1763,7 @@ void OS_Windows::set_window_position(const Point2 &p_position) {
}
last_pos = p_position;
+ update_real_mouse_position();
}
Size2 OS_Windows::get_window_size() const {
@@ -2214,7 +2240,9 @@ void OS_Windows::process_events() {
MSG msg;
- joypad->process_joypads();
+ if (!drop_events) {
+ joypad->process_joypads();
+ }
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
@@ -2222,7 +2250,10 @@ void OS_Windows::process_events() {
DispatchMessageW(&msg);
}
- process_key_events();
+ if (!drop_events) {
+ process_key_events();
+ input->flush_accumulated_events();
+ }
}
void OS_Windows::set_cursor_shape(CursorShape p_shape) {
@@ -2960,7 +2991,7 @@ int OS_Windows::get_power_percent_left() {
bool OS_Windows::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc";
+ return p_feature == "pc";
}
void OS_Windows::disable_crash_handler() {
@@ -2971,6 +3002,13 @@ bool OS_Windows::is_disable_crash_handler() const {
return crash_handler.is_disabled();
}
+void OS_Windows::process_and_drop_events() {
+
+ drop_events = true;
+ process_events();
+ drop_events = false;
+}
+
Error OS_Windows::move_to_trash(const String &p_path) {
SHFILEOPSTRUCTW sf;
WCHAR *from = new WCHAR[p_path.length() + 2];
@@ -2999,6 +3037,7 @@ Error OS_Windows::move_to_trash(const String &p_path) {
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
+ drop_events = false;
key_event_pos = 0;
layered_window = false;
hBitmap = NULL;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index e27dbbe530..2d03532c69 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -127,6 +127,7 @@ class OS_Windows : public OS {
bool window_has_focus;
uint32_t last_button_state;
bool use_raw_input;
+ bool drop_events;
HCURSOR cursors[CURSOR_MAX] = { NULL };
CursorShape cursor_shape;
@@ -197,6 +198,7 @@ public:
virtual void warp_mouse_position(const Point2 &p_to);
virtual Point2 get_mouse_position() const;
+ void update_real_mouse_position();
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
@@ -329,6 +331,8 @@ public:
virtual Error move_to_trash(const String &p_path);
+ virtual void process_and_drop_events();
+
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();
};
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 72139538b7..b5ad59e60a 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -2,7 +2,7 @@ import os
import platform
import sys
from compat import decode_utf8
-
+from methods import get_compiler_version, use_gcc
def is_active():
return True
@@ -20,12 +20,10 @@ def can_build():
# Check the minimal dependencies
x11_error = os.system("pkg-config --version > /dev/null")
if (x11_error):
- print("pkg-config not found.. x11 disabled.")
return False
x11_error = os.system("pkg-config x11 --modversion > /dev/null ")
if (x11_error):
- print("X11 not found.. x11 disabled.")
return False
x11_error = os.system("pkg-config xcursor --modversion > /dev/null ")
@@ -161,16 +159,10 @@ def configure(env):
env.Append(CCFLAGS=['-pipe'])
env.Append(LINKFLAGS=['-pipe'])
- # Check for gcc version > 5 before adding -no-pie
- import re
- import subprocess
- proc = subprocess.Popen([env['CXX'], '--version'], stdout=subprocess.PIPE)
- (stdout, _) = proc.communicate()
- stdout = decode_utf8(stdout)
- match = re.search('[0-9][0-9.]*', stdout)
- if match is not None:
- version = match.group().split('.')
- if (version[0] > '5'):
+ # Check for gcc version >= 6 before adding -no-pie
+ if use_gcc(env):
+ version = get_compiler_version(env)
+ if version != None and version[0] >= '6':
env.Append(CCFLAGS=['-fpie'])
env.Append(LINKFLAGS=['-no-pie'])
diff --git a/platform/x11/detect_prime.cpp b/platform/x11/detect_prime.cpp
index 04a825fac9..0fde2a0c04 100644
--- a/platform/x11/detect_prime.cpp
+++ b/platform/x11/detect_prime.cpp
@@ -180,8 +180,8 @@ int detect_prime() {
const char *vendor = (const char *)glGetString(GL_VENDOR);
const char *renderer = (const char *)glGetString(GL_RENDERER);
- int vendor_len = strlen(vendor) + 1;
- int renderer_len = strlen(renderer) + 1;
+ unsigned int vendor_len = strlen(vendor) + 1;
+ unsigned int renderer_len = strlen(renderer) + 1;
if (vendor_len + renderer_len >= sizeof(string)) {
renderer_len = 200 - vendor_len;
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index 907c652ab4..c4dd8fe0e0 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -367,12 +367,12 @@ void JoypadLinux::open_joypad(const char *p_path) {
joy.fd = fd;
joy.devpath = String(p_path);
setup_joypad_properties(joy_num);
- sprintf(uid, "%04x%04x", __bswap_16(inpid.bustype), 0);
+ sprintf(uid, "%04x%04x", BSWAP16(inpid.bustype), 0);
if (inpid.vendor && inpid.product && inpid.version) {
- uint16_t vendor = __bswap_16(inpid.vendor);
- uint16_t product = __bswap_16(inpid.product);
- uint16_t version = __bswap_16(inpid.version);
+ uint16_t vendor = BSWAP16(inpid.vendor);
+ uint16_t product = BSWAP16(inpid.product);
+ uint16_t version = BSWAP16(inpid.version);
sprintf(uid + String(uid).length(), "%04x%04x%04x%04x%04x%04x", vendor, 0, product, 0, version, 0);
input->joy_connection_changed(joy_num, true, name, uid);
@@ -476,7 +476,7 @@ void JoypadLinux::process_joypads() {
// ev may be tainted and out of MAX_KEY range, which will cause
// joy->key_map[ev.code] to crash
- if (ev.code < 0 || ev.code >= MAX_KEY)
+ if (ev.code >= MAX_KEY)
return;
switch (ev.type) {
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 8db4635d68..0fe91f3d00 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -299,7 +299,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
memdelete(context_gl);
context_gl = NULL;
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
if (p_video_driver == VIDEO_DRIVER_GLES2) {
gl_initialization_error = true;
break;
@@ -321,7 +321,7 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
RasterizerGLES3::make_current();
break;
} else {
- if (GLOBAL_GET("rendering/quality/driver/driver_fallback") == "Best" || editor) {
+ if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2") || editor) {
p_video_driver = VIDEO_DRIVER_GLES2;
opengl_api_type = ContextGL_X11::GLES_2_0_COMPATIBLE;
continue;
@@ -1660,7 +1660,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
k->set_shift(true);
}
- input->parse_input_event(k);
+ input->accumulate_input_event(k);
}
return;
}
@@ -1743,7 +1743,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// is correct, but the xorg developers are
// not very helpful today.
- ::Time tresh = ABS(peek_event.xkey.time - xkeyevent->time);
+ ::Time tresh = ABSDIFF(peek_event.xkey.time, xkeyevent->time);
if (peek_event.type == KeyPress && tresh < 5) {
KeySym rk;
XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, NULL);
@@ -1804,7 +1804,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
}
//printf("key: %x\n",k->get_scancode());
- input->parse_input_event(k);
+ input->accumulate_input_event(k);
}
struct Property {
@@ -1991,12 +1991,12 @@ void OS_X11::process_xevents() {
// in a spurious mouse motion event being sent to Godot; remember it to be able to filter it out
xi.mouse_pos_to_filter = pos;
}
- input->parse_input_event(st);
+ input->accumulate_input_event(st);
} else {
if (!xi.state.has(index)) // Defensive
break;
xi.state.erase(index);
- input->parse_input_event(st);
+ input->accumulate_input_event(st);
}
} break;
@@ -2014,7 +2014,7 @@ void OS_X11::process_xevents() {
sd->set_index(index);
sd->set_position(pos);
sd->set_relative(pos - curr_pos_elem->value());
- input->parse_input_event(sd);
+ input->accumulate_input_event(sd);
curr_pos_elem->value() = pos;
}
@@ -2102,7 +2102,7 @@ void OS_X11::process_xevents() {
st.instance();
st->set_index(E->key());
st->set_position(E->get());
- input->parse_input_event(st);
+ input->accumulate_input_event(st);
}
xi.state.clear();
#endif
@@ -2163,7 +2163,7 @@ void OS_X11::process_xevents() {
}
}
- input->parse_input_event(mb);
+ input->accumulate_input_event(mb);
} break;
case MotionNotify: {
@@ -2273,7 +2273,7 @@ void OS_X11::process_xevents() {
// this is so that the relative motion doesn't get messed up
// after we regain focus.
if (window_has_focus || !mouse_mode_grab)
- input->parse_input_event(mm);
+ input->accumulate_input_event(mm);
} break;
case KeyPress:
@@ -2355,7 +2355,7 @@ void OS_X11::process_xevents() {
Vector<String> files = String((char *)p.data).split("\n", false);
for (int i = 0; i < files.size(); i++) {
- files.write[i] = files[i].replace("file://", "").replace("%20", " ").strip_escapes();
+ files.write[i] = files[i].replace("file://", "").http_unescape().strip_escapes();
}
main_loop->drop_files(files);
@@ -2457,6 +2457,8 @@ void OS_X11::process_xevents() {
printf("Win: %d,%d\n", win_x, win_y);
*/
}
+
+ input->flush_accumulated_events();
}
MainLoop *OS_X11::get_main_loop() const {
@@ -2593,7 +2595,7 @@ Error OS_X11::shell_open(String p_uri) {
bool OS_X11::_check_internal_feature_support(const String &p_feature) {
- return p_feature == "pc" || p_feature == "s3tc" || p_feature == "bptc";
+ return p_feature == "pc";
}
String OS_X11::get_config_path() const {
@@ -3046,11 +3048,12 @@ void OS_X11::set_context(int p_context) {
if (p_context == CONTEXT_ENGINE) {
classHint->res_name = (char *)"Godot_Engine";
- char *config_name_tmp = (char *)((String)GLOBAL_GET("application/config/name")).utf8().ptrw();
- if (config_name_tmp)
- config_name = strdup(config_name_tmp);
- else
+ String config_name_tmp = GLOBAL_GET("application/config/name");
+ if (config_name_tmp.length() > 0) {
+ config_name = strdup(config_name_tmp.utf8().get_data());
+ } else {
config_name = strdup("Godot Engine");
+ }
wm_class = config_name;
}