summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/AndroidManifest.xml.template2
-rw-r--r--platform/android/SCsub22
-rw-r--r--platform/android/audio_driver_jandroid.cpp1
-rw-r--r--platform/android/audio_driver_jandroid.h1
-rw-r--r--platform/android/audio_driver_opensl.cpp1
-rw-r--r--platform/android/audio_driver_opensl.h1
-rw-r--r--platform/android/build.gradle.template3
-rw-r--r--platform/android/detect.py10
-rw-r--r--platform/android/dir_access_android.cpp1
-rw-r--r--platform/android/dir_access_android.h1
-rw-r--r--platform/android/dir_access_jandroid.cpp1
-rw-r--r--platform/android/dir_access_jandroid.h1
-rw-r--r--platform/android/export/export.cpp1693
-rw-r--r--platform/android/export/export.h1
-rw-r--r--platform/android/file_access_android.cpp1
-rw-r--r--platform/android/file_access_android.h1
-rw-r--r--platform/android/file_access_jandroid.cpp1
-rw-r--r--platform/android/file_access_jandroid.h1
-rw-r--r--platform/android/globals/global_defaults.cpp1
-rw-r--r--platform/android/globals/global_defaults.h1
-rw-r--r--platform/android/godot_android.cpp1
-rw-r--r--platform/android/java/src/com/android/vending/licensing/Obfuscator.java2
-rw-r--r--platform/android/java/src/org/godotengine/godot/Dictionary.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/Godot.java5
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotIO.java3
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotLib.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotView.java23
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotEditText.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/Crypt.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java1
-rw-r--r--platform/android/java/src/org/godotengine/godot/utils/RequestParams.java1
-rw-r--r--platform/android/java_class_wrapper.cpp1
-rw-r--r--platform/android/java_class_wrapper.h33
-rw-r--r--platform/android/java_glue.cpp16
-rw-r--r--platform/android/java_glue.h1
-rw-r--r--platform/android/os_android.cpp61
-rw-r--r--platform/android/os_android.h9
-rw-r--r--platform/android/platform_config.h1
-rw-r--r--platform/android/power_android.cpp1
-rw-r--r--platform/android/power_android.h1
-rw-r--r--platform/android/thread_jandroid.cpp1
-rw-r--r--platform/android/thread_jandroid.h1
-rw-r--r--platform/bb10/audio_driver_bb10.cpp1
-rw-r--r--platform/bb10/audio_driver_bb10.h1
-rw-r--r--platform/bb10/export/export.cpp1
-rw-r--r--platform/bb10/export/export.h1
-rw-r--r--platform/bb10/godot_bb10.cpp1
-rw-r--r--platform/bb10/os_bb10.cpp11
-rw-r--r--platform/bb10/os_bb10.h5
-rw-r--r--platform/bb10/payment_service.cpp1
-rw-r--r--platform/bb10/payment_service.h1
-rw-r--r--platform/bb10/platform_config.h1
-rw-r--r--platform/bb10/power_bb10.cpp1
-rw-r--r--platform/bb10/power_bb10.h1
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp1
-rw-r--r--platform/haiku/audio_driver_media_kit.h1
-rw-r--r--platform/haiku/context_gl_haiku.cpp1
-rw-r--r--platform/haiku/context_gl_haiku.h1
-rw-r--r--platform/haiku/detect.py2
-rw-r--r--platform/haiku/godot_haiku.cpp1
-rw-r--r--platform/haiku/haiku_application.cpp1
-rw-r--r--platform/haiku/haiku_application.h1
-rw-r--r--platform/haiku/haiku_direct_window.cpp11
-rw-r--r--platform/haiku/haiku_direct_window.h2
-rw-r--r--platform/haiku/haiku_gl_view.cpp1
-rw-r--r--platform/haiku/haiku_gl_view.h1
-rw-r--r--platform/haiku/key_mapping_haiku.cpp1
-rw-r--r--platform/haiku/key_mapping_haiku.h1
-rw-r--r--platform/haiku/os_haiku.cpp3
-rw-r--r--platform/haiku/os_haiku.h3
-rw-r--r--platform/haiku/platform_config.h1
-rw-r--r--platform/haiku/power_haiku.cpp1
-rw-r--r--platform/haiku/power_haiku.h1
-rw-r--r--platform/iphone/app_delegate.h1
-rw-r--r--platform/iphone/app_delegate.mm390
-rw-r--r--platform/iphone/audio_driver_iphone.cpp1
-rw-r--r--platform/iphone/audio_driver_iphone.h1
-rw-r--r--platform/iphone/detect.py12
-rw-r--r--platform/iphone/game_center.h1
-rw-r--r--platform/iphone/game_center.mm172
-rw-r--r--platform/iphone/gl_view.h1
-rw-r--r--[-rwxr-xr-x]platform/iphone/gl_view.mm349
-rw-r--r--platform/iphone/globals/global_defaults.cpp1
-rw-r--r--platform/iphone/globals/global_defaults.h1
-rw-r--r--platform/iphone/godot_iphone.cpp1
-rw-r--r--platform/iphone/icloud.h1
-rw-r--r--platform/iphone/icloud.mm271
-rw-r--r--platform/iphone/in_app_store.h1
-rw-r--r--platform/iphone/in_app_store.mm261
-rw-r--r--platform/iphone/ios.h1
-rw-r--r--platform/iphone/ios.mm16
-rw-r--r--platform/iphone/main.m12
-rw-r--r--platform/iphone/os_iphone.cpp22
-rw-r--r--platform/iphone/os_iphone.h4
-rw-r--r--platform/iphone/platform_config.h1
-rw-r--r--platform/iphone/platform_refcount.h1
-rw-r--r--platform/iphone/power_iphone.cpp1
-rw-r--r--platform/iphone/power_iphone.h1
-rw-r--r--platform/iphone/rasterizer_iphone.cpp21
-rw-r--r--platform/iphone/rasterizer_iphone.h21
-rw-r--r--platform/iphone/sem_iphone.cpp1
-rw-r--r--platform/iphone/sem_iphone.h1
-rw-r--r--platform/iphone/view_controller.h1
-rw-r--r--platform/iphone/view_controller.mm83
-rw-r--r--platform/javascript/audio_driver_javascript.cpp1
-rw-r--r--platform/javascript/audio_driver_javascript.h1
-rw-r--r--platform/javascript/audio_server_javascript.cpp1
-rw-r--r--platform/javascript/audio_server_javascript.h1
-rw-r--r--platform/javascript/detect.py4
-rw-r--r--platform/javascript/dom_keys.h1
-rw-r--r--platform/javascript/export/export.cpp457
-rw-r--r--platform/javascript/export/export.h1
-rw-r--r--platform/javascript/godot_shell.html199
-rw-r--r--platform/javascript/javascript_eval.cpp1
-rw-r--r--platform/javascript/javascript_eval.h1
-rw-r--r--platform/javascript/javascript_main.cpp14
-rw-r--r--platform/javascript/os_javascript.cpp32
-rw-r--r--platform/javascript/os_javascript.h6
-rw-r--r--platform/javascript/platform_config.h1
-rw-r--r--platform/javascript/power_javascript.cpp1
-rw-r--r--platform/javascript/power_javascript.h1
-rw-r--r--platform/osx/audio_driver_osx.cpp1
-rw-r--r--platform/osx/audio_driver_osx.h1
-rw-r--r--platform/osx/context_gl_osx.cpp1
-rw-r--r--platform/osx/context_gl_osx.h1
-rw-r--r--platform/osx/detect.py2
-rw-r--r--platform/osx/dir_access_osx.h1
-rw-r--r--platform/osx/dir_access_osx.mm8
-rw-r--r--platform/osx/export/export.cpp1
-rw-r--r--platform/osx/export/export.h1
-rw-r--r--platform/osx/godot_main_osx.mm39
-rw-r--r--platform/osx/godot_osx.h1
-rw-r--r--platform/osx/godot_osx.mm213
-rw-r--r--platform/osx/joypad_osx.cpp10
-rw-r--r--platform/osx/joypad_osx.h3
-rw-r--r--platform/osx/os_osx.h5
-rw-r--r--platform/osx/os_osx.mm1449
-rw-r--r--platform/osx/platform_config.h1
-rw-r--r--platform/osx/power_osx.cpp1
-rw-r--r--platform/osx/power_osx.h1
-rw-r--r--platform/osx/sem_osx.cpp1
-rw-r--r--platform/osx/sem_osx.h1
-rw-r--r--platform/server/detect.py2
-rw-r--r--platform/server/godot_server.cpp1
-rw-r--r--platform/server/os_server.cpp3
-rw-r--r--platform/server/os_server.h3
-rw-r--r--platform/server/platform_config.h1
-rw-r--r--platform/uwp/app.cpp1
-rw-r--r--platform/uwp/app.h1
-rw-r--r--platform/uwp/export/export.cpp3
-rw-r--r--platform/uwp/export/export.h1
-rw-r--r--platform/uwp/gl_context_egl.cpp1
-rw-r--r--platform/uwp/gl_context_egl.h1
-rw-r--r--platform/uwp/joypad_uwp.cpp19
-rw-r--r--platform/uwp/joypad_uwp.h3
-rw-r--r--platform/uwp/os_uwp.cpp9
-rw-r--r--platform/uwp/os_uwp.h4
-rw-r--r--platform/uwp/platform_config.h1
-rw-r--r--platform/uwp/thread_uwp.cpp1
-rw-r--r--platform/uwp/thread_uwp.h1
-rw-r--r--platform/windows/context_gl_win.cpp3
-rw-r--r--platform/windows/context_gl_win.h1
-rw-r--r--platform/windows/ctxgl_procaddr.cpp1
-rw-r--r--platform/windows/ctxgl_procaddr.h1
-rw-r--r--platform/windows/detect.py6
-rw-r--r--platform/windows/export/export.cpp30
-rw-r--r--platform/windows/export/export.h1
-rw-r--r--platform/windows/godot_win.cpp1
-rw-r--r--platform/windows/joypad.cpp31
-rw-r--r--platform/windows/joypad.h5
-rw-r--r--platform/windows/key_mapping_win.cpp1
-rw-r--r--platform/windows/key_mapping_win.h1
-rw-r--r--platform/windows/lang_table.h1
-rw-r--r--platform/windows/os_windows.cpp42
-rw-r--r--platform/windows/os_windows.h8
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp26
-rw-r--r--platform/windows/packet_peer_udp_winsock.h5
-rw-r--r--platform/windows/platform_config.h1
-rw-r--r--platform/windows/power_windows.cpp1
-rw-r--r--platform/windows/power_windows.h1
-rw-r--r--platform/windows/stream_peer_winsock.cpp1
-rw-r--r--platform/windows/stream_peer_winsock.h1
-rw-r--r--platform/windows/tcp_server_winsock.cpp1
-rw-r--r--platform/windows/tcp_server_winsock.h1
-rw-r--r--platform/x11/context_gl_x11.cpp3
-rw-r--r--platform/x11/context_gl_x11.h1
-rw-r--r--platform/x11/detect.py4
-rw-r--r--platform/x11/export/export.cpp7
-rw-r--r--platform/x11/export/export.h1
-rw-r--r--platform/x11/godot_x11.cpp1
-rw-r--r--platform/x11/joypad_linux.cpp16
-rw-r--r--platform/x11/joypad_linux.h3
-rw-r--r--platform/x11/key_mapping_x11.cpp1
-rw-r--r--platform/x11/key_mapping_x11.h1
-rw-r--r--platform/x11/os_x11.cpp20
-rw-r--r--platform/x11/os_x11.h4
-rw-r--r--platform/x11/platform_config.h1
-rw-r--r--platform/x11/power_x11.cpp1
-rw-r--r--platform/x11/power_x11.h1
212 files changed, 3922 insertions, 2472 deletions
diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template
index 2a24c7cdc2..be5afb406a 100644
--- a/platform/android/AndroidManifest.xml.template
+++ b/platform/android/AndroidManifest.xml.template
@@ -31,7 +31,7 @@
$$ADD_APPLICATION_CHUNKS$$
</application>
- <uses-feature android:glEsVersion="0x00020000"/>
+ <uses-feature android:glEsVersion="0x00030000"/>
$$ADD_PERMISSION_CHUNKS$$
<uses-permission android:name="godot.ACCESS_CHECKIN_PROPERTIES"/>
diff --git a/platform/android/SCsub b/platform/android/SCsub
index e8536953a3..7fb3c876be 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -19,8 +19,8 @@ android_files = [
'android_native_app_glue.c',
'java_glue.cpp',
'cpu-features.c',
- 'java_class_wrapper.cpp'
- 'power_android.cpp'
+ 'java_class_wrapper.cpp',
+# 'power_android.cpp'
]
# env.Depends('#core/math/vector3.h', 'vector3_psp.h')
@@ -52,13 +52,13 @@ if len(env.android_maven_repos) > 0:
gradle_maven_repos_text += ""
for x in env.android_maven_repos:
gradle_maven_repos_text += "\tmaven {\n"
- gradle_maven_repos_text += "\t\t" + x + "\n"
+ gradle_maven_repos_text += "\t" + x + "\n"
gradle_maven_repos_text += "\t}\n"
gradle_maven_dependencies_text = ""
for x in env.android_dependencies:
- gradle_maven_dependencies_text += x + "\n"
+ gradle_maven_dependencies_text += x + "\n\t"
gradle_java_dirs_text = ""
@@ -92,9 +92,23 @@ gradle_asset_dirs_text = ""
gradle_default_config_text = ""
+minSdk = 14
+targetSdk = 23
+
for x in env.android_default_config:
+ if x.startswith("minSdkVersion") and int(x.split(" ")[-1]) < minSdk:
+ x = "minSdkVersion " + str(minSdk)
+ if x.startswith("targetSdkVersion") and int(x.split(" ")[-1]) > targetSdk:
+ x = "targetSdkVersion " + str(targetSdk)
+
gradle_default_config_text += x + "\n\t\t"
+if "minSdkVersion" not in gradle_default_config_text:
+ gradle_default_config_text += ("minSdkVersion " + str(minSdk) + "\n\t\t")
+
+if "targetSdkVersion" not in gradle_default_config_text:
+ gradle_default_config_text += ("targetSdkVersion " + str(targetSdk) + "\n\t\t")
+
gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$", gradle_maven_repos_text)
gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$", gradle_maven_dependencies_text)
gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$", gradle_java_dirs_text)
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index 5e30289310..7b2127a211 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h
index 4b5131cdc0..e2bb5ede86 100644
--- a/platform/android/audio_driver_jandroid.h
+++ b/platform/android/audio_driver_jandroid.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp
index bba98dd623..acd94d2bdd 100644
--- a/platform/android/audio_driver_opensl.cpp
+++ b/platform/android/audio_driver_opensl.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h
index 306589aa23..f6270a3084 100644
--- a/platform/android/audio_driver_opensl.h
+++ b/platform/android/audio_driver_opensl.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 24aab8e01f..8dfb006c00 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -12,6 +12,7 @@ apply plugin: 'com.android.application'
allprojects {
repositories {
+ jcenter()
mavenCentral()
$$GRADLE_REPOSITORY_URLS$$
}
@@ -38,8 +39,6 @@ android {
exclude 'META-INF/NOTICE'
}
defaultConfig {
- minSdkVersion 14
- targetSdkVersion 23
$$GRADLE_DEFAULT_CONFIG$$
}
// Both signing and zip-aligning will be done at export time
diff --git a/platform/android/detect.py b/platform/android/detect.py
index d1073e0c7b..8d2ed59f17 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -26,7 +26,7 @@ def get_opts():
return [
('ANDROID_NDK_ROOT', 'the path to Android NDK',
os.environ.get("ANDROID_NDK_ROOT", 0)),
- ('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"),
+ ('ndk_platform', 'compile for platform: (android-<api> , example: android-18)', "android-18"),
('android_arch', 'select compiler architecture: (armv7/armv6/x86)', "armv7"),
('android_neon', 'enable neon (armv7 only)', "yes"),
('android_stl', 'enable STL support in android port (for modules)', "no")
@@ -168,15 +168,15 @@ def configure(env):
env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"])
env.Append(CPPFLAGS=string.split(
- '-Wno-invalid-command-line-argument -Wno-unused-command-line-argument'))
- env.Append(CPPFLAGS=string.split(
- '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing -Wa,--noexecstack'))
+ '-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'))
env.Append(CPPFLAGS=string.split('-DANDROID -DNO_STATVFS -DGLES2_ENABLED'))
env['neon_enabled'] = False
if env['android_arch'] == 'x86':
can_vectorize = True
target_opts = ['-target', 'i686-none-linux-android']
+ # The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least
+ env.Append(CPPFLAGS=['-mstackrealign'])
elif env["android_arch"] == "armv6":
can_vectorize = False
target_opts = ['-target', 'armv6-none-linux-androideabi']
@@ -198,7 +198,7 @@ def configure(env):
env.Append(LIBS=['OpenSLES'])
env.Append(LIBS=['EGL', 'OpenSLES', 'android'])
- env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'z'])
+ env.Append(LIBS=['log', 'GLESv1_CM', 'GLESv2', 'GLESv3','z'])
if (sys.platform.startswith("darwin")):
env['SHLIBSUFFIX'] = '.so'
diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp
index 989bd02bd9..67aa7750cd 100644
--- a/platform/android/dir_access_android.cpp
+++ b/platform/android/dir_access_android.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/dir_access_android.h b/platform/android/dir_access_android.h
index 640800584a..32986f524b 100644
--- a/platform/android/dir_access_android.h
+++ b/platform/android/dir_access_android.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp
index 68446302ff..34f4afa331 100644
--- a/platform/android/dir_access_jandroid.cpp
+++ b/platform/android/dir_access_jandroid.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h
index 096858ddf7..0175595543 100644
--- a/platform/android/dir_access_jandroid.h
+++ b/platform/android/dir_access_jandroid.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 31fa4c18bd..72d665329e 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -1792,7 +1793,6 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
name="";
_signed=true;
apk_expansion=false;
- device_lock = Mutex::create();
quit_request=false;
orientation=0;
remove_prev=true;
@@ -1888,26 +1888,1679 @@ EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
#endif
-void register_android_exporter() {
+static const char *android_perms[] = {
+ "ACCESS_CHECKIN_PROPERTIES",
+ "ACCESS_COARSE_LOCATION",
+ "ACCESS_FINE_LOCATION",
+ "ACCESS_LOCATION_EXTRA_COMMANDS",
+ "ACCESS_MOCK_LOCATION",
+ "ACCESS_NETWORK_STATE",
+ "ACCESS_SURFACE_FLINGER",
+ "ACCESS_WIFI_STATE",
+ "ACCOUNT_MANAGER",
+ "ADD_VOICEMAIL",
+ "AUTHENTICATE_ACCOUNTS",
+ "BATTERY_STATS",
+ "BIND_ACCESSIBILITY_SERVICE",
+ "BIND_APPWIDGET",
+ "BIND_DEVICE_ADMIN",
+ "BIND_INPUT_METHOD",
+ "BIND_NFC_SERVICE",
+ "BIND_NOTIFICATION_LISTENER_SERVICE",
+ "BIND_PRINT_SERVICE",
+ "BIND_REMOTEVIEWS",
+ "BIND_TEXT_SERVICE",
+ "BIND_VPN_SERVICE",
+ "BIND_WALLPAPER",
+ "BLUETOOTH",
+ "BLUETOOTH_ADMIN",
+ "BLUETOOTH_PRIVILEGED",
+ "BRICK",
+ "BROADCAST_PACKAGE_REMOVED",
+ "BROADCAST_SMS",
+ "BROADCAST_STICKY",
+ "BROADCAST_WAP_PUSH",
+ "CALL_PHONE",
+ "CALL_PRIVILEGED",
+ "CAMERA",
+ "CAPTURE_AUDIO_OUTPUT",
+ "CAPTURE_SECURE_VIDEO_OUTPUT",
+ "CAPTURE_VIDEO_OUTPUT",
+ "CHANGE_COMPONENT_ENABLED_STATE",
+ "CHANGE_CONFIGURATION",
+ "CHANGE_NETWORK_STATE",
+ "CHANGE_WIFI_MULTICAST_STATE",
+ "CHANGE_WIFI_STATE",
+ "CLEAR_APP_CACHE",
+ "CLEAR_APP_USER_DATA",
+ "CONTROL_LOCATION_UPDATES",
+ "DELETE_CACHE_FILES",
+ "DELETE_PACKAGES",
+ "DEVICE_POWER",
+ "DIAGNOSTIC",
+ "DISABLE_KEYGUARD",
+ "DUMP",
+ "EXPAND_STATUS_BAR",
+ "FACTORY_TEST",
+ "FLASHLIGHT",
+ "FORCE_BACK",
+ "GET_ACCOUNTS",
+ "GET_PACKAGE_SIZE",
+ "GET_TASKS",
+ "GET_TOP_ACTIVITY_INFO",
+ "GLOBAL_SEARCH",
+ "HARDWARE_TEST",
+ "INJECT_EVENTS",
+ "INSTALL_LOCATION_PROVIDER",
+ "INSTALL_PACKAGES",
+ "INSTALL_SHORTCUT",
+ "INTERNAL_SYSTEM_WINDOW",
+ "INTERNET",
+ "KILL_BACKGROUND_PROCESSES",
+ "LOCATION_HARDWARE",
+ "MANAGE_ACCOUNTS",
+ "MANAGE_APP_TOKENS",
+ "MANAGE_DOCUMENTS",
+ "MASTER_CLEAR",
+ "MEDIA_CONTENT_CONTROL",
+ "MODIFY_AUDIO_SETTINGS",
+ "MODIFY_PHONE_STATE",
+ "MOUNT_FORMAT_FILESYSTEMS",
+ "MOUNT_UNMOUNT_FILESYSTEMS",
+ "NFC",
+ "PERSISTENT_ACTIVITY",
+ "PROCESS_OUTGOING_CALLS",
+ "READ_CALENDAR",
+ "READ_CALL_LOG",
+ "READ_CONTACTS",
+ "READ_EXTERNAL_STORAGE",
+ "READ_FRAME_BUFFER",
+ "READ_HISTORY_BOOKMARKS",
+ "READ_INPUT_STATE",
+ "READ_LOGS",
+ "READ_PHONE_STATE",
+ "READ_PROFILE",
+ "READ_SMS",
+ "READ_SOCIAL_STREAM",
+ "READ_SYNC_SETTINGS",
+ "READ_SYNC_STATS",
+ "READ_USER_DICTIONARY",
+ "REBOOT",
+ "RECEIVE_BOOT_COMPLETED",
+ "RECEIVE_MMS",
+ "RECEIVE_SMS",
+ "RECEIVE_WAP_PUSH",
+ "RECORD_AUDIO",
+ "REORDER_TASKS",
+ "RESTART_PACKAGES",
+ "SEND_RESPOND_VIA_MESSAGE",
+ "SEND_SMS",
+ "SET_ACTIVITY_WATCHER",
+ "SET_ALARM",
+ "SET_ALWAYS_FINISH",
+ "SET_ANIMATION_SCALE",
+ "SET_DEBUG_APP",
+ "SET_ORIENTATION",
+ "SET_POINTER_SPEED",
+ "SET_PREFERRED_APPLICATIONS",
+ "SET_PROCESS_LIMIT",
+ "SET_TIME",
+ "SET_TIME_ZONE",
+ "SET_WALLPAPER",
+ "SET_WALLPAPER_HINTS",
+ "SIGNAL_PERSISTENT_PROCESSES",
+ "STATUS_BAR",
+ "SUBSCRIBED_FEEDS_READ",
+ "SUBSCRIBED_FEEDS_WRITE",
+ "SYSTEM_ALERT_WINDOW",
+ "TRANSMIT_IR",
+ "UNINSTALL_SHORTCUT",
+ "UPDATE_DEVICE_STATS",
+ "USE_CREDENTIALS",
+ "USE_SIP",
+ "VIBRATE",
+ "WAKE_LOCK",
+ "WRITE_APN_SETTINGS",
+ "WRITE_CALENDAR",
+ "WRITE_CALL_LOG",
+ "WRITE_CONTACTS",
+ "WRITE_EXTERNAL_STORAGE",
+ "WRITE_GSERVICES",
+ "WRITE_HISTORY_BOOKMARKS",
+ "WRITE_PROFILE",
+ "WRITE_SECURE_SETTINGS",
+ "WRITE_SETTINGS",
+ "WRITE_SMS",
+ "WRITE_SOCIAL_STREAM",
+ "WRITE_SYNC_SETTINGS",
+ "WRITE_USER_DICTIONARY",
+ NULL
+};
+
+class EditorExportAndroid : public EditorExportPlatform {
+
+ GDCLASS(EditorExportAndroid, EditorExportPlatform)
+
+ Ref<ImageTexture> logo;
+
+ struct Device {
+
+ String id;
+ String name;
+ String description;
+ };
+
+ struct APKExportData {
+
+ zipFile apk;
+ EditorProgress *ep;
+ };
+
+ Vector<Device> devices;
+ bool devices_changed;
+ Mutex *device_lock;
+ Thread *device_thread;
+ volatile bool quit_request;
+
+ static void _device_poll_thread(void *ud) {
+
+ EditorExportAndroid *ea = (EditorExportAndroid *)ud;
+
+ while (!ea->quit_request) {
+
+ String adb = EditorSettings::get_singleton()->get("export/android/adb");
+ if (FileAccess::exists(adb)) {
+
+ String devices;
+ List<String> args;
+ args.push_back("devices");
+ int ec;
+ OS::get_singleton()->execute(adb, args, true, NULL, &devices, &ec);
+
+ Vector<String> ds = devices.split("\n");
+ Vector<String> ldevices;
+ for (int i = 1; i < ds.size(); i++) {
+
+ String d = ds[i];
+ int dpos = d.find("device");
+ if (dpos == -1)
+ continue;
+ d = d.substr(0, dpos).strip_edges();
+ //print_line("found devuce: "+d);
+ ldevices.push_back(d);
+ }
+
+ ea->device_lock->lock();
+
+ bool different = false;
+
+ if (ea->devices.size() != ldevices.size()) {
+
+ different = true;
+ } else {
+
+ for (int i = 0; i < ea->devices.size(); i++) {
+
+ if (ea->devices[i].id != ldevices[i]) {
+ different = true;
+ break;
+ }
+ }
+ }
+
+ if (different) {
+
+ print_line("DIFFERENT!");
+ Vector<Device> ndevices;
+
+ for (int i = 0; i < ldevices.size(); i++) {
+
+ Device d;
+ d.id = ldevices[i];
+ for (int j = 0; j < ea->devices.size(); j++) {
+ if (ea->devices[j].id == ldevices[i]) {
+ d.description = ea->devices[j].description;
+ d.name = ea->devices[j].name;
+ }
+ }
+
+ if (d.description == "") {
+ //in the oven, request!
+ args.clear();
+ args.push_back("-s");
+ args.push_back(d.id);
+ args.push_back("shell");
+ args.push_back("cat");
+ args.push_back("/system/build.prop");
+ int ec;
+ String dp;
+
+ OS::get_singleton()->execute(adb, args, true, NULL, &dp, &ec);
+
+ Vector<String> props = dp.split("\n");
+ String vendor;
+ String device;
+ d.description + "Device ID: " + d.id + "\n";
+ for (int j = 0; j < props.size(); j++) {
+
+ String p = props[j];
+ if (p.begins_with("ro.product.model=")) {
+ device = p.get_slice("=", 1).strip_edges();
+ } else if (p.begins_with("ro.product.brand=")) {
+ vendor = p.get_slice("=", 1).strip_edges().capitalize();
+ } else if (p.begins_with("ro.build.display.id=")) {
+ d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n";
+ } else if (p.begins_with("ro.build.version.release=")) {
+ d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n";
+ } else if (p.begins_with("ro.product.cpu.abi=")) {
+ d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n";
+ } else if (p.begins_with("ro.product.manufacturer=")) {
+ d.description += "Manufacturer: " + p.get_slice("=", 1).strip_edges() + "\n";
+ } else if (p.begins_with("ro.board.platform=")) {
+ d.description += "Chipset: " + p.get_slice("=", 1).strip_edges() + "\n";
+ } else if (p.begins_with("ro.opengles.version=")) {
+ uint32_t opengl = p.get_slice("=", 1).to_int();
+ d.description += "OpenGL: " + itos(opengl >> 16) + "." + itos((opengl >> 8) & 0xFF) + "." + itos((opengl)&0xFF) + "\n";
+ }
+ }
+
+ d.name = vendor + " " + device;
+ //print_line("name: "+d.name);
+ //print_line("description: "+d.description);
+ }
+
+ ndevices.push_back(d);
+ }
+
+ ea->devices = ndevices;
+ ea->devices_changed = true;
+ }
+
+ ea->device_lock->unlock();
+ }
+
+ uint64_t wait = 3000000;
+ uint64_t time = OS::get_singleton()->get_ticks_usec();
+ while (OS::get_singleton()->get_ticks_usec() - time < wait) {
+ OS::get_singleton()->delay_usec(1000);
+ if (ea->quit_request)
+ break;
+ }
+ }
+
+ if (EditorSettings::get_singleton()->get("export/android/shutdown_adb_on_exit")) {
+ String adb = EditorSettings::get_singleton()->get("export/android/adb");
+ if (!FileAccess::exists(adb)) {
+ return; //adb not configured
+ }
+
+ List<String> args;
+ args.push_back("kill-server");
+ OS::get_singleton()->execute(adb, args, true);
+ };
+ }
+
+ String get_project_name(const String &p_name) const {
+
+ String aname;
+ if (p_name != "") {
+ aname = p_name;
+ } else {
+ aname = GlobalConfig::get_singleton()->get("application/name");
+ }
+
+ if (aname == "") {
+ aname = _MKSTR(VERSION_NAME);
+ }
+
+ return aname;
+ }
+
+ String get_package_name(const String &p_package) {
+
+ String pname = p_package;
+ String basename = GlobalConfig::get_singleton()->get("application/name");
+ basename = basename.to_lower();
+
+ String name;
+ bool first = true;
+ for (int i = 0; i < basename.length(); i++) {
+ CharType c = basename[i];
+ if (c >= '0' && c <= '9' && first) {
+ continue;
+ }
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
+ name += String::chr(c);
+ first = false;
+ }
+ }
+ if (name == "")
+ name = "noname";
+
+ pname = pname.replace("$genname", name);
+ return pname;
+ }
+
+ static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data) {
+
+ /*
+ * By not compressing files with little or not benefit in doing so,
+ * a performance gain is expected attime. Moreover, if the APK is
+ * zip-aligned, assets stored as they are can be efficiently read by
+ * Android by memory-mapping them.
+ */
+
+ // -- Unconditional uncompress to mimic AAPT plus some other
+
+ static const char *unconditional_compress_ext[] = {
+ // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp
+ // These formats are already compressed, or don't compress well:
+ ".jpg", ".jpeg", ".png", ".gif",
+ ".wav", ".mp2", ".mp3", ".ogg", ".aac",
+ ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
+ ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
+ ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
+ ".amr", ".awb", ".wma", ".wmv",
+ // Godot-specific:
+ ".webp", // Same reasoning as .png
+ ".cfb", // Don't let small config files slow-down startup
+ ".scn", // Binary scenes are usually already compressed
+ ".stex", // Streamable textures are usually already compressed
+ // Trailer for easier processing
+ NULL
+ };
+
+ for (const char **ext = unconditional_compress_ext; *ext; ++ext) {
+ if (p_path.to_lower().ends_with(String(*ext))) {
+ return false;
+ }
+ }
+
+ // -- Compressed resource?
+
+ if (p_data.size() >= 4 && p_data[0] == 'R' && p_data[1] == 'S' && p_data[2] == 'C' && p_data[3] == 'C') {
+ // Already compressed
+ return false;
+ }
+
+ // --- TODO: Decide on texture resources according to their image compression setting
+
+ return true;
+ }
+
+ static zip_fileinfo get_zip_fileinfo() {
+
+ OS::Time time = OS::get_singleton()->get_time();
+ OS::Date date = OS::get_singleton()->get_date();
+
+ zip_fileinfo zipfi;
+ zipfi.tmz_date.tm_hour = time.hour;
+ zipfi.tmz_date.tm_mday = date.day;
+ zipfi.tmz_date.tm_min = time.min;
+ zipfi.tmz_date.tm_mon = date.month;
+ zipfi.tmz_date.tm_sec = time.sec;
+ zipfi.tmz_date.tm_year = date.year;
+ zipfi.dosDate = 0;
+ zipfi.external_fa = 0;
+ zipfi.internal_fa = 0;
+
+ return zipfi;
+ }
+
+ static Error save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
+
+ APKExportData *ed = (APKExportData *)p_userdata;
+ String dst_path = p_path;
+ dst_path = dst_path.replace_first("res://", "assets/");
+
+ zip_fileinfo zipfi = get_zip_fileinfo();
+
+ zipOpenNewFileInZip(ed->apk,
+ dst_path.utf8().get_data(),
+ &zipfi,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ _should_compress_asset(p_path, p_data) ? Z_DEFLATED : 0,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(ed->apk, p_data.ptr(), p_data.size());
+ zipCloseFileInZip(ed->apk);
+ ed->ep->step("File: " + p_path, 3 + p_file * 100 / p_total);
+ return OK;
+ }
+
+ void _fix_manifest(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest, bool p_give_internet) {
+
+ const int CHUNK_AXML_FILE = 0x00080003;
+ const int CHUNK_RESOURCEIDS = 0x00080180;
+ const int CHUNK_STRINGS = 0x001C0001;
+ const int CHUNK_XML_END_NAMESPACE = 0x00100101;
+ const int CHUNK_XML_END_TAG = 0x00100103;
+ const int CHUNK_XML_START_NAMESPACE = 0x00100100;
+ const int CHUNK_XML_START_TAG = 0x00100102;
+ const int CHUNK_XML_TEXT = 0x00100104;
+ const int UTF8_FLAG = 0x00000100;
+
+ Vector<String> string_table;
+
+ uint32_t ofs = 0;
+
+ uint32_t header = decode_uint32(&p_manifest[ofs]);
+ uint32_t filesize = decode_uint32(&p_manifest[ofs + 4]);
+ ofs += 8;
+
+ //print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));
+
+ uint32_t string_count;
+ uint32_t styles_count;
+ uint32_t string_flags;
+ uint32_t string_data_offset;
+
+ uint32_t styles_offset;
+ uint32_t string_table_begins;
+ uint32_t string_table_ends;
+ Vector<uint8_t> stable_extra;
+
+ String version_name = p_preset->get("version/name");
+ int version_code = p_preset->get("version/code");
+ String package_name = p_preset->get("package/unique_name");
+
+ int orientation = p_preset->get("screen/orientation");
+
+ 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");
+ bool screen_support_xlarge = p_preset->get("screen/support_xlarge");
+
+ String user_perms[MAX_USER_PERMISSIONS];
+
+ for (int i = 0; i < MAX_USER_PERMISSIONS; i++) {
+
+ user_perms[i] = p_preset->get("user_permissions/" + itos(i));
+ }
+
+ Set<String> perms;
+
+ const char **aperms = android_perms;
+ while (*aperms) {
+
+ bool enabled = p_preset->get("permissions/" + String(*aperms).to_lower());
+ if (enabled)
+ perms.insert(String(*aperms));
+ aperms++;
+ }
+
+ while (ofs < (uint32_t)p_manifest.size()) {
+
+ uint32_t chunk = decode_uint32(&p_manifest[ofs]);
+ uint32_t size = decode_uint32(&p_manifest[ofs + 4]);
+
+ switch (chunk) {
+
+ case CHUNK_STRINGS: {
+
+ int iofs = ofs + 8;
+
+ string_count = decode_uint32(&p_manifest[iofs]);
+ styles_count = decode_uint32(&p_manifest[iofs + 4]);
+ string_flags = decode_uint32(&p_manifest[iofs + 8]);
+ string_data_offset = decode_uint32(&p_manifest[iofs + 12]);
+ styles_offset = decode_uint32(&p_manifest[iofs + 16]);
+ /*
+ printf("string count: %i\n",string_count);
+ printf("flags: %i\n",string_flags);
+ printf("sdata ofs: %i\n",string_data_offset);
+ printf("styles ofs: %i\n",styles_offset);
+ */
+ uint32_t st_offset = iofs + 20;
+ string_table.resize(string_count);
+ uint32_t string_end = 0;
+
+ string_table_begins = st_offset;
+
+ for (uint32_t i = 0; i < string_count; i++) {
+
+ uint32_t string_at = decode_uint32(&p_manifest[st_offset + i * 4]);
+ string_at += st_offset + string_count * 4;
+
+ ERR_EXPLAIN("Unimplemented, can't read utf8 string table.");
+ ERR_FAIL_COND(string_flags & UTF8_FLAG);
+
+ if (string_flags & UTF8_FLAG) {
+
+ } else {
+ uint32_t len = decode_uint16(&p_manifest[string_at]);
+ Vector<CharType> ucstring;
+ ucstring.resize(len + 1);
+ for (uint32_t j = 0; j < len; j++) {
+ uint16_t c = decode_uint16(&p_manifest[string_at + 2 + 2 * j]);
+ ucstring[j] = c;
+ }
+ string_end = MAX(string_at + 2 + 2 * len, string_end);
+ ucstring[len] = 0;
+ string_table[i] = ucstring.ptr();
+ }
+
+ //print_line("String "+itos(i)+": "+string_table[i]);
+ }
+
+ for (uint32_t i = string_end; i < (ofs + size); i++) {
+ stable_extra.push_back(p_manifest[i]);
+ }
+
+ //printf("stable extra: %i\n",int(stable_extra.size()));
+ string_table_ends = ofs + size;
+
+ //print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));
+
+ } break;
+ case CHUNK_XML_START_TAG: {
+
+ int iofs = ofs + 8;
+ uint32_t line = decode_uint32(&p_manifest[iofs]);
+ uint32_t nspace = decode_uint32(&p_manifest[iofs + 8]);
+ uint32_t name = decode_uint32(&p_manifest[iofs + 12]);
+ uint32_t check = decode_uint32(&p_manifest[iofs + 16]);
+
+ String tname = string_table[name];
+
+ //printf("NSPACE: %i\n",nspace);
+ //printf("NAME: %i (%s)\n",name,tname.utf8().get_data());
+ //printf("CHECK: %x\n",check);
+ uint32_t attrcount = decode_uint32(&p_manifest[iofs + 20]);
+ iofs += 28;
+ //printf("ATTRCOUNT: %x\n",attrcount);
+ for (uint32_t i = 0; i < attrcount; i++) {
+ uint32_t attr_nspace = decode_uint32(&p_manifest[iofs]);
+ uint32_t attr_name = decode_uint32(&p_manifest[iofs + 4]);
+ uint32_t attr_value = decode_uint32(&p_manifest[iofs + 8]);
+ uint32_t attr_flags = decode_uint32(&p_manifest[iofs + 12]);
+ uint32_t attr_resid = decode_uint32(&p_manifest[iofs + 16]);
+
+ String value;
+ if (attr_value != 0xFFFFFFFF)
+ value = string_table[attr_value];
+ else
+ value = "Res #" + itos(attr_resid);
+ String attrname = string_table[attr_name];
+ String nspace;
+ if (attr_nspace != 0xFFFFFFFF)
+ nspace = string_table[attr_nspace];
+ else
+ nspace = "";
+
+ //printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
+ //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
+ //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
+ //printf("ATTR %i FLAGS: %x\n",i,attr_flags);
+ //printf("ATTR %i RESID: %x\n",i,attr_resid);
+
+ //replace project information
+ if (tname == "manifest" && attrname == "package") {
+
+ print_line("FOUND package");
+ string_table[attr_value] = get_package_name(package_name);
+ }
+
+ //print_line("tname: "+tname);
+ //print_line("nspace: "+nspace);
+ //print_line("attrname: "+attrname);
+ if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionCode") {
+
+ print_line("FOUND versionCode");
+ encode_uint32(version_code, &p_manifest[iofs + 16]);
+ }
+
+ if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionName") {
+
+ print_line("FOUND versionName");
+ if (attr_value == 0xFFFFFFFF) {
+ WARN_PRINT("Version name in a resource, should be plaintext")
+ } else
+ string_table[attr_value] = version_name;
+ }
+
+ if (tname == "activity" && /*nspace=="android" &&*/ attrname == "screenOrientation") {
+
+ encode_uint32(orientation == 0 ? 0 : 1, &p_manifest[iofs + 16]);
+ /*
+ print_line("FOUND screen orientation");
+ if (attr_value==0xFFFFFFFF) {
+ WARN_PRINT("Version name in a resource, should be plaintext")
+ } else {
+ string_table[attr_value]=(orientation==0?"landscape":"portrait");
+ }*/
+ }
+
+ if (tname == "uses-permission" && /*nspace=="android" &&*/ attrname == "name") {
+
+ if (value.begins_with("godot.custom")) {
+
+ int which = value.get_slice(".", 2).to_int();
+ if (which >= 0 && which < MAX_USER_PERMISSIONS && user_perms[which].strip_edges() != "") {
+
+ string_table[attr_value] = user_perms[which].strip_edges();
+ }
+
+ } else if (value.begins_with("godot.")) {
+ String perm = value.get_slice(".", 1);
+
+ if (perms.has(perm) || (p_give_internet && perm == "INTERNET")) {
+
+ print_line("PERM: " + perm);
+ string_table[attr_value] = "android.permission." + perm;
+ }
+ }
+ }
+
+ if (tname == "supports-screens") {
+
+ if (attrname == "smallScreens") {
+
+ encode_uint32(screen_support_small ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
+
+ } else if (attrname == "normalScreens") {
+
+ encode_uint32(screen_support_normal ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
+
+ } else if (attrname == "largeScreens") {
+
+ encode_uint32(screen_support_large ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
+
+ } else if (attrname == "xlargeScreens") {
+
+ encode_uint32(screen_support_xlarge ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
+ }
+ }
+
+ iofs += 20;
+ }
+
+ } break;
+ }
+ //printf("chunk %x: size: %d\n",chunk,size);
+
+ ofs += size;
+ }
+
+ //printf("end\n");
+
+ //create new andriodmanifest binary
+
+ Vector<uint8_t> ret;
+ ret.resize(string_table_begins + string_table.size() * 4);
+
+ for (uint32_t i = 0; i < string_table_begins; i++) {
+
+ ret[i] = p_manifest[i];
+ }
+
+ ofs = 0;
+ for (int i = 0; i < string_table.size(); i++) {
+
+ encode_uint32(ofs, &ret[string_table_begins + i * 4]);
+ ofs += string_table[i].length() * 2 + 2 + 2;
+ //print_line("ofs: "+itos(i)+": "+itos(ofs));
+ }
+ ret.resize(ret.size() + ofs);
+ uint8_t *chars = &ret[ret.size() - ofs];
+ for (int i = 0; i < string_table.size(); i++) {
+
+ String s = string_table[i];
+ //print_line("savint string :"+s);
+ encode_uint16(s.length(), chars);
+ chars += 2;
+ for (int j = 0; j < s.length(); j++) { //include zero?
+ encode_uint16(s[j], chars);
+ chars += 2;
+ }
+ encode_uint16(0, chars);
+ chars += 2;
+ }
+
+ for (int i = 0; i < stable_extra.size(); i++) {
+ ret.push_back(stable_extra[i]);
+ }
+
+ while (ret.size() % 4)
+ ret.push_back(0);
+
+ uint32_t new_stable_end = ret.size();
+
+ uint32_t extra = (p_manifest.size() - string_table_ends);
+ ret.resize(new_stable_end + extra);
+ for (uint32_t i = 0; i < extra; i++)
+ ret[new_stable_end + i] = p_manifest[string_table_ends + i];
+
+ while (ret.size() % 4)
+ ret.push_back(0);
+ encode_uint32(ret.size(), &ret[4]); //update new file size
+
+ encode_uint32(new_stable_end - 8, &ret[12]); //update new string table size
+
+ //print_line("file size: "+itos(ret.size()));
+
+ p_manifest = ret;
#if 0
- String exe_ext=OS::get_singleton()->get_name()=="Windows"?"exe":"";
- EDITOR_DEF("export/android/adb","");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/adb",PROPERTY_HINT_GLOBAL_FILE,exe_ext));
- EDITOR_DEF("export/android/jarsigner","");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/jarsigner",PROPERTY_HINT_GLOBAL_FILE,exe_ext));
- EDITOR_DEF("export/android/debug_keystore","");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/debug_keystore",PROPERTY_HINT_GLOBAL_FILE,"keystore"));
- EDITOR_DEF("export/android/debug_keystore_user","androiddebugkey");
- EDITOR_DEF("export/android/debug_keystore_pass","android");
- //EDITOR_DEF("android/release_keystore","");
- //EDITOR_DEF("android/release_username","");
- //EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/release_keystore",PROPERTY_HINT_GLOBAL_FILE,"*.keystore"));
- EDITOR_DEF("export/android/timestamping_authority_url","");
- EDITOR_DEF("export/android/use_remote_debug_over_adb",false);
- EDITOR_DEF("export/android/shutdown_adb_on_exit",true);
-
- Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>( memnew(EditorExportPlatformAndroid) );
- EditorImportExport::get_singleton()->add_export_platform(exporter);
+ uint32_t header[9];
+ for(int i=0;i<9;i++) {
+ header[i]=decode_uint32(&p_manifest[i*4]);
+ }
+
+ //print_line("STO: "+itos(header[3]));
+ uint32_t st_offset=9*4;
+ //ERR_FAIL_COND(header[3]!=0x24)
+ uint32_t string_count=header[4];
+
+
+ string_table.resize(string_count);
+
+ for(int i=0;i<string_count;i++) {
+
+ uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]);
+ string_at+=st_offset+string_count*4;
+ uint32_t len = decode_uint16(&p_manifest[string_at]);
+ Vector<CharType> ucstring;
+ ucstring.resize(len+1);
+ for(int j=0;j<len;j++) {
+ uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]);
+ ucstring[j]=c;
+ }
+ ucstring[len]=0;
+ string_table[i]=ucstring.ptr();
+ }
+
#endif
+ }
+
+ static String _parse_string(const uint8_t *p_bytes, bool p_utf8) {
+
+ uint32_t offset = 0;
+ uint32_t len = decode_uint16(&p_bytes[offset]);
+
+ if (p_utf8) {
+ //don't know how to read extended utf8, this will have to be for now
+ len >>= 8;
+ }
+ offset += 2;
+ //printf("len %i, unicode: %i\n",len,int(p_utf8));
+
+ if (p_utf8) {
+
+ Vector<uint8_t> str8;
+ str8.resize(len + 1);
+ for (uint32_t i = 0; i < len; i++) {
+ str8[i] = p_bytes[offset + i];
+ }
+ str8[len] = 0;
+ String str;
+ str.parse_utf8((const char *)str8.ptr());
+ return str;
+ } else {
+
+ String str;
+ for (uint32_t i = 0; i < len; i++) {
+ CharType c = decode_uint16(&p_bytes[offset + i * 2]);
+ if (c == 0)
+ break;
+ str += String::chr(c);
+ }
+ return str;
+ }
+ }
+ void _fix_resources(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest) {
+
+ const int UTF8_FLAG = 0x00000100;
+ print_line("*******************GORRRGLE***********************");
+
+ uint32_t header = decode_uint32(&p_manifest[0]);
+ uint32_t filesize = decode_uint32(&p_manifest[4]);
+ uint32_t string_block_len = decode_uint32(&p_manifest[16]);
+ uint32_t string_count = decode_uint32(&p_manifest[20]);
+ uint32_t string_flags = decode_uint32(&p_manifest[28]);
+ const uint32_t string_table_begins = 40;
+
+ Vector<String> string_table;
+
+ String package_name = p_preset->get("package/name");
+
+ //printf("stirng block len: %i\n",string_block_len);
+ //printf("stirng count: %i\n",string_count);
+ //printf("flags: %x\n",string_flags);
+
+ for (uint32_t i = 0; i < string_count; i++) {
+
+ uint32_t offset = decode_uint32(&p_manifest[string_table_begins + i * 4]);
+ offset += string_table_begins + string_count * 4;
+
+ String str = _parse_string(&p_manifest[offset], string_flags & UTF8_FLAG);
+
+ if (str.begins_with("godot-project-name")) {
+
+ if (str == "godot-project-name") {
+ //project name
+ str = get_project_name(package_name);
+
+ } else {
+
+ String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_");
+ String prop = "application/name_" + lang;
+ if (GlobalConfig::get_singleton()->has(prop)) {
+ str = GlobalConfig::get_singleton()->get(prop);
+ } else {
+ str = get_project_name(package_name);
+ }
+ }
+ }
+
+ string_table.push_back(str);
+ }
+
+ //write a new string table, but use 16 bits
+ Vector<uint8_t> ret;
+ ret.resize(string_table_begins + string_table.size() * 4);
+
+ for (uint32_t i = 0; i < string_table_begins; i++) {
+
+ ret[i] = p_manifest[i];
+ }
+
+ int ofs = 0;
+ for (int i = 0; i < string_table.size(); i++) {
+
+ encode_uint32(ofs, &ret[string_table_begins + i * 4]);
+ ofs += string_table[i].length() * 2 + 2 + 2;
+ }
+
+ ret.resize(ret.size() + ofs);
+ uint8_t *chars = &ret[ret.size() - ofs];
+ for (int i = 0; i < string_table.size(); i++) {
+
+ String s = string_table[i];
+ encode_uint16(s.length(), chars);
+ chars += 2;
+ for (int j = 0; j < s.length(); j++) {
+ encode_uint16(s[j], chars);
+ chars += 2;
+ }
+ encode_uint16(0, chars);
+ chars += 2;
+ }
+
+ //pad
+ while (ret.size() % 4)
+ ret.push_back(0);
+
+ //change flags to not use utf8
+ encode_uint32(string_flags & ~0x100, &ret[28]);
+ //change length
+ encode_uint32(ret.size() - 12, &ret[16]);
+ //append the rest...
+ int rest_from = 12 + string_block_len;
+ int rest_to = ret.size();
+ int rest_len = (p_manifest.size() - rest_from);
+ ret.resize(ret.size() + (p_manifest.size() - rest_from));
+ for (int i = 0; i < rest_len; i++) {
+ ret[rest_to + i] = p_manifest[rest_from + i];
+ }
+ //finally update the size
+ encode_uint32(ret.size(), &ret[4]);
+
+ p_manifest = ret;
+ //printf("end\n");
+ }
+
+public:
+ enum {
+ MAX_USER_PERMISSIONS = 20
+ };
+
+ typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
+
+public:
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
+
+ r_features->push_back("etc");
+ }
+
+ virtual void get_export_options(List<ExportOption> *r_options) {
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "apk"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,65535,1"), 1));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name"), "org.godotengine.$genname"));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/icon", PROPERTY_HINT_FILE, "png"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architecture/arm"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "architecture/x86"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/use_32_bits_view"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"), 0));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_small"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_normal"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_large"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "keystore"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_user"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_password"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "apk_expansion/enable"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "apk_expansion/SALT"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "apk_expansion/public_key", PROPERTY_HINT_MULTILINE_TEXT), ""));
+
+ const char **perms = android_perms;
+ while (*perms) {
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "permissions/" + String(*perms).to_lower()), false));
+ perms++;
+ }
+
+ for (int i = 0; i < MAX_USER_PERMISSIONS; i++) {
+
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "user_permissions/" + itos(i)), false));
+ }
+
+ //r_options->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)"));
+ }
+
+ virtual String get_name() const {
+ return "Android";
+ }
+ virtual Ref<Texture> get_logo() const {
+ return logo;
+ }
+
+ virtual bool poll_devices() {
+
+ bool dc = devices_changed;
+ devices_changed = false;
+ return dc;
+ }
+
+ virtual int get_device_count() const {
+
+ device_lock->lock();
+ int dc = devices.size();
+ device_lock->unlock();
+
+ return dc;
+ }
+
+ virtual String get_device_name(int p_device) const {
+
+ ERR_FAIL_INDEX_V(p_device, devices.size(), "");
+ device_lock->lock();
+ String s = devices[p_device].name;
+ device_lock->unlock();
+ return s;
+ }
+
+ virtual String get_device_info(int p_device) const {
+
+ ERR_FAIL_INDEX_V(p_device, devices.size(), "");
+ device_lock->lock();
+ String s = devices[p_device].description;
+ device_lock->unlock();
+ return s;
+ }
+
+ virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
+
+ ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER);
+ device_lock->lock();
+
+ EditorProgress ep("run", "Running on " + devices[p_device].name, 3);
+
+ String adb = EditorSettings::get_singleton()->get("export/android/adb");
+ if (adb == "") {
+
+ EditorNode::add_io_error("ADB executable not configured in settings, can't run.");
+ device_lock->unlock();
+ return ERR_UNCONFIGURED;
+ }
+
+ //export_temp
+ ep.step("Exporting APK", 0);
+
+ bool use_adb_over_usb = bool(EDITOR_DEF("export/android/use_remote_debug_over_adb", true));
+
+ if (use_adb_over_usb) {
+ p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST;
+ }
+
+ String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk";
+ Error err = export_project(p_preset, true, export_to, p_debug_flags);
+ if (err) {
+ device_lock->unlock();
+ return err;
+ }
+
+ List<String> args;
+ int rv;
+
+ bool remove_prev = p_preset->get("one_click_deploy/clear_previous_install");
+ String version_name = p_preset->get("version/name");
+ String package_name = p_preset->get("package/unique_name");
+
+ if (remove_prev) {
+ ep.step("Uninstalling..", 1);
+
+ print_line("Uninstalling previous version: " + devices[p_device].name);
+
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("uninstall");
+ args.push_back(get_package_name(package_name));
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+#if 0
+ if (err || rv!=0) {
+ EditorNode::add_io_error("Could not install to device.");
+ device_lock->unlock();
+ return ERR_CANT_CREATE;
+ }
+#endif
+ }
+
+ print_line("Installing into device (please wait..): " + devices[p_device].name);
+ ep.step("Installing to Device (please wait..)..", 2);
+
+ args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("install");
+ args.push_back("-r");
+ args.push_back(export_to);
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ if (err || rv != 0) {
+ EditorNode::add_io_error("Could not install to device.");
+ device_lock->unlock();
+ return ERR_CANT_CREATE;
+ }
+
+ if (use_adb_over_usb) {
+
+ args.clear();
+ args.push_back("reverse");
+ args.push_back("--remove-all");
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+
+ int port = GlobalConfig::get_singleton()->get("network/debug/remote_port");
+ args.clear();
+ args.push_back("reverse");
+ args.push_back("tcp:" + itos(port));
+ args.push_back("tcp:" + itos(port));
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ print_line("Reverse result: " + itos(rv));
+
+ int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port");
+
+ args.clear();
+ args.push_back("reverse");
+ args.push_back("tcp:" + itos(fs_port));
+ args.push_back("tcp:" + itos(fs_port));
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ print_line("Reverse result2: " + itos(rv));
+ }
+
+ ep.step("Running on Device..", 3);
+ args.clear();
+ args.push_back("-s");
+ args.push_back(devices[p_device].id);
+ args.push_back("shell");
+ args.push_back("am");
+ args.push_back("start");
+ args.push_back("--user 0");
+ args.push_back("-a");
+ args.push_back("android.intent.action.MAIN");
+ args.push_back("-n");
+ args.push_back(get_package_name(package_name) + "/org.godotengine.godot.Godot");
+
+ err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
+ if (err || rv != 0) {
+ EditorNode::add_io_error("Could not execute ondevice.");
+ device_lock->unlock();
+ return ERR_CANT_CREATE;
+ }
+ device_lock->unlock();
+ return OK;
+ }
+
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+
+ r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String();
+
+ bool valid = !r_missing_templates;
+
+ String adb = EditorSettings::get_singleton()->get("export/android/adb");
+ String err;
+
+ if (!FileAccess::exists(adb)) {
+
+ valid = false;
+ err += "ADB executable not configured in editor settings.\n";
+ }
+
+ String js = EditorSettings::get_singleton()->get("export/android/jarsigner");
+
+ if (!FileAccess::exists(js)) {
+
+ valid = false;
+ err += "OpenJDK 6 jarsigner not configured in editor settings.\n";
+ }
+
+ String dk = EditorSettings::get_singleton()->get("export/android/debug_keystore");
+
+ if (!FileAccess::exists(dk)) {
+
+ valid = false;
+ err += "Debug Keystore not configured in editor settings.\n";
+ }
+
+ bool apk_expansion = p_preset->get("apk_expansion/enable");
+
+ if (apk_expansion) {
+
+ /*
+ if (apk_expansion_salt=="") {
+ valid=false;
+ err+="Invalid SALT for apk expansion.\n";
+ }
+ */
+
+ String apk_expansion_pkey = p_preset->get("apk_expansion/public_key");
+
+ if (apk_expansion_pkey == "") {
+ valid = false;
+
+ err += "Invalid public key for apk expansion.\n";
+ }
+ }
+
+ r_error = err;
+ return valid;
+ }
+
+ virtual String get_binary_extension() const {
+ return "apk";
+ }
+
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {
+
+ String src_apk;
+
+ EditorProgress ep("export", "Exporting for Android", 105);
+
+ if (p_debug)
+ src_apk = p_preset->get("custom_package/debug");
+ else
+ src_apk = p_preset->get("custom_package/release");
+
+ src_apk = src_apk.strip_edges();
+ if (src_apk == "") {
+ if (p_debug) {
+ src_apk = find_export_template("android_debug.apk");
+ } else {
+ src_apk = find_export_template("android_release.apk");
+ }
+ if (src_apk == "") {
+ EditorNode::add_io_error("Package not found: " + src_apk);
+ return ERR_FILE_NOT_FOUND;
+ }
+ }
+
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ ep.step("Creating APK", 0);
+
+ unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io);
+ if (!pkg) {
+
+ EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk);
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
+ int ret = unzGoToFirstFile(pkg);
+
+ zlib_filefunc_def io2 = io;
+ FileAccess *dst_f = NULL;
+ io2.opaque = &dst_f;
+ String unaligned_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport-unaligned.apk";
+ zipFile unaligned_apk = zipOpen2(unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
+
+ bool export_x86 = p_preset->get("architecture/x86");
+ bool export_arm = p_preset->get("architecture/arm");
+
+ bool use_32_fb = p_preset->get("screen/use_32_bits_view");
+ bool immersive = p_preset->get("screen/immersive_mode");
+
+ bool _signed = p_preset->get("package/signed");
+
+ bool apk_expansion = p_preset->get("apk_expansion/enable");
+
+ String cmdline = p_preset->get("command_line/extra_args");
+
+ int version_code = p_preset->get("version/code");
+ String version_name = p_preset->get("version/name");
+ String package_name = p_preset->get("package/unique_name");
+
+ String apk_expansion_pkey = p_preset->get("apk_expansion/public_key");
+
+ String release_keystore = p_preset->get("keystore/release");
+ String release_username = p_preset->get("keystore/release_user");
+ String release_password = p_preset->get("keystore/release_password");
+
+ while (ret == UNZ_OK) {
+
+ //get filename
+ unz_file_info info;
+ char fname[16384];
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
+
+ bool skip = false;
+
+ String file = fname;
+
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ //read
+ unzOpenCurrentFile(pkg);
+ unzReadCurrentFile(pkg, data.ptr(), data.size());
+ unzCloseCurrentFile(pkg);
+
+ //write
+
+ if (file == "AndroidManifest.xml") {
+
+ _fix_manifest(p_preset, data, p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG));
+ }
+
+ if (file == "resources.arsc") {
+
+ _fix_resources(p_preset, data);
+ }
+
+ if (file == "res/drawable/icon.png") {
+
+ String icon = p_preset->get("package/icon");
+ icon = icon.strip_edges();
+ bool found = false;
+
+ if (icon != "" && icon.ends_with(".png")) {
+
+ FileAccess *f = FileAccess::open(icon, FileAccess::READ);
+ if (f) {
+
+ data.resize(f->get_len());
+ f->get_buffer(data.ptr(), data.size());
+ memdelete(f);
+ found = true;
+ }
+ }
+
+ if (!found) {
+
+ String appicon = GlobalConfig::get_singleton()->get("application/icon");
+ if (appicon != "" && appicon.ends_with(".png")) {
+ FileAccess *f = FileAccess::open(appicon, FileAccess::READ);
+ if (f) {
+ data.resize(f->get_len());
+ f->get_buffer(data.ptr(), data.size());
+ memdelete(f);
+ }
+ }
+ }
+ }
+
+ if (file == "lib/x86/libgodot_android.so" && !export_x86) {
+ skip = true;
+ }
+
+ if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) {
+ skip = true;
+ }
+
+ if (file.begins_with("META-INF") && _signed) {
+ skip = true;
+ }
+
+ print_line("ADDING: " + file);
+
+ if (!skip) {
+
+ // Respect decision on compression made by AAPT for the export template
+ const bool uncompressed = info.compression_method == 0;
+
+ zip_fileinfo zipfi = get_zip_fileinfo();
+
+ zipOpenNewFileInZip(unaligned_apk,
+ file.utf8().get_data(),
+ &zipfi,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ uncompressed ? 0 : Z_DEFLATED,
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(unaligned_apk, data.ptr(), data.size());
+ zipCloseFileInZip(unaligned_apk);
+ }
+
+ ret = unzGoToNextFile(pkg);
+ }
+
+ ep.step("Adding Files..", 1);
+ Error err = OK;
+ Vector<String> cl = cmdline.strip_edges().split(" ");
+ for (int i = 0; i < cl.size(); i++) {
+ if (cl[i].strip_edges().length() == 0) {
+ cl.remove(i);
+ i--;
+ }
+ }
+
+ gen_export_flags(cl, p_flags);
+
+ if (p_flags & DEBUG_FLAG_DUMB_CLIENT) {
+
+ /*String host = EditorSettings::get_singleton()->get("filesystem/file_server/host");
+ int port = EditorSettings::get_singleton()->get("filesystem/file_server/post");
+ String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password");
+ cl.push_back("-rfs");
+ cl.push_back(host+":"+itos(port));
+ if (passwd!="") {
+ cl.push_back("-rfs_pass");
+ cl.push_back(passwd);
+ }*/
+
+ } else {
+ //all files
+
+ if (apk_expansion) {
+
+ String apkfname = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb";
+ String fullpath = p_path.get_base_dir().plus_file(apkfname);
+ err = save_pack(p_preset, fullpath);
+ if (err != OK) {
+ EditorNode::add_io_error("Could not write expansion package file: " + apkfname);
+ return OK;
+ }
+
+ cl.push_back("-use_apk_expansion");
+ cl.push_back("-apk_expansion_md5");
+ cl.push_back(FileAccess::get_md5(fullpath));
+ cl.push_back("-apk_expansion_key");
+ cl.push_back(apk_expansion_pkey.strip_edges());
+
+ } else {
+
+ APKExportData ed;
+ ed.ep = &ep;
+ ed.apk = unaligned_apk;
+
+ err = export_project_files(p_preset, save_apk_file, &ed);
+ }
+ }
+
+ if (use_32_fb)
+ cl.push_back("-use_depth_32");
+
+ if (immersive)
+ cl.push_back("-use_immersive");
+
+ if (cl.size()) {
+ //add comandline
+ Vector<uint8_t> clf;
+ clf.resize(4);
+ encode_uint32(cl.size(), &clf[0]);
+ for (int i = 0; i < cl.size(); i++) {
+
+ CharString txt = cl[i].utf8();
+ int base = clf.size();
+ clf.resize(base + 4 + txt.length());
+ encode_uint32(txt.length(), &clf[base]);
+ copymem(&clf[base + 4], txt.ptr(), txt.length());
+ print_line(itos(i) + " param: " + cl[i]);
+ }
+
+ zip_fileinfo zipfi = get_zip_fileinfo();
+
+ zipOpenNewFileInZip(unaligned_apk,
+ "assets/_cl_",
+ &zipfi,
+ NULL,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ 0, // No compress (little size gain and potentially slower startup)
+ Z_DEFAULT_COMPRESSION);
+
+ zipWriteInFileInZip(unaligned_apk, clf.ptr(), clf.size());
+ zipCloseFileInZip(unaligned_apk);
+ }
+
+ zipClose(unaligned_apk, NULL);
+ unzClose(pkg);
+
+ if (err) {
+ return err;
+ }
+
+ if (_signed) {
+
+ String jarsigner = EditorSettings::get_singleton()->get("export/android/jarsigner");
+ if (!FileAccess::exists(jarsigner)) {
+ EditorNode::add_io_error("'jarsigner' could not be found.\nPlease supply a path in the editor settings.\nResulting apk is unsigned.");
+ return OK;
+ }
+
+ String keystore;
+ String password;
+ String user;
+ if (p_debug) {
+ keystore = EditorSettings::get_singleton()->get("export/android/debug_keystore");
+ password = EditorSettings::get_singleton()->get("export/android/debug_keystore_pass");
+ user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user");
+
+ ep.step("Signing Debug APK..", 103);
+
+ } else {
+ keystore = release_keystore;
+ password = release_password;
+ user = release_username;
+
+ ep.step("Signing Release APK..", 103);
+ }
+
+ if (!FileAccess::exists(keystore)) {
+ EditorNode::add_io_error("Could not find keystore, unable to export.");
+ return ERR_FILE_CANT_OPEN;
+ }
+
+ List<String> args;
+ args.push_back("-digestalg");
+ args.push_back("SHA1");
+ args.push_back("-sigalg");
+ args.push_back("MD5withRSA");
+ String tsa_url = EditorSettings::get_singleton()->get("export/android/timestamping_authority_url");
+ if (tsa_url != "") {
+ args.push_back("-tsa");
+ args.push_back(tsa_url);
+ }
+ args.push_back("-verbose");
+ args.push_back("-keystore");
+ args.push_back(keystore);
+ args.push_back("-storepass");
+ args.push_back(password);
+ args.push_back(unaligned_path);
+ args.push_back(user);
+ int retval;
+ OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval);
+ if (retval) {
+ EditorNode::add_io_error("'jarsigner' returned with error #" + itos(retval));
+ return ERR_CANT_CREATE;
+ }
+
+ ep.step("Verifying APK..", 104);
+
+ args.clear();
+ args.push_back("-verify");
+ args.push_back("-keystore");
+ args.push_back(keystore);
+ args.push_back(unaligned_path);
+ args.push_back("-verbose");
+
+ OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval);
+ if (retval) {
+ EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use jarsigner from Java 6.");
+ return ERR_CANT_CREATE;
+ }
+ }
+
+ // Let's zip-align (must be done after signing)
+
+ static const int ZIP_ALIGNMENT = 4;
+
+ ep.step("Aligning APK..", 105);
+
+ unzFile tmp_unaligned = unzOpen2(unaligned_path.utf8().get_data(), &io);
+ if (!tmp_unaligned) {
+
+ EditorNode::add_io_error("Could not find temp unaligned APK.");
+ return ERR_FILE_NOT_FOUND;
+ }
+
+ ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN);
+ ret = unzGoToFirstFile(tmp_unaligned);
+
+ io2 = io;
+ dst_f = NULL;
+ io2.opaque = &dst_f;
+ zipFile final_apk = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
+
+ // Take files from the unaligned APK and write them out to the aligned one
+ // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed,
+ // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp
+ int bias = 0;
+ while (ret == UNZ_OK) {
+
+ unz_file_info info;
+ memset(&info, 0, sizeof(info));
+
+ char fname[16384];
+ char extra[16384];
+ ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, NULL, 0);
+
+ String file = fname;
+
+ Vector<uint8_t> data;
+ data.resize(info.compressed_size);
+
+ // read
+ int method, level;
+ unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read
+ long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned);
+ unzReadCurrentFile(tmp_unaligned, data.ptr(), data.size());
+ unzCloseCurrentFile(tmp_unaligned);
+
+ // align
+ int padding = 0;
+ if (!info.compression_method) {
+ // Uncompressed file => Align
+ long new_offset = file_offset + bias;
+ padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT;
+ }
+
+ memset(extra + info.size_file_extra, 0, padding);
+
+ // write
+ zip_fileinfo zipfi = get_zip_fileinfo();
+
+ zipOpenNewFileInZip2(final_apk,
+ file.utf8().get_data(),
+ &zipfi,
+ extra,
+ info.size_file_extra + padding,
+ NULL,
+ 0,
+ NULL,
+ method,
+ level,
+ 1); // raw write
+ zipWriteInFileInZip(final_apk, data.ptr(), data.size());
+ zipCloseFileInZipRaw(final_apk, info.uncompressed_size, info.crc);
+
+ bias += padding;
+
+ ret = unzGoToNextFile(tmp_unaligned);
+ }
+
+ zipClose(final_apk, NULL);
+ unzClose(tmp_unaligned);
+
+ if (err) {
+ return err;
+ }
+
+ return OK;
+ }
+
+ EditorExportAndroid() {
+
+ Image img(_android_logo);
+ logo = Ref<ImageTexture>(memnew(ImageTexture));
+ logo->create_from_image(img);
+
+ device_lock = Mutex::create();
+ device_thread = Thread::create(_device_poll_thread, this);
+ devices_changed = true;
+ quit_request = false;
+ }
+
+ ~EditorExportAndroid() {
+ quit_request = true;
+ Thread::wait_to_finish(device_thread);
+ memdelete(device_lock);
+ memdelete(device_thread);
+ }
+};
+
+void register_android_exporter() {
+
+ String exe_ext;
+ if (OS::get_singleton()->get_name() == "Windows") {
+ exe_ext = "*.exe";
+ }
+
+ EDITOR_DEF("export/android/adb", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/adb", PROPERTY_HINT_GLOBAL_FILE, exe_ext));
+ EDITOR_DEF("export/android/jarsigner", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/jarsigner", PROPERTY_HINT_GLOBAL_FILE, exe_ext));
+ EDITOR_DEF("export/android/debug_keystore", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore"));
+ EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey");
+ EDITOR_DEF("export/android/debug_keystore_pass", "android");
+
+ EDITOR_DEF("export/android/timestamping_authority_url", "");
+ EDITOR_DEF("export/android/use_remote_debug_over_adb", false);
+ EDITOR_DEF("export/android/shutdown_adb_on_exit", true);
+
+ Ref<EditorExportAndroid> exporter = Ref<EditorExportAndroid>(memnew(EditorExportAndroid));
+ EditorExport::get_singleton()->add_export_platform(exporter);
}
diff --git a/platform/android/export/export.h b/platform/android/export/export.h
index 468b484177..e3b0b4aab6 100644
--- a/platform/android/export/export.h
+++ b/platform/android/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp
index 4426af4dad..be19f056b0 100644
--- a/platform/android/file_access_android.cpp
+++ b/platform/android/file_access_android.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h
index de131f19bc..0ee8cd7efe 100644
--- a/platform/android/file_access_android.h
+++ b/platform/android/file_access_android.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp
index b3624e9f26..e20ffd4f8a 100644
--- a/platform/android/file_access_jandroid.cpp
+++ b/platform/android/file_access_jandroid.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h
index b78d5e603c..9bb471246a 100644
--- a/platform/android/file_access_jandroid.h
+++ b/platform/android/file_access_jandroid.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp
index 60d7d8cb6b..f708ad5dd7 100644
--- a/platform/android/globals/global_defaults.cpp
+++ b/platform/android/globals/global_defaults.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/globals/global_defaults.h b/platform/android/globals/global_defaults.h
index 49d7f6393c..d524b56af6 100644
--- a/platform/android/globals/global_defaults.h
+++ b/platform/android/globals/global_defaults.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp
index 9d300940b0..3a21f9212f 100644
--- a/platform/android/godot_android.cpp
+++ b/platform/android/godot_android.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/com/android/vending/licensing/Obfuscator.java b/platform/android/java/src/com/android/vending/licensing/Obfuscator.java
index b5d510d72d..88891728e6 100644
--- a/platform/android/java/src/com/android/vending/licensing/Obfuscator.java
+++ b/platform/android/java/src/com/android/vending/licensing/Obfuscator.java
@@ -20,7 +20,7 @@ package com.google.android.vending.licensing;
* Interface used as part of a {@link Policy} to allow application authors to obfuscate
* licensing data that will be stored into a SharedPreferences file.
* <p>
- * Any transformation scheme must be reversable. Implementing classes may optionally implement an
+ * Any transformation scheme must be reversible. Implementing classes may optionally implement an
* integrity check to further prevent modification to preference data. Implementing classes
* should use device-specific information as a key in the obfuscation algorithm to prevent
* obfuscated preferences from being shared among devices.
diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java
index 72f0b7a60e..b9501e0858 100644
--- a/platform/android/java/src/org/godotengine/godot/Dictionary.java
+++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java
index 610f707b47..88928089b6 100644
--- a/platform/android/java/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/src/org/godotengine/godot/Godot.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -340,7 +341,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
r = is.read(len);
if (r<4) {
- Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
+ Log.d("GODOT", "**ERROR** Wrong cmdline param length.\n");
return new String[0];
}
int strlen=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
@@ -721,7 +722,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
@Override public void onBackPressed() {
System.out.printf("** BACK REQUEST!\n");
- GodotLib.back();
+ //GodotLib.back();
}
public void forceQuit() {
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
index 5a07d680b3..6cdc6be793 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
index fba082e80d..38d30c108c 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java
index 33c1c03ace..ecb623452c 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotIO.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -469,7 +470,7 @@ public class GodotIO {
}
/////////////////////////
- // MISCELANEOUS OS IO
+ // MISCELLANEOUS OS IO
/////////////////////////
diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java
index 57856cfd6b..1ed04d9d27 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotLib.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
index 6eee8da91b..3cb8fd3da8 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java
index 4cfe295835..c6c68c36b0 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotView.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotView.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -77,18 +78,18 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
private static GodotIO io;
private static boolean firsttime=true;
- private static boolean use_gl2=false;
+ private static boolean use_gl3=false;
private static boolean use_32=false;
private Godot activity;
private InputManagerCompat mInputManager;
- public GodotView(Context context,GodotIO p_io,boolean p_use_gl2, boolean p_use_32_bits, Godot p_activity) {
+ public GodotView(Context context,GodotIO p_io,boolean p_use_gl3, boolean p_use_32_bits, Godot p_activity) {
super(context);
ctx=context;
io=p_io;
- use_gl2=p_use_gl2;
+ use_gl3=p_use_gl3;
use_32=p_use_32_bits;
activity = p_activity;
@@ -362,14 +363,15 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
private static class ContextFactory implements GLSurfaceView.EGLContextFactory {
private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
- if (use_gl2)
- Log.w(TAG, "creating OpenGL ES 2.0 context :");
+ if (use_gl3)
+ Log.w(TAG, "creating OpenGL ES 3.0 context :");
else
- Log.w(TAG, "creating OpenGL ES 1.1 context :");
+ Log.w(TAG, "creating OpenGL ES 2.0 context :");
checkEglError("Before eglCreateContext", egl);
int[] attrib_list2 = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
- EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, use_gl2?attrib_list2:null);
+ int[] attrib_list3 = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL10.EGL_NONE };
+ EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, use_gl3?attrib_list3:attrib_list2);
checkEglError("After eglCreateContext", egl);
return context;
}
@@ -432,13 +434,14 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE
};
- private static int[] s_configAttribs =
+ private static int[] s_configAttribs3 =
{
EGL10.EGL_RED_SIZE, 4,
EGL10.EGL_GREEN_SIZE, 4,
EGL10.EGL_BLUE_SIZE, 4,
// EGL10.EGL_DEPTH_SIZE, 16,
// EGL10.EGL_STENCIL_SIZE, EGL10.EGL_DONT_CARE,
+ EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, //apparently there is no EGL_OPENGL_ES3_BIT
EGL10.EGL_NONE
};
@@ -447,7 +450,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
/* Get the number of minimally matching EGL configurations
*/
int[] num_config = new int[1];
- egl.eglChooseConfig(display, use_gl2?s_configAttribs2:s_configAttribs, null, 0, num_config);
+ egl.eglChooseConfig(display, use_gl3?s_configAttribs3:s_configAttribs2, null, 0, num_config);
int numConfigs = num_config[0];
@@ -458,7 +461,7 @@ public class GodotView extends GLSurfaceView implements InputDeviceListener {
/* Allocate then read the array of minimally matching EGL configs
*/
EGLConfig[] configs = new EGLConfig[numConfigs];
- egl.eglChooseConfig(display, use_gl2?s_configAttribs2:s_configAttribs, configs, numConfigs, num_config);
+ egl.eglChooseConfig(display, use_gl3?s_configAttribs3:s_configAttribs2, configs, numConfigs, num_config);
if (DEBUG) {
printConfigs(egl, display, configs);
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
index f0dae03a81..bf5239aa77 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
index 3c8207fae1..1dbcb78ada 100644
--- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
+++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
index 67293df2a8..c37821ffd9 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
index dfa363ed75..72126a8f64 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
index 3850453a77..e223bbb8c0 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
index 4678dae1b3..fa5564a3f4 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
index 73d1cc3bc8..044efba1f3 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
index 5ad96b35ee..81352b0cf4 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
index 60a43a9070..9d40371b9b 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
index f09bcbf9a4..09f80df403 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
index f8936bef2b..02a2fba854 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
index 823c75d186..7881754fb2 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
index faefbbd2c6..b314fb721b 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
index bb00f1f468..41d26ba70f 100644
--- a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
+++ b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp
index eb208f0ee0..56a27fa0e0 100644
--- a/platform/android/java_class_wrapper.cpp
+++ b/platform/android/java_class_wrapper.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/java_class_wrapper.h b/platform/android/java_class_wrapper.h
index dcc9973446..f990708bdf 100644
--- a/platform/android/java_class_wrapper.h
+++ b/platform/android/java_class_wrapper.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -68,9 +69,9 @@ class JavaClass : public Reference {
jmethodID method;
};
- _FORCE_INLINE_ static void _convert_to_variant_type(int p_sig, Variant::Type &r_type, float &likelyhood) {
+ _FORCE_INLINE_ static void _convert_to_variant_type(int p_sig, Variant::Type &r_type, float &likelihood) {
- likelyhood = 1.0;
+ likelihood = 1.0;
r_type = Variant::NIL;
switch (p_sig) {
@@ -81,37 +82,37 @@ class JavaClass : public Reference {
case ARG_TYPE_BYTE | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_BYTE:
r_type = Variant::INT;
- likelyhood = 0.1;
+ likelihood = 0.1;
break;
case ARG_TYPE_CHAR | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_CHAR:
r_type = Variant::INT;
- likelyhood = 0.2;
+ likelihood = 0.2;
break;
case ARG_TYPE_SHORT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_SHORT:
r_type = Variant::INT;
- likelyhood = 0.3;
+ likelihood = 0.3;
break;
case ARG_TYPE_INT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_INT:
r_type = Variant::INT;
- likelyhood = 1.0;
+ likelihood = 1.0;
break;
case ARG_TYPE_LONG | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_LONG:
r_type = Variant::INT;
- likelyhood = 0.5;
+ likelihood = 0.5;
break;
case ARG_TYPE_FLOAT | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_FLOAT:
r_type = Variant::REAL;
- likelyhood = 1.0;
+ likelihood = 1.0;
break;
case ARG_TYPE_DOUBLE | ARG_NUMBER_CLASS_BIT:
case ARG_TYPE_DOUBLE:
r_type = Variant::REAL;
- likelyhood = 0.5;
+ likelihood = 0.5;
break;
case ARG_TYPE_STRING: r_type = Variant::STRING; break;
case ARG_TYPE_CLASS: r_type = Variant::OBJECT; break;
@@ -119,31 +120,31 @@ class JavaClass : public Reference {
case ARG_ARRAY_BIT | ARG_TYPE_BOOLEAN: r_type = Variant::ARRAY; break;
case ARG_ARRAY_BIT | ARG_TYPE_BYTE:
r_type = Variant::POOL_BYTE_ARRAY;
- likelyhood = 1.0;
+ likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_CHAR:
r_type = Variant::POOL_BYTE_ARRAY;
- likelyhood = 0.5;
+ likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_SHORT:
r_type = Variant::POOL_INT_ARRAY;
- likelyhood = 0.3;
+ likelihood = 0.3;
break;
case ARG_ARRAY_BIT | ARG_TYPE_INT:
r_type = Variant::POOL_INT_ARRAY;
- likelyhood = 1.0;
+ likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_LONG:
r_type = Variant::POOL_INT_ARRAY;
- likelyhood = 0.5;
+ likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_FLOAT:
r_type = Variant::POOL_REAL_ARRAY;
- likelyhood = 1.0;
+ likelihood = 1.0;
break;
case ARG_ARRAY_BIT | ARG_TYPE_DOUBLE:
r_type = Variant::POOL_REAL_ARRAY;
- likelyhood = 0.5;
+ likelihood = 0.5;
break;
case ARG_ARRAY_BIT | ARG_TYPE_STRING: r_type = Variant::POOL_STRING_ARRAY; break;
case ARG_ARRAY_BIT | ARG_TYPE_CLASS: r_type = Variant::ARRAY; break;
diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp
index 4016b44434..6882dad4f0 100644
--- a/platform/android/java_glue.cpp
+++ b/platform/android/java_glue.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -350,7 +351,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
jobjectArray arr = (jobjectArray)obj;
int objCount = env->GetArrayLength(arr);
- Array varr(true);
+ Array varr;
for (int i = 0; i < objCount; i++) {
jobject jobj = env->GetObjectArrayElement(arr, i);
@@ -364,7 +365,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) {
if (name == "java.util.HashMap" || name == "org.godotengine.godot.Dictionary") {
- Dictionary ret(true);
+ Dictionary ret;
jclass oclass = c;
jmethodID get_keys = env->GetMethodID(oclass, "get_keys", "()[Ljava/lang/String;");
jobjectArray arr = (jobjectArray)env->CallObjectMethod(obj, get_keys);
@@ -881,7 +882,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
__android_log_print(ANDROID_LOG_INFO, "godot", "*****SETUP OK");
- //video driver is determined here, because once initialized, it cant be changed
+ //video driver is determined here, because once initialized, it can't be changed
String vd = GlobalConfig::get_singleton()->get("display/driver");
env->CallVoidMethod(_godot_instance, _on_video_init, (jboolean) true);
@@ -929,7 +930,16 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, job
static void _initialize_java_modules() {
+ if (!GlobalConfig::get_singleton()->has("android/modules")) {
+ print_line("ANDROID MODULES: Nothing to load, aborting");
+ return;
+ }
+
String modules = GlobalConfig::get_singleton()->get("android/modules");
+ modules = modules.strip_edges();
+ if (modules == String()) {
+ return;
+ }
Vector<String> mods = modules.split(",", false);
print_line("ANDROID MODULES : " + modules);
__android_log_print(ANDROID_LOG_INFO, "godot", "mod count: %i", mods.size());
diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h
index 51a2031867..f400f41e28 100644
--- a/platform/android/java_glue.h
+++ b/platform/android/java_glue.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 705f0df46e..6772964c2f 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -30,13 +31,13 @@
#include "core/global_config.h"
#include "core/io/file_access_buffered_fa.h"
-#include "drivers/gles2/rasterizer_gles2.h"
+#include "drivers/gles3/rasterizer_gles3.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
#include "file_access_android.h"
#include "main/main.h"
#include "servers/visual/visual_server_raster.h"
-#include "servers/visual/visual_server_wrap_mt.h"
+//#include "servers/visual/visual_server_wrap_mt.h"
#ifdef ANDROID_NATIVE_ACTIVITY
#include "dir_access_android.h"
@@ -125,18 +126,14 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
AudioDriverManager::add_driver(&audio_driver_android);
- RasterizerGLES2 *rasterizer_gles22 = memnew(RasterizerGLES2(false, use_reload_hooks, false, use_reload_hooks));
- if (gl_extensions)
- rasterizer_gles22->set_extensions(gl_extensions);
- rasterizer = rasterizer_gles22;
+ RasterizerGLES3::register_config();
+ RasterizerGLES3::make_current();
- rasterizer->set_force_16_bits_fbo(use_16bits_fbo);
-
- visual_server = memnew(VisualServerRaster(rasterizer));
- if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
+ visual_server = memnew(VisualServerRaster);
+ /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerWrapMT(visual_server, false));
- };
+ };*/
visual_server->init();
visual_server->cursor_set_visible(false, 0);
@@ -156,7 +153,7 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
input = memnew(InputDefault);
input->set_fallback_mapping("Default Android Gamepad");
- power_manager = memnew(power_android);
+ //power_manager = memnew(power_android);
}
void OS_Android::set_main_loop(MainLoop *p_main_loop) {
@@ -227,7 +224,7 @@ void OS_Android::print(const char *p_format, ...) {
void OS_Android::alert(const String &p_alert, const String &p_title) {
- print("ALERT: %s\n", p_alert.utf8().get_data());
+ //print("ALERT: %s\n", p_alert.utf8().get_data());
if (alert_func)
alert_func(p_alert, p_title);
}
@@ -248,7 +245,7 @@ bool OS_Android::is_mouse_grab_enabled() const {
return false;
}
-Point2 OS_Android::get_mouse_pos() const {
+Point2 OS_Android::get_mouse_position() const {
return Point2();
}
@@ -347,16 +344,16 @@ void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
switch (p_event.type) {
case JOY_EVENT_BUTTON:
- last_id = input->joy_button(last_id, p_event.device, p_event.index, p_event.pressed);
+ input->joy_button(p_event.device, p_event.index, p_event.pressed);
break;
case JOY_EVENT_AXIS:
InputDefault::JoyAxis value;
value.min = -1;
value.value = p_event.value;
- last_id = input->joy_axis(last_id, p_event.device, p_event.index, value);
+ input->joy_axis(p_event.device, p_event.index, value);
break;
case JOY_EVENT_HAT:
- last_id = input->joy_hat(last_id, p_event.device, p_event.hat);
+ input->joy_hat(p_event.device, p_event.hat);
break;
default:
return;
@@ -365,7 +362,6 @@ void OS_Android::process_joy_event(OS_Android::JoypadEvent p_event) {
void OS_Android::process_event(InputEvent p_event) {
- p_event.ID = last_id++;
input->parse_input_event(p_event);
}
@@ -380,7 +376,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
//end all if exist
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = false;
@@ -394,7 +389,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -413,7 +407,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
//send mouse
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = true;
@@ -421,7 +414,7 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
ev.mouse_button.y = touch[0].pos.y;
ev.mouse_button.global_x = touch[0].pos.x;
ev.mouse_button.global_y = touch[0].pos.y;
- input->set_mouse_pos(Point2(touch[0].pos.x,touch[0].pos.y));
+ input->set_mouse_position(Point2(touch[0].pos.x, touch[0].pos.y));
last_mouse = touch[0].pos;
input->parse_input_event(ev);
}
@@ -431,7 +424,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = true;
ev.screen_touch.x = touch[i].pos.x;
@@ -446,11 +438,10 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
//send mouse, should look for point 0?
InputEvent ev;
ev.type = InputEvent::MOUSE_MOTION;
- ev.ID = last_id++;
ev.mouse_motion.button_mask = BUTTON_MASK_LEFT;
ev.mouse_motion.x = p_points[0].pos.x;
ev.mouse_motion.y = p_points[0].pos.y;
- input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
+ input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_motion.speed_x = input->get_last_mouse_speed().x;
ev.mouse_motion.speed_y = input->get_last_mouse_speed().y;
ev.mouse_motion.relative_x = p_points[0].pos.x - last_mouse.x;
@@ -479,7 +470,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
InputEvent ev;
ev.type = InputEvent::SCREEN_DRAG;
- ev.ID = last_id++;
ev.screen_drag.index = touch[i].id;
ev.screen_drag.x = p_points[idx].pos.x;
ev.screen_drag.y = p_points[idx].pos.y;
@@ -496,7 +486,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
//end all if exist
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = false;
@@ -504,14 +493,13 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
ev.mouse_button.y = touch[0].pos.y;
ev.mouse_button.global_x = touch[0].pos.x;
ev.mouse_button.global_y = touch[0].pos.y;
- input->set_mouse_pos(Point2(touch[0].pos.x,touch[0].pos.y));
+ input->set_mouse_position(Point2(touch[0].pos.x, touch[0].pos.y));
input->parse_input_event(ev);
for (int i = 0; i < touch.size(); i++) {
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -531,7 +519,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = tp.id;
ev.screen_touch.pressed = true;
ev.screen_touch.x = tp.pos.x;
@@ -546,7 +533,6 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos>
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -631,8 +617,8 @@ void OS_Android::reload_gfx() {
if (gfx_init_func)
gfx_init_func(gfx_init_ud, use_gl2);
- if (rasterizer)
- rasterizer->reload_vram();
+ //if (rasterizer)
+ // rasterizer->reload_vram();
}
Error OS_Android::shell_open(String p_uri) {
@@ -750,9 +736,9 @@ void OS_Android::native_video_stop() {
void OS_Android::set_context_is_16_bits(bool p_is_16) {
- use_16bits_fbo = p_is_16;
- if (rasterizer)
- rasterizer->set_force_16_bits_fbo(p_is_16);
+ //use_16bits_fbo = p_is_16;
+ //if (rasterizer)
+ // rasterizer->set_force_16_bits_fbo(p_is_16);
}
void OS_Android::joy_connection_changed(int p_device, bool p_connected, String p_name) {
@@ -778,9 +764,8 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI
gfx_init_func = p_gfx_init_func;
gfx_init_ud = p_gfx_init_ud;
main_loop = NULL;
- last_id = 1;
gl_extensions = NULL;
- rasterizer = NULL;
+ //rasterizer = NULL;
use_gl2 = false;
open_uri_func = p_open_uri_func;
diff --git a/platform/android/os_android.h b/platform/android/os_android.h
index 2c0be8e3c1..f1da2867f0 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -35,7 +36,7 @@
#include "main/input_default.h"
#include "os/input.h"
#include "os/main_loop.h"
-#include "power_android.h"
+//#include "power_android.h"
#include "servers/audio_server.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
@@ -94,7 +95,6 @@ private:
Vector<TouchPos> touch;
Point2 last_mouse;
- unsigned int last_id;
GFXInitFunc gfx_init_func;
void *gfx_init_ud;
@@ -104,7 +104,6 @@ private:
bool use_16bits_fbo;
- Rasterizer *rasterizer;
VisualServer *visual_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
@@ -141,7 +140,7 @@ private:
SetKeepScreenOnFunc set_keep_screen_on_func;
AlertFunc alert_func;
- power_android *power_manager;
+ //power_android *power_manager;
public:
// functions used by main to initialize/deintialize the OS
@@ -172,7 +171,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/android/platform_config.h b/platform/android/platform_config.h
index cdef185ff0..48bcadcc29 100644
--- a/platform/android/platform_config.h
+++ b/platform/android/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/power_android.cpp b/platform/android/power_android.cpp
index aa37dc51e2..57977dd4b9 100644
--- a/platform/android/power_android.cpp
+++ b/platform/android/power_android.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/power_android.h b/platform/android/power_android.h
index df4983bbf3..328a4506a1 100644
--- a/platform/android/power_android.h
+++ b/platform/android/power_android.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index 854cdb1e34..401f3cd73b 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h
index a8d8a4d8b1..6174066968 100644
--- a/platform/android/thread_jandroid.h
+++ b/platform/android/thread_jandroid.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/audio_driver_bb10.cpp b/platform/bb10/audio_driver_bb10.cpp
index 5416fc5f02..5658dc5334 100644
--- a/platform/bb10/audio_driver_bb10.cpp
+++ b/platform/bb10/audio_driver_bb10.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/audio_driver_bb10.h b/platform/bb10/audio_driver_bb10.h
index 2a0ed9c545..c5d64236b8 100644
--- a/platform/bb10/audio_driver_bb10.h
+++ b/platform/bb10/audio_driver_bb10.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp
index c958bf7ff4..b620cea230 100644
--- a/platform/bb10/export/export.cpp
+++ b/platform/bb10/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/export/export.h b/platform/bb10/export/export.h
index d8407c4152..7939754bfa 100644
--- a/platform/bb10/export/export.h
+++ b/platform/bb10/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/godot_bb10.cpp b/platform/bb10/godot_bb10.cpp
index e1826450a6..4d382ddd15 100644
--- a/platform/bb10/godot_bb10.cpp
+++ b/platform/bb10/godot_bb10.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp
index 80e846d3cd..b571d1640c 100644
--- a/platform/bb10/os_bb10.cpp
+++ b/platform/bb10/os_bb10.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -216,7 +217,7 @@ bool OSBB10::is_mouse_grab_enabled() const {
//*sigh* technology has evolved so much since i was a kid..
return false;
}
-Point2 OSBB10::get_mouse_pos() const {
+Point2 OSBB10::get_mouse_position() const {
return Point2();
}
@@ -282,7 +283,6 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
InputEvent ievent;
ievent.type = InputEvent::SCREEN_TOUCH;
- ievent.ID = ++last_id;
ievent.device = 0;
ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH);
ievent.screen_touch.x = pos[0];
@@ -301,7 +301,6 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
InputEvent ievent;
ievent.type = InputEvent::MOUSE_BUTTON;
- ievent.ID = ++last_id;
ievent.device = 0;
ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH);
ievent.mouse_button.button_index = BUTTON_LEFT;
@@ -318,7 +317,6 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
InputEvent ievent;
ievent.type = InputEvent::SCREEN_DRAG;
- ievent.ID = ++last_id;
ievent.device = 0;
ievent.screen_drag.x = pos[0];
ievent.screen_drag.y = pos[1];
@@ -347,11 +345,10 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
InputEvent ievent;
ievent.type = InputEvent::MOUSE_MOTION;
- ievent.ID = ++last_id;
ievent.device = 0;
ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x;
ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y;
- input->set_mouse_pos(Point2(ievent.mouse_motion.x, ievent.mouse_motion.y));
+ input->set_mouse_position(Point2(ievent.mouse_motion.x, ievent.mouse_motion.y));
ievent.mouse_motion.speed_x = input->get_last_mouse_speed().x;
ievent.mouse_motion.speed_y = input->get_last_mouse_speed().y;
ievent.mouse_motion.relative_x = mrel.x;
@@ -366,7 +363,6 @@ void OSBB10::handle_screen_event(bps_event_t *event) {
InputEvent ievent;
ievent.type = InputEvent::KEY;
- ievent.ID = ++last_id;
ievent.device = 0;
int val = 0;
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SCAN, &val);
@@ -595,7 +591,6 @@ int OSBB10::get_power_percent_left() {
OSBB10::OSBB10() {
main_loop = NULL;
- last_id = 1;
minimized = false;
fullscreen = true;
flip_accelerometer = true;
diff --git a/platform/bb10/os_bb10.h b/platform/bb10/os_bb10.h
index 313f9c9e6b..91149b6f68 100644
--- a/platform/bb10/os_bb10.h
+++ b/platform/bb10/os_bb10.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -48,8 +49,6 @@
class OSBB10 : public OS_Unix {
- unsigned int last_id;
-
screen_context_t screen_cxt;
float fullscreen_mixer_volume;
float fullscreen_stream_volume;
@@ -114,7 +113,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/bb10/payment_service.cpp b/platform/bb10/payment_service.cpp
index e78326e8b1..353845583f 100644
--- a/platform/bb10/payment_service.cpp
+++ b/platform/bb10/payment_service.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/payment_service.h b/platform/bb10/payment_service.h
index d5b4cc3d60..64dc982ab2 100644
--- a/platform/bb10/payment_service.h
+++ b/platform/bb10/payment_service.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/platform_config.h b/platform/bb10/platform_config.h
index cdef185ff0..48bcadcc29 100644
--- a/platform/bb10/platform_config.h
+++ b/platform/bb10/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/power_bb10.cpp b/platform/bb10/power_bb10.cpp
index 29c1fe370d..a683b61376 100644
--- a/platform/bb10/power_bb10.cpp
+++ b/platform/bb10/power_bb10.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/bb10/power_bb10.h b/platform/bb10/power_bb10.h
index 6c13f6e997..c5c18d5f69 100644
--- a/platform/bb10/power_bb10.h
+++ b/platform/bb10/power_bb10.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
index 0f969d25ab..9c4f6d3aba 100644
--- a/platform/haiku/audio_driver_media_kit.cpp
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h
index e9282c8471..2cceb279e8 100644
--- a/platform/haiku/audio_driver_media_kit.h
+++ b/platform/haiku/audio_driver_media_kit.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp
index f345928005..eb5e60152f 100644
--- a/platform/haiku/context_gl_haiku.cpp
+++ b/platform/haiku/context_gl_haiku.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h
index c0030fad41..074b4bf0d1 100644
--- a/platform/haiku/context_gl_haiku.h
+++ b/platform/haiku/context_gl_haiku.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/detect.py b/platform/haiku/detect.py
index 71202a9a49..54e227cd19 100644
--- a/platform/haiku/detect.py
+++ b/platform/haiku/detect.py
@@ -53,7 +53,7 @@ def configure(env):
elif (env["target"] == "release_debug"):
env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
# env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np
diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp
index 47cfbe55d7..3a8206d9d5 100644
--- a/platform/haiku/godot_haiku.cpp
+++ b/platform/haiku/godot_haiku.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp
index f675d4216d..1f0c9fdcbf 100644
--- a/platform/haiku/haiku_application.cpp
+++ b/platform/haiku/haiku_application.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h
index 7fbce5dcbc..6e690d4ab8 100644
--- a/platform/haiku/haiku_application.h
+++ b/platform/haiku/haiku_application.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index bc2dbb9b8f..fb6d9afd85 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -151,7 +152,6 @@ void HaikuDirectWindow::HandleMouseButton(BMessage *message) {
*/
InputEvent mouse_event;
- mouse_event.ID = ++event_id;
mouse_event.type = InputEvent::MOUSE_BUTTON;
mouse_event.device = 0;
@@ -208,7 +208,6 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage *message) {
Point2i rel = pos - last_mouse_position;
InputEvent motion_event;
- motion_event.ID = ++event_id;
motion_event.type = InputEvent::MOUSE_MOTION;
motion_event.device = 0;
@@ -216,7 +215,7 @@ void HaikuDirectWindow::HandleMouseMoved(BMessage *message) {
motion_event.mouse_motion.button_mask = GetMouseButtonState(buttons);
motion_event.mouse_motion.x = pos.x;
motion_event.mouse_motion.y = pos.y;
- input->set_mouse_pos(pos);
+ input->set_mouse_position(pos);
motion_event.mouse_motion.global_x = pos.x;
motion_event.mouse_motion.global_y = pos.y;
motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x;
@@ -237,7 +236,6 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage *message) {
}
InputEvent mouse_event;
- mouse_event.ID = ++event_id;
mouse_event.type = InputEvent::MOUSE_BUTTON;
mouse_event.device = 0;
@@ -252,7 +250,6 @@ void HaikuDirectWindow::HandleMouseWheelChanged(BMessage *message) {
mouse_event.mouse_button.pressed = true;
input->parse_input_event(mouse_event);
- mouse_event.ID = ++event_id;
mouse_event.mouse_button.pressed = false;
input->parse_input_event(mouse_event);
}
@@ -275,7 +272,6 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
}
InputEvent event;
- event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
@@ -289,7 +285,7 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
event.key.unicode = BUnicodeChar::FromUTF8(&bytes);
}
- //make it consistent accross platforms.
+ //make it consistent across platforms.
if (event.key.scancode == KEY_BACKTAB) {
event.key.scancode = KEY_TAB;
event.key.mod.shift = true;
@@ -313,7 +309,6 @@ void HaikuDirectWindow::HandleKeyboardModifierEvent(BMessage *message) {
int32 key = old_modifiers ^ modifiers;
InputEvent event;
- event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h
index 7fcea7a6f6..3671c3c9cb 100644
--- a/platform/haiku/haiku_direct_window.h
+++ b/platform/haiku/haiku_direct_window.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -43,7 +44,6 @@
class HaikuDirectWindow : public BDirectWindow {
private:
- unsigned int event_id;
Point2i last_mouse_position;
bool last_mouse_pos_valid;
uint32 last_buttons_state;
diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp
index ded15e12a7..dd568f281e 100644
--- a/platform/haiku/haiku_gl_view.cpp
+++ b/platform/haiku/haiku_gl_view.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h
index f06bc64794..14e2889d6c 100644
--- a/platform/haiku/haiku_gl_view.h
+++ b/platform/haiku/haiku_gl_view.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp
index 1bc3467914..9df7b2f047 100644
--- a/platform/haiku/key_mapping_haiku.cpp
+++ b/platform/haiku/key_mapping_haiku.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h
index 0f2e2e64bd..8d09203737 100644
--- a/platform/haiku/key_mapping_haiku.h
+++ b/platform/haiku/key_mapping_haiku.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index 0853fac393..3131f2bf1e 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -206,7 +207,7 @@ void OS_Haiku::swap_buffers() {
context_gl->swap_buffers();
}
-Point2 OS_Haiku::get_mouse_pos() const {
+Point2 OS_Haiku::get_mouse_position() const {
return window->GetLastMousePosition();
}
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index 827814c7e9..83e44734a6 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -88,7 +89,7 @@ public:
virtual void make_rendering_thread();
virtual void swap_buffers();
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_cursor_shape(CursorShape p_shape);
diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h
index a3aa918ba8..e59b9bac80 100644
--- a/platform/haiku/platform_config.h
+++ b/platform/haiku/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/power_haiku.cpp b/platform/haiku/power_haiku.cpp
index d70aad9d5f..b0d01df982 100644
--- a/platform/haiku/power_haiku.cpp
+++ b/platform/haiku/power_haiku.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/haiku/power_haiku.h b/platform/haiku/power_haiku.h
index 8e7b050cd6..711ad86a02 100644
--- a/platform/haiku/power_haiku.h
+++ b/platform/haiku/power_haiku.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h
index eaa74946ee..f357427144 100644
--- a/platform/iphone/app_delegate.h
+++ b/platform/iphone/app_delegate.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 00bb4b9fad..e075941d36 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -27,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#import "app_delegate.h"
-#import "gl_view.h"
-#include "os_iphone.h"
#include "core/global_config.h"
+#import "gl_view.h"
#include "main/main.h"
+#include "os_iphone.h"
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
#include "modules/FacebookScorer_ios/FacebookScorer.h"
@@ -44,24 +45,24 @@
#endif
#ifdef MODULE_PARSE_ENABLED
-#import <Parse/Parse.h>
#import "FBSDKCoreKit/FBSDKCoreKit.h"
+#import <Parse/Parse.h>
#endif
-#define kFilteringFactor 0.1
-#define kRenderingFrequency 60
-#define kAccelerometerFrequency 100.0 // Hz
+#define kFilteringFactor 0.1
+#define kRenderingFrequency 60
+#define kAccelerometerFrequency 100.0 // Hz
Error _shell_open(String);
void _set_keep_screen_on(bool p_enabled);
Error _shell_open(String p_uri) {
- NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
+ NSString *url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()];
- if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]])
- return ERR_CANT_OPEN;
+ if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]])
+ return ERR_CANT_OPEN;
- printf("opening url %ls\n", p_uri.c_str());
+ printf("opening url %ls\n", p_uri.c_str());
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
[url release];
return OK;
@@ -76,174 +77,170 @@ void _set_keep_screen_on(bool p_enabled) {
@synthesize window;
extern int gargc;
-extern char** gargv;
-extern int iphone_main(int, int, int, char**);
+extern char **gargv;
+extern int iphone_main(int, int, int, char **);
extern void iphone_finish();
CMMotionManager *motionManager;
-bool motionInitialised;
+bool motionInitialised;
-static ViewController* mainViewController = nil;
-+ (ViewController*) getViewController
-{
+static ViewController *mainViewController = nil;
++ (ViewController *)getViewController {
return mainViewController;
}
static int frame_count = 0;
-- (void)drawView:(GLView*)view; {
+- (void)drawView:(GLView *)view;
+{
switch (frame_count) {
-
- case 0: {
- int backingWidth;
- int backingHeight;
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
- glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
-
-
- OS::VideoMode vm;
- vm.fullscreen = true;
- vm.width = backingWidth;
- vm.height = backingHeight;
- vm.resizable = false;
- OS::get_singleton()->set_video_mode(vm);
-
- if (!OS::get_singleton()) {
- exit(0);
- };
- ++frame_count;
-
- NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentsDirectory = [paths objectAtIndex:0];
- //NSString *documentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
- OSIPhone::get_singleton()->set_data_dir(String::utf8([documentsDirectory UTF8String]));
-
- NSString *locale_code = [[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2];
- OSIPhone::get_singleton()->set_locale(String::utf8([locale_code UTF8String]));
-
- NSString* uuid;
- if ([[UIDevice currentDevice]respondsToSelector:@selector(identifierForVendor)]) {
- uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
- }else{
-
- // before iOS 6, so just generate an identifier and store it
- uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"];
- if( !uuid ) {
- CFUUIDRef cfuuid = CFUUIDCreate(NULL);
- uuid = (__bridge_transfer NSString*)CFUUIDCreateString(NULL, cfuuid);
- CFRelease(cfuuid);
- [[NSUserDefaults standardUserDefaults] setObject:uuid forKey:@"identifierForVendor"];
+ case 0: {
+ int backingWidth;
+ int backingHeight;
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
+ glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
+
+ OS::VideoMode vm;
+ vm.fullscreen = true;
+ vm.width = backingWidth;
+ vm.height = backingHeight;
+ vm.resizable = false;
+ OS::get_singleton()->set_video_mode(vm);
+
+ if (!OS::get_singleton()) {
+ exit(0);
+ };
+ ++frame_count;
+
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ //NSString *documentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
+ OSIPhone::get_singleton()->set_data_dir(String::utf8([documentsDirectory UTF8String]));
+
+ NSString *locale_code = [[[NSLocale preferredLanguages] objectAtIndex:0] substringToIndex:2];
+ OSIPhone::get_singleton()->set_locale(String::utf8([locale_code UTF8String]));
+
+ NSString *uuid;
+ if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
+ uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
+ } else {
+ // before iOS 6, so just generate an identifier and store it
+ uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"identiferForVendor"];
+ if (!uuid) {
+ CFUUIDRef cfuuid = CFUUIDCreate(NULL);
+ uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, cfuuid);
+ CFRelease(cfuuid);
+ [[NSUserDefaults standardUserDefaults] setObject:uuid forKey:@"identifierForVendor"];
+ }
}
- }
- OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String]));
+ OSIPhone::get_singleton()->set_unique_ID(String::utf8([uuid UTF8String]));
- }; break;
-/*
- case 1: {
- ++frame_count;
- } break;
+ }; break;
+ /*
+ case 1: {
+ ++frame_count;
+ }; break;
*/
- case 1: {
+ case 1: {
- Main::setup2();
- ++frame_count;
+ Main::setup2();
+ ++frame_count;
- // this might be necessary before here
- NSDictionary* dict = [[NSBundle mainBundle] infoDictionary];
- for (NSString* key in dict) {
- NSObject* value = [dict objectForKey:key];
- String ukey = String::utf8([key UTF8String]);
+ // this might be necessary before here
+ NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
+ for (NSString *key in dict) {
+ NSObject *value = [dict objectForKey:key];
+ String ukey = String::utf8([key UTF8String]);
- // we need a NSObject to Variant conversor
+ // we need a NSObject to Variant conversor
- if ([value isKindOfClass:[NSString class]]) {
- NSString* str = (NSString*)value;
- String uval = String::utf8([str UTF8String]);
+ if ([value isKindOfClass:[NSString class]]) {
+ NSString *str = (NSString *)value;
+ String uval = String::utf8([str UTF8String]);
- GlobalConfig::get_singleton()->set("Info.plist/"+ukey, uval);
+ GlobalConfig::get_singleton()->set("Info.plist/" + ukey, uval);
- } else if ([value isKindOfClass:[NSNumber class]]) {
+ } else if ([value isKindOfClass:[NSNumber class]]) {
- NSNumber* n = (NSNumber*)value;
- double dval = [n doubleValue];
+ NSNumber *n = (NSNumber *)value;
+ double dval = [n doubleValue];
- GlobalConfig::get_singleton()->set("Info.plist/"+ukey, dval);
- };
- // do stuff
- }
-
- } break;
-/*
- case 3: {
- ++frame_count;
- } break;
-*/
- case 2: {
-
- Main::start();
- ++frame_count;
-
- }; break; // no fallthrough
-
- default: {
- if (OSIPhone::get_singleton()) {
-// OSIPhone::get_singleton()->update_accelerometer(accel[0], accel[1], accel[2]);
- if (motionInitialised) {
- // Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
- // See Apple reference pages for more details:
- // https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
-
- // Apple splits our accelerometer date into a gravity and user movement component. We add them back together
- CMAcceleration gravity = motionManager.deviceMotion.gravity;
- CMAcceleration acceleration = motionManager.deviceMotion.userAcceleration;
-
- ///@TODO We don't seem to be getting data here, is my device broken or is this code incorrect?
- CMMagneticField magnetic = motionManager.deviceMotion.magneticField.field;
-
- ///@TODO we can access rotationRate as a CMRotationRate variable (processed date) or CMGyroData (raw data), have to see what works best
- CMRotationRate rotation = motionManager.deviceMotion.rotationRate;
-
- // Adjust for screen orientation.
- // [[UIDevice currentDevice] orientation] changes even if we've fixed our orientation which is not
- // a good thing when you're trying to get your user to move the screen in all directions and want consistent output
-
- ///@TODO Using [[UIApplication sharedApplication] statusBarOrientation] is a bit of a hack. Godot obviously knows the orientation so maybe we
- // can use that instead? (note that left and right seem swapped)
-
- switch ([[UIApplication sharedApplication] statusBarOrientation]) {
- case UIDeviceOrientationLandscapeLeft: {
- OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x, gravity.z);
- OSIPhone::get_singleton()->update_accelerometer(-(acceleration.y + gravity.y), (acceleration.x + gravity.x), acceleration.z + gravity.z);
- OSIPhone::get_singleton()->update_magnetometer(-magnetic.y, magnetic.x, magnetic.z);
- OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x, rotation.z);
- }; break;
- case UIDeviceOrientationLandscapeRight: {
- OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x, gravity.z);
- OSIPhone::get_singleton()->update_accelerometer((acceleration.y + gravity.y), -(acceleration.x + gravity.x), acceleration.z + gravity.z);
- OSIPhone::get_singleton()->update_magnetometer(magnetic.y, -magnetic.x, magnetic.z);
- OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x, rotation.z);
- }; break;
- case UIDeviceOrientationPortraitUpsideDown: {
- OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y, gravity.z);
- OSIPhone::get_singleton()->update_accelerometer(-(acceleration.x + gravity.x), (acceleration.y + gravity.y), acceleration.z + gravity.z);
- OSIPhone::get_singleton()->update_magnetometer(-magnetic.x, magnetic.y, magnetic.z);
- OSIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y, rotation.z);
- }; break;
- default: { // assume portrait
- OSIPhone::get_singleton()->update_gravity(gravity.x, gravity.y, gravity.z);
- OSIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z);
- OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z);
- OSIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y, rotation.z);
- }; break;
+ GlobalConfig::get_singleton()->set("Info.plist/" + ukey, dval);
};
+ // do stuff
}
- bool quit_request = OSIPhone::get_singleton()->iterate();
- };
-
- };
+ }; break;
+ /*
+ case 3: {
+ ++frame_count;
+ }; break;
+*/
+ case 2: {
+
+ Main::start();
+ ++frame_count;
+
+ }; break; // no fallthrough
+
+ default: {
+ if (OSIPhone::get_singleton()) {
+ //OSIPhone::get_singleton()->update_accelerometer(accel[0], accel[1], accel[2]);
+ if (motionInitialised) {
+ // Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
+ // See Apple reference pages for more details:
+ // https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
+
+ // Apple splits our accelerometer date into a gravity and user movement component. We add them back together
+ CMAcceleration gravity = motionManager.deviceMotion.gravity;
+ CMAcceleration acceleration = motionManager.deviceMotion.userAcceleration;
+
+ ///@TODO We don't seem to be getting data here, is my device broken or is this code incorrect?
+ CMMagneticField magnetic = motionManager.deviceMotion.magneticField.field;
+
+ ///@TODO we can access rotationRate as a CMRotationRate variable (processed date) or CMGyroData (raw data), have to see what works best
+ CMRotationRate rotation = motionManager.deviceMotion.rotationRate;
+
+ // Adjust for screen orientation.
+ // [[UIDevice currentDevice] orientation] changes even if we've fixed our orientation which is not
+ // a good thing when you're trying to get your user to move the screen in all directions and want consistent output
+
+ ///@TODO Using [[UIApplication sharedApplication] statusBarOrientation] is a bit of a hack. Godot obviously knows the orientation so maybe we
+ // can use that instead? (note that left and right seem swapped)
+
+ switch ([[UIApplication sharedApplication] statusBarOrientation]) {
+ case UIDeviceOrientationLandscapeLeft: {
+ OSIPhone::get_singleton()->update_gravity(-gravity.y, gravity.x, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(-(acceleration.y + gravity.y), (acceleration.x + gravity.x), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(-magnetic.y, magnetic.x, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(-rotation.y, rotation.x, rotation.z);
+ }; break;
+ case UIDeviceOrientationLandscapeRight: {
+ OSIPhone::get_singleton()->update_gravity(gravity.y, -gravity.x, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer((acceleration.y + gravity.y), -(acceleration.x + gravity.x), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(magnetic.y, -magnetic.x, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(rotation.y, -rotation.x, rotation.z);
+ }; break;
+ case UIDeviceOrientationPortraitUpsideDown: {
+ OSIPhone::get_singleton()->update_gravity(-gravity.x, gravity.y, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(-(acceleration.x + gravity.x), (acceleration.y + gravity.y), acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(-magnetic.x, magnetic.y, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(-rotation.x, rotation.y, rotation.z);
+ }; break;
+ default: { // assume portrait
+ OSIPhone::get_singleton()->update_gravity(gravity.x, gravity.y, gravity.z);
+ OSIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z);
+ OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z);
+ OSIPhone::get_singleton()->update_gyroscope(rotation.x, rotation.y, rotation.z);
+ }; break;
+ };
+ }
+
+ bool quit_request = OSIPhone::get_singleton()->iterate();
+ };
+ }; break;
};
};
@@ -253,7 +250,7 @@ static int frame_count = 0;
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_MEMORY_WARNING);
};
-- (void)applicationDidFinishLaunching:(UIApplication*)application {
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
printf("**************** app delegate init\n");
CGRect rect = [[UIScreen mainScreen] bounds];
@@ -286,8 +283,8 @@ static int frame_count = 0;
view_controller.view = glView;
window.rootViewController = view_controller;
- _set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on",true)) ? YES : NO);
- glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink",true)) ? YES : NO;
+ _set_keep_screen_on(bool(GLOBAL_DEF("display/keep_screen_on", true)) ? YES : NO);
+ glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink", true)) ? YES : NO;
printf("cadisaplylink: %d", glView.useCADisplayLink);
glView.animationInterval = 1.0 / kRenderingFrequency;
[glView startAnimation];
@@ -299,8 +296,8 @@ static int frame_count = 0;
if (!motionInitialised) {
motionManager = [[CMMotionManager alloc] init];
if (motionManager.deviceMotionAvailable) {
- motionManager.deviceMotionUpdateInterval = 1.0/70.0;
- [motionManager startDeviceMotionUpdates];
+ motionManager.deviceMotionUpdateInterval = 1.0 / 70.0;
+ [motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXMagneticNorthZVertical];
motionInitialised = YES;
};
};
@@ -311,36 +308,32 @@ static int frame_count = 0;
mainViewController = view_controller;
#ifdef MODULE_GAME_ANALYTICS_ENABLED
- printf("********************* didFinishLaunchingWithOptions\n");
- if(!GlobalConfig::get_singleton()->has("mobileapptracker/advertiser_id"))
- {
- return;
- }
- if(!GlobalConfig::get_singleton()->has("mobileapptracker/conversion_key"))
- {
- return;
- }
-
- String adid = GLOBAL_DEF("mobileapptracker/advertiser_id","");
- String convkey = GLOBAL_DEF("mobileapptracker/conversion_key","");
-
- NSString * advertiser_id = [NSString stringWithUTF8String:adid.utf8().get_data()];
- NSString * conversion_key = [NSString stringWithUTF8String:convkey.utf8().get_data()];
-
- // Account Configuration info - must be set
- [MobileAppTracker initializeWithMATAdvertiserId:advertiser_id
- MATConversionKey:conversion_key];
-
- // Used to pass us the IFA, enables highly accurate 1-to-1 attribution.
- // Required for many advertising networks.
- [MobileAppTracker setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier]
- advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
+ printf("********************* didFinishLaunchingWithOptions\n");
+ if (!GlobalConfig::get_singleton()->has("mobileapptracker/advertiser_id")) {
+ return;
+ }
+ if (!GlobalConfig::get_singleton()->has("mobileapptracker/conversion_key")) {
+ return;
+ }
-#endif
+ String adid = GLOBAL_DEF("mobileapptracker/advertiser_id", "");
+ String convkey = GLOBAL_DEF("mobileapptracker/conversion_key", "");
+
+ NSString *advertiser_id = [NSString stringWithUTF8String:adid.utf8().get_data()];
+ NSString *conversion_key = [NSString stringWithUTF8String:convkey.utf8().get_data()];
+
+ // Account Configuration info - must be set
+ [MobileAppTracker initializeWithMATAdvertiserId:advertiser_id MATConversionKey:conversion_key];
+
+ // Used to pass us the IFA, enables highly accurate 1-to-1 attribution.
+ // Required for many advertising networks.
+ [MobileAppTracker setAppleAdvertisingIdentifier:[[ASIdentifierManager sharedManager] advertisingIdentifier]
+ advertisingTrackingEnabled:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
+#endif
};
-- (void)applicationWillTerminate:(UIApplication*)application {
+- (void)applicationWillTerminate:(UIApplication *)application {
printf("********************* will terminate\n");
@@ -349,48 +342,46 @@ static int frame_count = 0;
[motionManager stopDeviceMotionUpdates];
[motionManager release];
motionManager = nil;
- motionInitialised = NO;
+ motionInitialised = NO;
};
iphone_finish();
};
-- (void)applicationDidEnterBackground:(UIApplication *)application
-{
+- (void)applicationDidEnterBackground:(UIApplication *)application {
printf("********************* did enter background\n");
///@TODO maybe add pause motionManager? and where would we unpause it?
if (OS::get_singleton()->get_main_loop())
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
+
[view_controller.view stopAnimation];
if (OS::get_singleton()->native_video_is_playing()) {
OSIPhone::get_singleton()->native_video_focus_out();
};
}
-- (void)applicationWillEnterForeground:(UIApplication *)application
-{
+- (void)applicationWillEnterForeground:(UIApplication *)application {
printf("********************* did enter foreground\n");
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
[view_controller.view startAnimation];
}
-- (void) applicationWillResignActive:(UIApplication *)application
-{
+- (void)applicationWillResignActive:(UIApplication *)application {
printf("********************* will resign active\n");
//OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
[view_controller.view stopAnimation]; // FIXME: pause seems to be recommended elsewhere
}
-- (void) applicationDidBecomeActive:(UIApplication *)application
-{
+- (void)applicationDidBecomeActive:(UIApplication *)application {
printf("********************* did become active\n");
#ifdef MODULE_GAME_ANALYTICS_ENABLED
- printf("********************* mobile app tracker found\n");
+ printf("********************* mobile app tracker found\n");
[MobileAppTracker measureSession];
#endif
if (OS::get_singleton()->get_main_loop())
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+
[view_controller.view startAnimation]; // FIXME: resume seems to be recommended elsewhere
if (OSIPhone::get_singleton()->native_video_is_playing()) {
OSIPhone::get_singleton()->native_video_unpause();
@@ -409,13 +400,13 @@ static int frame_count = 0;
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
#ifdef MODULE_PARSE_ENABLED
NSLog(@"Handling application openURL");
- return [[FBSDKApplicationDelegate sharedInstance] application:application
- openURL:url
- sourceApplication:sourceApplication
- annotation:annotation];
+ return [[FBSDKApplicationDelegate sharedInstance]
+ application:application
+ openURL:url
+ sourceApplication:sourceApplication
+ annotation:annotation];
#endif
-
#ifdef MODULE_FACEBOOKSCORER_IOS_ENABLED
return [[[FacebookScorer sharedInstance] facebook] handleOpenURL:url];
#else
@@ -449,8 +440,7 @@ static int frame_count = 0;
#endif
}
-- (void)dealloc
-{
+- (void)dealloc {
[window release];
[super dealloc];
}
diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp
index eff91fa40f..dea1ce405d 100644
--- a/platform/iphone/audio_driver_iphone.cpp
+++ b/platform/iphone/audio_driver_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h
index 8a0d92e070..c620e9068c 100644
--- a/platform/iphone/audio_driver_iphone.h
+++ b/platform/iphone/audio_driver_iphone.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py
index fa6082a5a7..248c73982b 100644
--- a/platform/iphone/detect.py
+++ b/platform/iphone/detect.py
@@ -58,16 +58,16 @@ def configure(env):
if (env["ios_sim"] == "yes" or env["arch"] == "x86"): # i386, simulator
env["arch"] = "x86"
env["bits"] = "32"
- env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"')
+ env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"')
elif (env["arch"] == "arm64"): # arm64
env["bits"] = "64"
- env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -fvisibility=hidden -Wno-sign-conversion -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK')
+ env['CCFLAGS'] = string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=7.0 -isysroot $IPHONESDK')
env.Append(CPPFLAGS=['-DNEED_LONG_INT'])
env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON'])
else: # armv7
env["arch"] = "arm"
env["bits"] = "32"
- env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot $IPHONESDK -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK')
+ env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=7.0 -MMD -MT dependencies -isysroot $IPHONESDK')
if (env["arch"] == "x86"):
env['IPHONEPLATFORM'] = 'iPhoneSimulator'
@@ -145,17 +145,17 @@ def configure(env):
if (env["target"] == "release"):
- env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-gdwarf-2']) # removed -ffast-math
+ env.Append(CCFLAGS=['-O3', '-DNS_BLOCK_ASSERTIONS=1', '-gdwarf-2']) # removed -ffast-math
env.Append(LINKFLAGS=['-O3'])
elif env["target"] == "release_debug":
- env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-Wall', '-DDEBUG_ENABLED'])
+ env.Append(CCFLAGS=['-Os', '-DNS_BLOCK_ASSERTIONS=1', '-DDEBUG_ENABLED'])
env.Append(LINKFLAGS=['-Os'])
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED'])
+ env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED'])
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED'])
elif (env["target"] == "profile"):
diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h
index a732a97a4c..cda6f78a1f 100644
--- a/platform/iphone/game_center.h
+++ b/platform/iphone/game_center.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm
index 4cfa64ae4b..f9bc70b7c4 100644
--- a/platform/iphone/game_center.mm
+++ b/platform/iphone/game_center.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -45,24 +46,23 @@ extern "C" {
#import "app_delegate.h"
};
-GameCenter* GameCenter::instance = NULL;
+GameCenter *GameCenter::instance = NULL;
void GameCenter::_bind_methods() {
- ClassDB::bind_method(D_METHOD("connect"),&GameCenter::connect);
- ClassDB::bind_method(D_METHOD("is_connected"),&GameCenter::is_connected);
-
- ClassDB::bind_method(D_METHOD("post_score"),&GameCenter::post_score);
- ClassDB::bind_method(D_METHOD("award_achievement"),&GameCenter::award_achievement);
- ClassDB::bind_method(D_METHOD("reset_achievements"),&GameCenter::reset_achievements);
- ClassDB::bind_method(D_METHOD("request_achievements"),&GameCenter::request_achievements);
- ClassDB::bind_method(D_METHOD("request_achievement_descriptions"),&GameCenter::request_achievement_descriptions);
- ClassDB::bind_method(D_METHOD("show_game_center"),&GameCenter::show_game_center);
-
- ClassDB::bind_method(D_METHOD("get_pending_event_count"),&GameCenter::get_pending_event_count);
- ClassDB::bind_method(D_METHOD("pop_pending_event"),&GameCenter::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("connect"), &GameCenter::connect);
+ ClassDB::bind_method(D_METHOD("is_connected"), &GameCenter::is_connected);
+
+ ClassDB::bind_method(D_METHOD("post_score"), &GameCenter::post_score);
+ ClassDB::bind_method(D_METHOD("award_achievement"), &GameCenter::award_achievement);
+ ClassDB::bind_method(D_METHOD("reset_achievements"), &GameCenter::reset_achievements);
+ ClassDB::bind_method(D_METHOD("request_achievements"), &GameCenter::request_achievements);
+ ClassDB::bind_method(D_METHOD("request_achievement_descriptions"), &GameCenter::request_achievement_descriptions);
+ ClassDB::bind_method(D_METHOD("show_game_center"), &GameCenter::show_game_center);
+
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"), &GameCenter::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"), &GameCenter::pop_pending_event);
};
-
Error GameCenter::connect() {
//if this class isn't available, game center isn't implemented
@@ -71,33 +71,34 @@ Error GameCenter::connect() {
return ERR_UNAVAILABLE;
}
- GKLocalPlayer* player = [GKLocalPlayer localPlayer];
+ GKLocalPlayer *player = [GKLocalPlayer localPlayer];
ERR_FAIL_COND_V(![player respondsToSelector:@selector(authenticateHandler)], ERR_UNAVAILABLE);
- ViewController *root_controller=(ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
+ ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
ERR_FAIL_COND_V(!root_controller, FAILED);
- //this handler is called serveral times. first when the view needs to be shown, then again after the view is cancelled or the user logs in. or if the user's already logged in, it's called just once to confirm they're authenticated. This is why no result needs to be specified in the presentViewController phase. in this case, more calls to this function will follow.
+ // This handler is called several times. First when the view needs to be shown, then again
+ // after the view is cancelled or the user logs in. Or if the user's already logged in, it's
+ // called just once to confirm they're authenticated. This is why no result needs to be specified
+ // in the presentViewController phase. In this case, more calls to this function will follow.
player.authenticateHandler = (^(UIViewController *controller, NSError *error) {
- if (controller) {
- [root_controller presentViewController:controller animated:YES completion:nil];
- }
- else {
- Dictionary ret;
- ret["type"] = "authentication";
- if (player.isAuthenticated) {
- ret["result"] = "ok";
- GameCenter::get_singleton()->connected = true;
- } else {
- ret["result"] = "error";
- ret["error_code"] = error.code;
- ret["error_description"] = [error.localizedDescription UTF8String];
- GameCenter::get_singleton()->connected = false;
- };
-
- pending_events.push_back(ret);
- };
-
+ if (controller) {
+ [root_controller presentViewController:controller animated:YES completion:nil];
+ } else {
+ Dictionary ret;
+ ret["type"] = "authentication";
+ if (player.isAuthenticated) {
+ ret["result"] = "ok";
+ GameCenter::get_singleton()->connected = true;
+ } else {
+ ret["result"] = "error";
+ ret["error_code"] = error.code;
+ ret["error_description"] = [error.localizedDescription UTF8String];
+ GameCenter::get_singleton()->connected = false;
+ };
+
+ pending_events.push_back(ret);
+ };
});
return OK;
@@ -114,26 +115,27 @@ Error GameCenter::post_score(Variant p_score) {
float score = params["score"];
String category = params["category"];
- NSString* cat_str = [[[NSString alloc] initWithUTF8String:category.utf8().get_data()] autorelease];
- GKScore* reporter = [[[GKScore alloc] initWithCategory:cat_str] autorelease];
+ NSString *cat_str = [[[NSString alloc] initWithUTF8String:category.utf8().get_data()] autorelease];
+ GKScore *reporter = [[[GKScore alloc] initWithCategory:cat_str] autorelease];
reporter.value = score;
ERR_FAIL_COND_V([GKScore respondsToSelector:@selector(reportScores)], ERR_UNAVAILABLE);
- [GKScore reportScores:@[reporter] withCompletionHandler:^(NSError* error) {
+ [GKScore reportScores:@[ reporter ]
+ withCompletionHandler:^(NSError *error) {
- Dictionary ret;
- ret["type"] = "post_score";
- if (error == nil) {
- ret["result"] = "ok";
- } else {
- ret["result"] = "error";
- ret["error_code"] = error.code;
- ret["error_description"] = [error.localizedDescription UTF8String];
- };
+ Dictionary ret;
+ ret["type"] = "post_score";
+ if (error == nil) {
+ ret["result"] = "ok";
+ } else {
+ ret["result"] = "error";
+ ret["error_code"] = error.code;
+ ret["error_description"] = [error.localizedDescription UTF8String];
+ };
- pending_events.push_back(ret);
- }];
+ pending_events.push_back(ret);
+ }];
return OK;
};
@@ -145,8 +147,8 @@ Error GameCenter::award_achievement(Variant p_params) {
String name = params["name"];
float progress = params["progress"];
- NSString* name_str = [[[NSString alloc] initWithUTF8String:name.utf8().get_data()] autorelease];
- GKAchievement* achievement = [[[GKAchievement alloc] initWithIdentifier: name_str] autorelease];
+ NSString *name_str = [[[NSString alloc] initWithUTF8String:name.utf8().get_data()] autorelease];
+ GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier:name_str] autorelease];
ERR_FAIL_COND_V(!achievement, FAILED);
ERR_FAIL_COND_V([GKAchievement respondsToSelector:@selector(reportAchievements)], ERR_UNAVAILABLE);
@@ -157,19 +159,20 @@ Error GameCenter::award_achievement(Variant p_params) {
achievement.showsCompletionBanner = params["show_completion_banner"] ? YES : NO;
}
- [GKAchievement reportAchievements:@[achievement] withCompletionHandler:^(NSError *error) {
+ [GKAchievement reportAchievements:@[ achievement ]
+ withCompletionHandler:^(NSError *error) {
- Dictionary ret;
- ret["type"] = "award_achievement";
- if (error == nil) {
- ret["result"] = "ok";
- } else {
- ret["result"] = "error";
- ret["error_code"] = error.code;
- };
+ Dictionary ret;
+ ret["type"] = "award_achievement";
+ if (error == nil) {
+ ret["result"] = "ok";
+ } else {
+ ret["result"] = "error";
+ ret["error_code"] = error.code;
+ };
- pending_events.push_back(ret);
- }];
+ pending_events.push_back(ret);
+ }];
return OK;
};
@@ -190,11 +193,11 @@ void GameCenter::request_achievement_descriptions() {
Array hidden;
Array replayable;
- for (int i=0; i<[descriptions count]; i++) {
+ for (int i = 0; i < [descriptions count]; i++) {
- GKAchievementDescription* description = [descriptions objectAtIndex:i];
+ GKAchievementDescription *description = [descriptions objectAtIndex:i];
- const char* str = [description.identifier UTF8String];
+ const char *str = [description.identifier UTF8String];
names.push_back(String::utf8(str != NULL ? str : ""));
str = [description.title UTF8String];
@@ -230,7 +233,6 @@ void GameCenter::request_achievement_descriptions() {
}];
};
-
void GameCenter::request_achievements() {
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
@@ -242,10 +244,10 @@ void GameCenter::request_achievements() {
PoolStringArray names;
PoolRealArray percentages;
- for (int i=0; i<[achievements count]; i++) {
+ for (int i = 0; i < [achievements count]; i++) {
- GKAchievement* achievement = [achievements objectAtIndex:i];
- const char* str = [achievement.identifier UTF8String];
+ GKAchievement *achievement = [achievements objectAtIndex:i];
+ const char *str = [achievement.identifier UTF8String];
names.push_back(String::utf8(str != NULL ? str : ""));
percentages.push_back(achievement.percentComplete);
@@ -265,8 +267,7 @@ void GameCenter::request_achievements() {
void GameCenter::reset_achievements() {
- [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error)
- {
+ [GKAchievement resetAchievementsWithCompletionHandler:^(NSError *error) {
Dictionary ret;
ret["type"] = "reset_achievements";
if (error == nil) {
@@ -291,17 +292,13 @@ Error GameCenter::show_game_center(Variant p_params) {
String view_name = params["view"];
if (view_name == "default") {
view_state = GKGameCenterViewControllerStateDefault;
- }
- else if (view_name == "leaderboards") {
+ } else if (view_name == "leaderboards") {
view_state = GKGameCenterViewControllerStateLeaderboards;
- }
- else if (view_name == "achievements") {
+ } else if (view_name == "achievements") {
view_state = GKGameCenterViewControllerStateAchievements;
- }
- else if (view_name == "challenges") {
+ } else if (view_name == "challenges") {
view_state = GKGameCenterViewControllerStateChallenges;
- }
- else {
+ } else {
return ERR_INVALID_PARAMETER;
}
}
@@ -309,7 +306,7 @@ Error GameCenter::show_game_center(Variant p_params) {
GKGameCenterViewController *controller = [[GKGameCenterViewController alloc] init];
ERR_FAIL_COND_V(!controller, FAILED);
- ViewController *root_controller=(ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
+ ViewController *root_controller = (ViewController *)((AppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController;
ERR_FAIL_COND_V(!root_controller, FAILED);
controller.gameCenterDelegate = root_controller;
@@ -318,12 +315,12 @@ Error GameCenter::show_game_center(Variant p_params) {
controller.leaderboardIdentifier = nil;
if (params.has("leaderboard_name")) {
String name = params["leaderboard_name"];
- NSString* name_str = [[[NSString alloc] initWithUTF8String:name.utf8().get_data()] autorelease];
+ NSString *name_str = [[[NSString alloc] initWithUTF8String:name.utf8().get_data()] autorelease];
controller.leaderboardIdentifier = name_str;
}
}
- [root_controller presentViewController: controller animated: YES completion:nil];
+ [root_controller presentViewController:controller animated:YES completion:nil];
return OK;
};
@@ -331,7 +328,7 @@ Error GameCenter::show_game_center(Variant p_params) {
void GameCenter::game_center_closed() {
Dictionary ret;
- ret["type"] = "show_game_center";
+ ret["type"] = "show_game_center";
ret["result"] = "ok";
pending_events.push_back(ret);
}
@@ -349,7 +346,7 @@ Variant GameCenter::pop_pending_event() {
return front;
};
-GameCenter* GameCenter::get_singleton() {
+GameCenter *GameCenter::get_singleton() {
return instance;
};
@@ -359,9 +356,6 @@ GameCenter::GameCenter() {
connected = false;
};
-
-GameCenter::~GameCenter() {
-
-};
+GameCenter::~GameCenter(){};
#endif
diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h
index 555e34a895..14e9a66a4a 100644
--- a/platform/iphone/gl_view.h
+++ b/platform/iphone/gl_view.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index adc76a622e..6270fa85f2 100755..100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,15 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#import "gl_view.h"
-#import <QuartzCore/QuartzCore.h>
-#import <OpenGLES/EAGLDrawable.h>
-#include "os_iphone.h"
-#include "core/os/keyboard.h"
#include "core/global_config.h"
+#include "core/os/keyboard.h"
+#include "os_iphone.h"
#include "servers/audio_server.h"
-#import "gl_view.h"
+#import <OpenGLES/EAGLDrawable.h>
+#import <QuartzCore/QuartzCore.h>
/*
@interface GLView (private)
@@ -47,7 +48,7 @@
int gl_view_base_fb;
static String keyboard_text;
-static GLView* _instance = NULL;
+static GLView *_instance = NULL;
static bool video_found_error = false;
static bool video_playing = false;
@@ -78,21 +79,22 @@ void _hide_keyboard() {
bool _play_video(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
p_path = GlobalConfig::get_singleton()->globalize_path(p_path);
- NSString* file_path = [[[NSString alloc] initWithUTF8String:p_path.utf8().get_data()] autorelease];
+ NSString *file_path = [[[NSString alloc] initWithUTF8String:p_path.utf8().get_data()] autorelease];
_instance.avAsset = [AVAsset assetWithURL:[NSURL fileURLWithPath:file_path]];
- _instance.avPlayerItem =[[AVPlayerItem alloc]initWithAsset:_instance.avAsset];
+ _instance.avPlayerItem = [[AVPlayerItem alloc] initWithAsset:_instance.avAsset];
[_instance.avPlayerItem addObserver:_instance forKeyPath:@"status" options:0 context:nil];
- _instance.avPlayer = [[AVPlayer alloc]initWithPlayerItem:_instance.avPlayerItem];
- _instance.avPlayerLayer =[AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
+ _instance.avPlayer = [[AVPlayer alloc] initWithPlayerItem:_instance.avPlayerItem];
+ _instance.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:_instance.avPlayer];
[_instance.avPlayer addObserver:_instance forKeyPath:@"status" options:0 context:nil];
- [[NSNotificationCenter defaultCenter] addObserver:_instance
- selector:@selector(playerItemDidReachEnd:)
- name:AVPlayerItemDidPlayToEndTimeNotification
- object:[_instance.avPlayer currentItem]];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:_instance
+ selector:@selector(playerItemDidReachEnd:)
+ name:AVPlayerItemDidPlayToEndTimeNotification
+ object:[_instance.avPlayer currentItem]];
[_instance.avPlayer addObserver:_instance forKeyPath:@"rate" options:NSKeyValueObservingOptionNew context:0];
@@ -100,16 +102,14 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
[_instance.layer addSublayer:_instance.avPlayerLayer];
[_instance.avPlayer play];
- AVMediaSelectionGroup *audioGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicAudible];
+ AVMediaSelectionGroup *audioGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicAudible];
NSMutableArray *allAudioParams = [NSMutableArray array];
- for (id track in audioGroup.options)
- {
- NSString* language = [[track locale] localeIdentifier];
+ for (id track in audioGroup.options) {
+ NSString *language = [[track locale] localeIdentifier];
NSLog(@"subtitle lang: %@", language);
- if ([language isEqualToString:[NSString stringWithUTF8String:p_audio_track.utf8()]])
- {
+ if ([language isEqualToString:[NSString stringWithUTF8String:p_audio_track.utf8()]]) {
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
[audioInputParams setVolume:p_volume atTime:kCMTimeZero];
[audioInputParams setTrackID:[track trackID]];
@@ -118,26 +118,24 @@ bool _play_video(String p_path, float p_volume, String p_audio_track, String p_s
AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix];
[audioMix setInputParameters:allAudioParams];
- [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: audioGroup];
+ [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup:audioGroup];
[_instance.avPlayer.currentItem setAudioMix:audioMix];
- break;
- }
+ break;
+ }
}
- AVMediaSelectionGroup *subtitlesGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicLegible];
+ AVMediaSelectionGroup *subtitlesGroup = [_instance.avAsset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
NSArray *useableTracks = [AVMediaSelectionGroup mediaSelectionOptionsFromArray:subtitlesGroup.options withoutMediaCharacteristics:[NSArray arrayWithObject:AVMediaCharacteristicContainsOnlyForcedSubtitles]];
- for (id track in useableTracks)
- {
- NSString* language = [[track locale] localeIdentifier];
+ for (id track in useableTracks) {
+ NSString *language = [[track locale] localeIdentifier];
NSLog(@"subtitle lang: %@", language);
- if ([language isEqualToString:[NSString stringWithUTF8String:p_subtitle_track.utf8()]])
- {
- [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup: subtitlesGroup];
- break;
- }
+ if ([language isEqualToString:[NSString stringWithUTF8String:p_subtitle_track.utf8()]]) {
+ [_instance.avPlayer.currentItem selectMediaOption:track inMediaSelectionGroup:subtitlesGroup];
+ break;
+ }
}
video_playing = true;
@@ -181,19 +179,19 @@ void _stop_video() {
@synthesize animationInterval;
static const int max_touches = 8;
-static UITouch* touches[max_touches];
+static UITouch *touches[max_touches];
static void init_touches() {
- for (int i=0; i<max_touches; i++) {
+ for (int i = 0; i < max_touches; i++) {
touches[i] = NULL;
};
};
-static int get_touch_id(UITouch* p_touch) {
+static int get_touch_id(UITouch *p_touch) {
int first = -1;
- for (int i=0; i<max_touches; i++) {
+ for (int i = 0; i < max_touches; i++) {
if (first == -1 && touches[i] == NULL) {
first = i;
continue;
@@ -210,10 +208,10 @@ static int get_touch_id(UITouch* p_touch) {
return -1;
};
-static int remove_touch(UITouch* p_touch) {
+static int remove_touch(UITouch *p_touch) {
int remaining = 0;
- for (int i=0; i<max_touches; i++) {
+ for (int i = 0; i < max_touches; i++) {
if (touches[i] == NULL)
continue;
@@ -225,9 +223,9 @@ static int remove_touch(UITouch* p_touch) {
return remaining;
};
-static int get_first_id(UITouch* p_touch) {
+static int get_first_id(UITouch *p_touch) {
- for (int i=0; i<max_touches; i++) {
+ for (int i = 0; i < max_touches; i++) {
if (touches[i] != NULL)
return i;
@@ -237,7 +235,7 @@ static int get_first_id(UITouch* p_touch) {
static void clear_touches() {
- for (int i=0; i<max_touches; i++) {
+ for (int i = 0; i < max_touches; i++) {
touches[i] = NULL;
};
@@ -245,39 +243,36 @@ static void clear_touches() {
// Implement this to override the default layer class (which is [CALayer class]).
// We do this so that our view will be backed by a layer that is capable of OpenGL ES rendering.
-+ (Class) layerClass
-{
++ (Class)layerClass {
return [CAEAGLLayer class];
}
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
-- (id)initWithCoder:(NSCoder*)coder
-{
+- (id)initWithCoder:(NSCoder *)coder {
active = FALSE;
- if((self = [super initWithCoder:coder]))
- {
+ if ((self = [super initWithCoder:coder])) {
self = [self initGLES];
}
return self;
}
--(id)initGLES
-{
+- (id)initGLES {
// Get our backing layer
- CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer;
+ CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
// Configure it so that it is opaque, does not retain the contents of the backbuffer when displayed, and uses RGBA8888 color.
eaglLayer.opaque = YES;
- eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
- kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
- nil];
+ eaglLayer.drawableProperties = [NSDictionary
+ dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE],
+ kEAGLDrawablePropertyRetainedBacking,
+ kEAGLColorFormatRGBA8,
+ kEAGLDrawablePropertyColorFormat,
+ nil];
// 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])
- {
+ if (!context || ![EAGLContext setCurrentContext:context] || ![self createFramebuffer]) {
[self release];
return nil;
}
@@ -287,14 +282,12 @@ static void clear_touches() {
return self;
}
--(id<GLViewDelegate>)delegate
-{
+- (id<GLViewDelegate>)delegate {
return delegate;
}
// Update the delegate, and if it needs a -setupView: call, set our internal flag so that it will be called.
--(void)setDelegate:(id<GLViewDelegate>)d
-{
+- (void)setDelegate:(id<GLViewDelegate>)d {
delegate = d;
delegateSetup = ![delegate respondsToSelector:@selector(setupView:)];
}
@@ -305,21 +298,18 @@ static void clear_touches() {
// This is the perfect opportunity to also update the framebuffer so that it is
// the same size as our display area.
--(void)layoutSubviews
-{
+- (void)layoutSubviews {
//printf("HERE\n");
[EAGLContext setCurrentContext:context];
[self destroyFramebuffer];
[self createFramebuffer];
[self drawView];
[self drawView];
-
}
-- (BOOL)createFramebuffer
-{
+- (BOOL)createFramebuffer {
// Generate IDs for a framebuffer object and a color renderbuffer
- UIScreen* mainscr = [UIScreen mainScreen];
+ UIScreen *mainscr = [UIScreen mainScreen];
printf("******** screen size %i, %i\n", (int)mainscr.currentMode.size.width, (int)mainscr.currentMode.size.height);
float minPointSize = MIN(mainscr.bounds.size.width, mainscr.bounds.size.height);
float minScreenSize = MIN(mainscr.currentMode.size.width, mainscr.currentMode.size.height);
@@ -331,7 +321,7 @@ static void clear_touches() {
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
// This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer)
- // allowing us to draw into a buffer that will later be rendered to screen whereever the layer is (which corresponds with our view).
+ // allowing us to draw into a buffer that will later be rendered to screen wherever the layer is (which corresponds with our view).
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>)self.layer];
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
@@ -344,8 +334,7 @@ static void clear_touches() {
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
- if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
- {
+ if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
return NO;
}
@@ -365,22 +354,19 @@ static void clear_touches() {
}
// Clean up any buffers we have allocated.
-- (void)destroyFramebuffer
-{
+- (void)destroyFramebuffer {
glDeleteFramebuffersOES(1, &viewFramebuffer);
viewFramebuffer = 0;
glDeleteRenderbuffersOES(1, &viewRenderbuffer);
viewRenderbuffer = 0;
- if(depthRenderbuffer)
- {
+ if (depthRenderbuffer) {
glDeleteRenderbuffersOES(1, &depthRenderbuffer);
depthRenderbuffer = 0;
}
}
-- (void)startAnimation
-{
+- (void)startAnimation {
if (active)
return;
active = TRUE;
@@ -389,26 +375,23 @@ static void clear_touches() {
// Approximate frame rate
// assumes device refreshes at 60 fps
- int frameInterval = (int) floor(animationInterval * 60.0f);
+ int frameInterval = (int)floor(animationInterval * 60.0f);
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
[displayLink setFrameInterval:frameInterval];
// Setup DisplayLink in main thread
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
- }
- else {
+ } else {
animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
}
- if (video_playing)
- {
+ if (video_playing) {
_unpause_video();
}
}
-- (void)stopAnimation
-{
+- (void)stopAnimation {
if (!active)
return;
active = FALSE;
@@ -417,41 +400,38 @@ static void clear_touches() {
if (useCADisplayLink) {
[displayLink invalidate];
displayLink = nil;
- }
- else {
+ } else {
[animationTimer invalidate];
animationTimer = nil;
}
clear_touches();
- if (video_playing)
- {
+ if (video_playing) {
// save position
}
}
-- (void)setAnimationInterval:(NSTimeInterval)interval
-{
+- (void)setAnimationInterval:(NSTimeInterval)interval {
animationInterval = interval;
- if ( (useCADisplayLink && displayLink) || ( !useCADisplayLink && animationTimer ) ) {
+ if ((useCADisplayLink && displayLink) || (!useCADisplayLink && animationTimer)) {
[self stopAnimation];
[self startAnimation];
}
}
// Updates the OpenGL view when the timer fires
-- (void)drawView
-{
+- (void)drawView {
if (useCADisplayLink) {
// Pause the CADisplayLink to avoid recursion
- [displayLink setPaused: YES];
+ [displayLink setPaused:YES];
// Process all input events
- while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
+ while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource)
+ ;
// We are good to go, resume the CADisplayLink
- [displayLink setPaused: NO];
+ [displayLink setPaused:NO];
}
if (!active) {
@@ -463,8 +443,7 @@ static void clear_touches() {
[EAGLContext setCurrentContext:context];
// If our drawing delegate needs to have the view setup, then call -setupView: and flag that it won't need to be called again.
- if(!delegateSetup)
- {
+ if (!delegateSetup) {
[delegate setupView:self];
delegateSetup = YES;
}
@@ -478,19 +457,18 @@ static void clear_touches() {
#ifdef DEBUG_ENABLED
GLenum err = glGetError();
- if(err)
+ if (err)
NSLog(@"%x error", err);
#endif
}
-- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
-{
- NSArray* tlist = [[event allTouches] allObjects];
- for (unsigned int i=0; i< [tlist count]; i++) {
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
+ NSArray *tlist = [[event allTouches] allObjects];
+ for (unsigned int i = 0; i < [tlist count]; i++) {
- if ( [touches containsObject:[tlist objectAtIndex:i]] ) {
+ if ([touches containsObject:[tlist objectAtIndex:i]]) {
- UITouch* touch = [tlist objectAtIndex:i];
+ UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseBegan)
continue;
int tid = get_touch_id(touch);
@@ -501,15 +479,14 @@ static void clear_touches() {
};
}
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
-{
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
- NSArray* tlist = [[event allTouches] allObjects];
- for (unsigned int i=0; i< [tlist count]; i++) {
+ NSArray *tlist = [[event allTouches] allObjects];
+ for (unsigned int i = 0; i < [tlist count]; i++) {
- if ( [touches containsObject:[tlist objectAtIndex:i]] ) {
+ if ([touches containsObject:[tlist objectAtIndex:i]]) {
- UITouch* touch = [tlist objectAtIndex:i];
+ UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseMoved)
continue;
int tid = get_touch_id(touch);
@@ -520,17 +497,15 @@ static void clear_touches() {
OSIPhone::get_singleton()->mouse_move(tid, prev_point.x * self.contentScaleFactor, prev_point.y * self.contentScaleFactor, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, first == tid);
};
};
-
}
-- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
-{
- NSArray* tlist = [[event allTouches] allObjects];
- for (unsigned int i=0; i< [tlist count]; i++) {
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
+ NSArray *tlist = [[event allTouches] allObjects];
+ for (unsigned int i = 0; i < [tlist count]; i++) {
- if ( [touches containsObject:[tlist objectAtIndex:i]] ) {
+ if ([touches containsObject:[tlist objectAtIndex:i]]) {
- UITouch* touch = [tlist objectAtIndex:i];
+ UITouch *touch = [tlist objectAtIndex:i];
if (touch.phase != UITouchPhaseEnded)
continue;
int tid = get_touch_id(touch);
@@ -552,7 +527,6 @@ static void clear_touches() {
return YES;
};
-
- (void)open_keyboard {
//keyboard_text = p_existing;
[self becomeFirstResponder];
@@ -577,12 +551,11 @@ static void clear_touches() {
String character;
character.parse_utf8([p_text UTF8String]);
keyboard_text = keyboard_text + character;
- OSIPhone::get_singleton()->key(character[0] == 10 ? KEY_ENTER : character[0] , true);
+ OSIPhone::get_singleton()->key(character[0] == 10 ? KEY_ENTER : character[0], true);
printf("inserting text with character %i\n", character[0]);
};
-- (void)audioRouteChangeListenerCallback:(NSNotification*)notification
-{
+- (void)audioRouteChangeListenerCallback:(NSNotification *)notification {
printf("*********** route changed!\n");
NSDictionary *interuptionDict = notification.userInfo;
@@ -590,49 +563,48 @@ static void clear_touches() {
switch (routeChangeReason) {
- case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
+ case AVAudioSessionRouteChangeReasonNewDeviceAvailable: {
NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable");
NSLog(@"Headphone/Line plugged in");
- break;
+ }; break;
- case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
+ case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: {
NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
NSLog(@"Headphone/Line was pulled. Resuming video play....");
if (_is_video_playing()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [_instance.avPlayer play]; // NOTE: change this line according your current player implementation
- NSLog(@"resumed play");
+ [_instance.avPlayer play]; // NOTE: change this line according your current player implementation
+ NSLog(@"resumed play");
});
};
- break;
+ }; break;
- case AVAudioSessionRouteChangeReasonCategoryChange:
+ case AVAudioSessionRouteChangeReasonCategoryChange: {
// called at start - also when other audio wants to play
NSLog(@"AVAudioSessionRouteChangeReasonCategoryChange");
- break;
+ }; break;
}
}
-
// When created via code however, we get initWithFrame
--(id)initWithFrame:(CGRect)frame
-{
+- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
_instance = self;
printf("after init super %p\n", self);
- if(self != nil)
- {
+ if (self != nil) {
self = [self initGLES];
printf("after init gles %p\n", self);
}
init_touches();
- self. multipleTouchEnabled = YES;
+ self.multipleTouchEnabled = YES;
printf("******** adding observer for sound routing changes\n");
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChangeListenerCallback:)
- name:AVAudioSessionRouteChangeNotification
- object:nil];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(audioRouteChangeListenerCallback:)
+ name:AVAudioSessionRouteChangeNotification
+ object:nil];
//self.autoresizesSubviews = YES;
//[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];
@@ -640,21 +612,19 @@ static void clear_touches() {
return self;
}
-// -(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
-// return YES;
-// }
+//- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
+// return YES;
+//}
-// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
-// return YES;
-// }
+//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
+// return YES;
+//}
// Stop animating and release resources when they are no longer needed.
-- (void)dealloc
-{
+- (void)dealloc {
[self stopAnimation];
- if([EAGLContext currentContext] == context)
- {
+ if ([EAGLContext currentContext] == context) {
[EAGLContext setCurrentContext:nil];
}
@@ -664,32 +634,31 @@ static void clear_touches() {
[super dealloc];
}
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
- change:(NSDictionary *)change context:(void *)context {
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == _instance.avPlayerItem && [keyPath isEqualToString:@"status"]) {
- if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
- _stop_video();
- video_found_error = true;
- }
+ if (_instance.avPlayerItem.status == AVPlayerStatusFailed || _instance.avPlayer.status == AVPlayerStatusFailed) {
+ _stop_video();
+ video_found_error = true;
+ }
- if(_instance.avPlayer.status == AVPlayerStatusReadyToPlay &&
- _instance.avPlayerItem.status == AVPlayerItemStatusReadyToPlay &&
- CMTIME_COMPARE_INLINE(video_current_time, ==, kCMTimeZero)) {
+ if (_instance.avPlayer.status == AVPlayerStatusReadyToPlay &&
+ _instance.avPlayerItem.status == AVPlayerItemStatusReadyToPlay &&
+ CMTIME_COMPARE_INLINE(video_current_time, ==, kCMTimeZero)) {
- //NSLog(@"time: %@", video_current_time);
+ //NSLog(@"time: %@", video_current_time);
- [_instance.avPlayer seekToTime:video_current_time];
- video_current_time = kCMTimeZero;
+ [_instance.avPlayer seekToTime:video_current_time];
+ video_current_time = kCMTimeZero;
}
- }
+ }
if (object == _instance.avPlayer && [keyPath isEqualToString:@"rate"]) {
NSLog(@"Player playback rate changed: %.5f", _instance.avPlayer.rate);
if (_is_video_playing() && _instance.avPlayer.rate == 0.0 && !_instance.avPlayer.error) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
- [_instance.avPlayer play]; // NOTE: change this line according your current player implementation
- NSLog(@"resumed play");
+ [_instance.avPlayer play]; // NOTE: change this line according your current player implementation
+ NSLog(@"resumed play");
});
NSLog(@" . . . PAUSED (or just started)");
@@ -698,40 +667,40 @@ static void clear_touches() {
}
- (void)playerItemDidReachEnd:(NSNotification *)notification {
- _stop_video();
+ _stop_video();
}
/*
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
- NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
- switch ([reason intValue]) {
- case MPMovieFinishReasonPlaybackEnded:
- //NSLog(@"Playback Ended");
- break;
- case MPMovieFinishReasonPlaybackError:
- //NSLog(@"Playback Error");
- video_found_error = true;
- break;
- case MPMovieFinishReasonUserExited:
- //NSLog(@"User Exited");
- video_found_error = true;
- break;
- default:
- //NSLog(@"Unsupported reason!");
- break;
- }
-
- MPMoviePlayerController *player = [notification object];
-
- [[NSNotificationCenter defaultCenter]
- removeObserver:self
- name:MPMoviePlayerPlaybackDidFinishNotification
- object:player];
-
- [_instance.moviePlayerController stop];
- [_instance.moviePlayerController.view removeFromSuperview];
+ NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
+ switch ([reason intValue]) {
+ case MPMovieFinishReasonPlaybackEnded:
+ //NSLog(@"Playback Ended");
+ break;
+ case MPMovieFinishReasonPlaybackError:
+ //NSLog(@"Playback Error");
+ video_found_error = true;
+ break;
+ case MPMovieFinishReasonUserExited:
+ //NSLog(@"User Exited");
+ video_found_error = true;
+ break;
+ default:
+ //NSLog(@"Unsupported reason!");
+ break;
+ }
+
+ MPMoviePlayerController *player = [notification object];
+
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:MPMoviePlayerPlaybackDidFinishNotification
+ object:player];
+
+ [_instance.moviePlayerController stop];
+ [_instance.moviePlayerController.view removeFromSuperview];
//[[MPMusicPlayerController applicationMusicPlayer] setVolume: video_previous_volume];
video_playing = false;
diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp
index b3067dc0c4..b320be2f85 100644
--- a/platform/iphone/globals/global_defaults.cpp
+++ b/platform/iphone/globals/global_defaults.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/globals/global_defaults.h b/platform/iphone/globals/global_defaults.h
index 1432b74425..6fe1027287 100644
--- a/platform/iphone/globals/global_defaults.h
+++ b/platform/iphone/globals/global_defaults.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp
index 626c78fdf4..4d34ebedf9 100644
--- a/platform/iphone/godot_iphone.cpp
+++ b/platform/iphone/godot_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/icloud.h b/platform/iphone/icloud.h
index 743a9a5de3..67d12a990a 100644
--- a/platform/iphone/icloud.h
+++ b/platform/iphone/icloud.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm
index a9b23baaeb..94c3d2ef91 100644
--- a/platform/iphone/icloud.mm
+++ b/platform/iphone/icloud.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -34,24 +35,25 @@
extern "C" {
#endif
-#import <Foundation/Foundation.h>
#import "app_delegate.h"
+#import <Foundation/Foundation.h>
+
#ifndef __IPHONE_9_0
};
#endif
-ICloud* ICloud::instance = NULL;
+ICloud *ICloud::instance = NULL;
void ICloud::_bind_methods() {
- ClassDB::bind_method(D_METHOD("remove_key"),&ICloud::remove_key);
- ClassDB::bind_method(D_METHOD("set_key_values"),&ICloud::set_key_values);
- ClassDB::bind_method(D_METHOD("get_key_value"),&ICloud::get_key_value);
- ClassDB::bind_method(D_METHOD("synchronize_key_values"),&ICloud::synchronize_key_values);
- ClassDB::bind_method(D_METHOD("get_all_key_values"),&ICloud::get_all_key_values);
-
- ClassDB::bind_method(D_METHOD("get_pending_event_count"),&ICloud::get_pending_event_count);
- ClassDB::bind_method(D_METHOD("pop_pending_event"),&ICloud::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("remove_key"), &ICloud::remove_key);
+ ClassDB::bind_method(D_METHOD("set_key_values"), &ICloud::set_key_values);
+ ClassDB::bind_method(D_METHOD("get_key_value"), &ICloud::get_key_value);
+ ClassDB::bind_method(D_METHOD("synchronize_key_values"), &ICloud::synchronize_key_values);
+ ClassDB::bind_method(D_METHOD("get_all_key_values"), &ICloud::get_all_key_values);
+
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"), &ICloud::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"), &ICloud::pop_pending_event);
};
int ICloud::get_pending_event_count() {
@@ -67,19 +69,18 @@ Variant ICloud::pop_pending_event() {
return front;
};
-ICloud* ICloud::get_singleton() {
+ICloud *ICloud::get_singleton() {
return instance;
};
//convert from apple's abstract type to godot's abstract type....
-Variant nsobject_to_variant(NSObject* object) {
+Variant nsobject_to_variant(NSObject *object) {
if ([object isKindOfClass:[NSString class]]) {
- const char* str = [(NSString*)object UTF8String];
+ const char *str = [(NSString *)object UTF8String];
return String::utf8(str != NULL ? str : "");
- }
- else if ([object isKindOfClass:[NSData class]]) {
+ } else if ([object isKindOfClass:[NSData class]]) {
PoolByteArray ret;
- NSData* data = (NSData*)object;
+ NSData *data = (NSData *)object;
if ([data length] > 0) {
ret.resize([data length]);
{
@@ -88,95 +89,78 @@ Variant nsobject_to_variant(NSObject* object) {
}
}
return ret;
- }
- else if ([object isKindOfClass:[NSArray class]]) {
+ } else if ([object isKindOfClass:[NSArray class]]) {
Array result;
- NSArray* array = (NSArray*)object;
+ NSArray *array = (NSArray *)object;
for (unsigned int i = 0; i < [array count]; ++i) {
- NSObject* value = [array objectAtIndex:i];
+ NSObject *value = [array objectAtIndex:i];
result.push_back(nsobject_to_variant(value));
}
return result;
- }
- else if ([object isKindOfClass:[NSDictionary class]]) {
+ } else if ([object isKindOfClass:[NSDictionary class]]) {
Dictionary result;
- NSDictionary* dic = (NSDictionary*)object;
+ NSDictionary *dic = (NSDictionary *)object;
-
- NSArray* keys = [dic allKeys];
+ NSArray *keys = [dic allKeys];
int count = [keys count];
- for (int i=0; i < count; ++i) {
- NSObject* k = [ keys objectAtIndex:i];
- NSObject* v = [dic objectForKey:k];
+ for (int i = 0; i < count; ++i) {
+ NSObject *k = [keys objectAtIndex:i];
+ NSObject *v = [dic objectForKey:k];
result[nsobject_to_variant(k)] = nsobject_to_variant(v);
}
return result;
- }
- else if ([object isKindOfClass:[NSNumber class]]) {
+ } else if ([object isKindOfClass:[NSNumber class]]) {
//Every type except numbers can reliably identify its type. The following is comparing to the *internal* representation, which isn't guaranteed to match the type that was used to create it, and is not advised, particularly when dealing with potential platform differences (ie, 32/64 bit)
//To avoid errors, we'll cast as broadly as possible, and only return int or float.
//bool, char, int, uint, longlong -> int
//float, double -> float
- NSNumber* num = (NSNumber*)object;
- if(strcmp([num objCType], @encode(BOOL)) == 0) {
+ NSNumber *num = (NSNumber *)object;
+ if (strcmp([num objCType], @encode(BOOL)) == 0) {
return Variant((int)[num boolValue]);
- }
- else if(strcmp([num objCType], @encode(char)) == 0) {
+ } else if (strcmp([num objCType], @encode(char)) == 0) {
return Variant((int)[num charValue]);
- }
- else if(strcmp([num objCType], @encode(int)) == 0) {
+ } else if (strcmp([num objCType], @encode(int)) == 0) {
return Variant([num intValue]);
- }
- else if(strcmp([num objCType], @encode(unsigned int)) == 0) {
+ } else if (strcmp([num objCType], @encode(unsigned int)) == 0) {
return Variant((int)[num unsignedIntValue]);
- }
- else if(strcmp([num objCType], @encode(long long)) == 0) {
+ } else if (strcmp([num objCType], @encode(long long)) == 0) {
return Variant((int)[num longValue]);
- }
- else if(strcmp([num objCType], @encode(float)) == 0) {
+ } else if (strcmp([num objCType], @encode(float)) == 0) {
return Variant([num floatValue]);
- }
- else if(strcmp([num objCType], @encode(double)) == 0) {
+ } else if (strcmp([num objCType], @encode(double)) == 0) {
return Variant((float)[num doubleValue]);
}
- }
- else if ([object isKindOfClass:[NSDate class]]) {
+ } else if ([object isKindOfClass:[NSDate class]]) {
//this is a type that icloud supports...but how did you submit it in the first place?
//I guess this is a type that *might* show up, if you were, say, trying to make your game
//compatible with existing cloud data written by another engine's version of your game
WARN_PRINT("NSDate unsupported, returning null Variant")
return Variant();
- }
- else if ([object isKindOfClass:[NSNull class]] or object == nil) {
+ } else if ([object isKindOfClass:[NSNull class]] or object == nil) {
return Variant();
- }
- else {
+ } else {
WARN_PRINT("Trying to convert unknown NSObject type to Variant");
return Variant();
}
}
-NSObject* variant_to_nsobject(Variant v) {
+NSObject *variant_to_nsobject(Variant v) {
if (v.get_type() == Variant::STRING) {
return [[[NSString alloc] initWithUTF8String:((String)v).utf8().get_data()] autorelease];
- }
- else if (v.get_type() == Variant::REAL) {
+ } else if (v.get_type() == Variant::REAL) {
return [NSNumber numberWithDouble:(double)v];
- }
- else if (v.get_type() == Variant::INT) {
+ } else if (v.get_type() == Variant::INT) {
return [NSNumber numberWithLongLong:(long)(int)v];
- }
- else if (v.get_type() == Variant::BOOL) {
+ } else if (v.get_type() == Variant::BOOL) {
return [NSNumber numberWithBool:BOOL((bool)v)];
- }
- else if (v.get_type() == Variant::DICTIONARY) {
- NSMutableDictionary* result = [[[NSMutableDictionary alloc] init] autorelease];
+ } else if (v.get_type() == Variant::DICTIONARY) {
+ NSMutableDictionary *result = [[[NSMutableDictionary alloc] init] autorelease];
Dictionary dic = v;
Array keys = dic.keys();
for (unsigned int i = 0; i < keys.size(); ++i) {
- NSString* key = [[[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()] autorelease];
- NSObject* value = variant_to_nsobject(dic[keys[i]]);
+ NSString *key = [[[NSString alloc] initWithUTF8String:((String)(keys[i])).utf8().get_data()] autorelease];
+ NSObject *value = variant_to_nsobject(dic[keys[i]]);
if (key == NULL || value == NULL) {
return NULL;
@@ -185,12 +169,11 @@ NSObject* variant_to_nsobject(Variant v) {
[result setObject:value forKey:key];
}
return result;
- }
- else if (v.get_type() == Variant::ARRAY) {
- NSMutableArray* result = [[[NSMutableArray alloc] init] autorelease];
+ } else if (v.get_type() == Variant::ARRAY) {
+ NSMutableArray *result = [[[NSMutableArray alloc] init] autorelease];
Array arr = v;
for (unsigned int i = 0; i < arr.size(); ++i) {
- NSObject* value = variant_to_nsobject(arr[i]);
+ NSObject *value = variant_to_nsobject(arr[i]);
if (value == NULL) {
//trying to add something unsupported to the array. cancel the whole array
return NULL;
@@ -198,21 +181,19 @@ NSObject* variant_to_nsobject(Variant v) {
[result addObject:value];
}
return result;
- }
- else if (v.get_type() == Variant::POOL_BYTE_ARRAY) {
+ } else if (v.get_type() == Variant::POOL_BYTE_ARRAY) {
PoolByteArray arr = v;
PoolByteArray::Read r = arr.read();
- NSData* result = [NSData dataWithBytes:r.ptr() length:arr.size()];
+ NSData *result = [NSData dataWithBytes:r.ptr() length:arr.size()];
return result;
}
- WARN_PRINT(String("Could not add unsupported type to iCloud: '" + Variant::get_type_name(v.get_type())+"'").utf8().get_data());
+ WARN_PRINT(String("Could not add unsupported type to iCloud: '" + Variant::get_type_name(v.get_type()) + "'").utf8().get_data());
return NULL;
}
-
Error ICloud::remove_key(Variant p_param) {
String param = p_param;
- NSString* key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
+ NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
@@ -235,13 +216,13 @@ Variant ICloud::set_key_values(Variant p_params) {
String variant_key = keys[i];
Variant variant_value = params[variant_key];
- NSString* key = [[[NSString alloc] initWithUTF8String:variant_key.utf8().get_data()] autorelease];
+ NSString *key = [[[NSString alloc] initWithUTF8String:variant_key.utf8().get_data()] autorelease];
if (key == NULL) {
error_keys.push_back(variant_key);
continue;
}
- NSObject* value = variant_to_nsobject(variant_value);
+ NSObject *value = variant_to_nsobject(variant_value);
if (value == NULL) {
error_keys.push_back(variant_key);
@@ -258,7 +239,7 @@ Variant ICloud::set_key_values(Variant p_params) {
Variant ICloud::get_key_value(Variant p_param) {
String param = p_param;
- NSString* key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
+ NSString *key = [[[NSString alloc] initWithUTF8String:param.utf8().get_data()] autorelease];
NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
if (![[store dictionaryRepresentation] objectForKey:key]) {
@@ -273,16 +254,16 @@ Variant ICloud::get_key_value(Variant p_param) {
Variant ICloud::get_all_key_values() {
Dictionary result;
- NSUbiquitousKeyValueStore* store = [NSUbiquitousKeyValueStore defaultStore];
- NSDictionary* store_dictionary = [store dictionaryRepresentation];
+ NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
+ NSDictionary *store_dictionary = [store dictionaryRepresentation];
- NSArray* keys = [store_dictionary allKeys];
+ NSArray *keys = [store_dictionary allKeys];
int count = [keys count];
- for (int i=0; i < count; ++i) {
- NSString* k = [ keys objectAtIndex:i];
- NSObject* v = [store_dictionary objectForKey:k];
+ for (int i = 0; i < count; ++i) {
+ NSString *k = [keys objectAtIndex:i];
+ NSObject *v = [store_dictionary objectForKey:k];
- const char* str = [k UTF8String];
+ const char *str = [k UTF8String];
if (str != NULL) {
result[String::utf8(str)] = nsobject_to_variant(v);
}
@@ -296,8 +277,7 @@ Error ICloud::synchronize_key_values() {
BOOL result = [store synchronize];
if (result == YES) {
return OK;
- }
- else {
+ } else {
return FAILED;
}
}
@@ -306,14 +286,14 @@ Error ICloud::initial_sync() {
//you sometimes have to write something to the store to get it to download new data. go apple!
NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
if ([store boolForKey:@"isb"])
- {
- [store setBool:NO forKey:@"isb"];
- }
- else
- {
- [store setBool:YES forKey:@"isb"];
- }
- return synchronize();
+ {
+ [store setBool:NO forKey:@"isb"];
+ }
+ else
+ {
+ [store setBool:YES forKey:@"isb"];
+ }
+ return synchronize();
}
*/
ICloud::ICloud() {
@@ -321,65 +301,56 @@ ICloud::ICloud() {
instance = this;
//connected = false;
- [
- //[NSNotificationCenter defaultCenter] addObserverForName: @"notify"
- [NSNotificationCenter defaultCenter] addObserverForName: NSUbiquitousKeyValueStoreDidChangeExternallyNotification
- object: [NSUbiquitousKeyValueStore defaultStore]
- queue: nil
- usingBlock: ^ (NSNotification * notification) {
- NSDictionary* userInfo = [notification userInfo];
- NSInteger change = [[userInfo objectForKey:NSUbiquitousKeyValueStoreChangeReasonKey] integerValue];
-
- Dictionary ret;
- ret["type"] = "key_value_changed";
-
- //PoolStringArray result_keys;
- //Array result_values;
- Dictionary keyValues;
- String reason = "";
-
- if (change == NSUbiquitousKeyValueStoreServerChange) {
- reason = "server";
- }
- else if (change == NSUbiquitousKeyValueStoreInitialSyncChange) {
- reason = "initial_sync";
- }
- else if (change == NSUbiquitousKeyValueStoreQuotaViolationChange) {
- reason = "quota_violation";
- }
- else if (change == NSUbiquitousKeyValueStoreAccountChange) {
- reason = "account";
- }
-
- ret["reason"] = reason;
-
-
- NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
-
- NSArray * keys = [userInfo objectForKey:NSUbiquitousKeyValueStoreChangedKeysKey];
- for (NSString* key in keys) {
- const char* str = [key UTF8String];
- if (str == NULL) {
- continue;
- }
-
- NSObject* object = [store objectForKey:key];
-
- //figure out what kind of object it is
- Variant value = nsobject_to_variant(object);
-
- keyValues[String::utf8(str)] = value;
- }
-
- ret["changed_values"] = keyValues;
- pending_events.push_back(ret);
- }
- ];
+ [[NSNotificationCenter defaultCenter]
+ addObserverForName:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
+ object:[NSUbiquitousKeyValueStore defaultStore]
+ queue:nil
+ usingBlock:^(NSNotification *notification) {
+ NSDictionary *userInfo = [notification userInfo];
+ NSInteger change = [[userInfo objectForKey:NSUbiquitousKeyValueStoreChangeReasonKey] integerValue];
+
+ Dictionary ret;
+ ret["type"] = "key_value_changed";
+
+ //PoolStringArray result_keys;
+ //Array result_values;
+ Dictionary keyValues;
+ String reason = "";
+
+ if (change == NSUbiquitousKeyValueStoreServerChange) {
+ reason = "server";
+ } else if (change == NSUbiquitousKeyValueStoreInitialSyncChange) {
+ reason = "initial_sync";
+ } else if (change == NSUbiquitousKeyValueStoreQuotaViolationChange) {
+ reason = "quota_violation";
+ } else if (change == NSUbiquitousKeyValueStoreAccountChange) {
+ reason = "account";
+ }
+
+ ret["reason"] = reason;
+
+ NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
+
+ NSArray *keys = [userInfo objectForKey:NSUbiquitousKeyValueStoreChangedKeysKey];
+ for (NSString *key in keys) {
+ const char *str = [key UTF8String];
+ if (str == NULL) {
+ continue;
+ }
+
+ NSObject *object = [store objectForKey:key];
+
+ //figure out what kind of object it is
+ Variant value = nsobject_to_variant(object);
+
+ keyValues[String::utf8(str)] = value;
+ }
+
+ ret["changed_values"] = keyValues;
+ pending_events.push_back(ret);
+ }];
}
-
-ICloud::~ICloud() {
-
-};
+ICloud::~ICloud(){};
#endif
diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h
index b2ed6f70e4..153c46bd7b 100644
--- a/platform/iphone/in_app_store.h
+++ b/platform/iphone/in_app_store.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index b63d7b42ab..710df0f757 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -28,30 +29,29 @@
/*************************************************************************/
#ifdef STOREKIT_ENABLED
+#include "in_app_store.h"
+
#ifdef MODULE_FUSEBOXX_ENABLED
#import "modules/fuseboxx/ios/FuseSDK.h"
#endif
-#include "in_app_store.h"
-
extern "C" {
-#import <StoreKit/StoreKit.h>
#import <Foundation/Foundation.h>
+#import <StoreKit/StoreKit.h>
};
bool auto_finish_transactions = true;
-NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
+NSMutableDictionary *pending_transactions = [NSMutableDictionary dictionary];
@interface SKProduct (LocalizedPrice)
-@property (nonatomic, readonly) NSString *localizedPrice;
+@property(nonatomic, readonly) NSString *localizedPrice;
@end
//----------------------------------//
// SKProduct extension
//----------------------------------//
@implementation SKProduct (LocalizedPrice)
-- (NSString *)localizedPrice
-{
+- (NSString *)localizedPrice {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
@@ -62,30 +62,28 @@ NSMutableDictionary* pending_transactions = [NSMutableDictionary dictionary];
}
@end
-
-InAppStore* InAppStore::instance = NULL;
+InAppStore *InAppStore::instance = NULL;
void InAppStore::_bind_methods() {
- ClassDB::bind_method(D_METHOD("request_product_info"),&InAppStore::request_product_info);
- ClassDB::bind_method(D_METHOD("purchase"),&InAppStore::purchase);
+ ClassDB::bind_method(D_METHOD("request_product_info"), &InAppStore::request_product_info);
+ ClassDB::bind_method(D_METHOD("purchase"), &InAppStore::purchase);
- ClassDB::bind_method(D_METHOD("get_pending_event_count"),&InAppStore::get_pending_event_count);
- ClassDB::bind_method(D_METHOD("pop_pending_event"),&InAppStore::pop_pending_event);
- ClassDB::bind_method(D_METHOD("finish_transaction"),&InAppStore::finish_transaction);
- ClassDB::bind_method(D_METHOD("set_auto_finish_transaction"),&InAppStore::set_auto_finish_transaction);
+ ClassDB::bind_method(D_METHOD("get_pending_event_count"), &InAppStore::get_pending_event_count);
+ ClassDB::bind_method(D_METHOD("pop_pending_event"), &InAppStore::pop_pending_event);
+ ClassDB::bind_method(D_METHOD("finish_transaction"), &InAppStore::finish_transaction);
+ ClassDB::bind_method(D_METHOD("set_auto_finish_transaction"), &InAppStore::set_auto_finish_transaction);
};
-@interface ProductsDelegate : NSObject<SKProductsRequestDelegate> {
-
+@interface ProductsDelegate : NSObject <SKProductsRequestDelegate> {
};
@end
@implementation ProductsDelegate
-- (void)productsRequest:(SKProductsRequest*)request didReceiveResponse:(SKProductsResponse*)response {
+- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
- NSArray* products = response.products;
+ NSArray *products = response.products;
Dictionary ret;
ret["type"] = "product_info";
ret["result"] = "ok";
@@ -95,11 +93,11 @@ void InAppStore::_bind_methods() {
PoolStringArray ids;
PoolStringArray localized_prices;
- for (int i=0; i<[products count]; i++) {
+ for (int i = 0; i < [products count]; i++) {
- SKProduct* product = [products objectAtIndex:i];
+ SKProduct *product = [products objectAtIndex:i];
- const char* str = [product.localizedTitle UTF8String];
+ const char *str = [product.localizedTitle UTF8String];
titles.push_back(String::utf8(str != NULL ? str : ""));
str = [product.localizedDescription UTF8String];
@@ -116,7 +114,7 @@ void InAppStore::_bind_methods() {
PoolStringArray invalid_ids;
- for (NSString* ipid in response.invalidProductIdentifiers) {
+ for (NSString *ipid in response.invalidProductIdentifiers) {
invalid_ids.push_back(String::utf8([ipid UTF8String]));
};
@@ -137,15 +135,15 @@ Error InAppStore::request_product_info(Variant p_params) {
PoolStringArray pids = params["product_ids"];
printf("************ request product info! %i\n", pids.size());
- NSMutableArray* array = [[[NSMutableArray alloc] initWithCapacity:pids.size()] autorelease];
- for (int i=0; i<pids.size(); i++) {
+ NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:pids.size()] autorelease];
+ for (int i = 0; i < pids.size(); i++) {
printf("******** adding %ls to product list\n", pids[i].c_str());
- NSString* pid = [[[NSString alloc] initWithUTF8String:pids[i].utf8().get_data()] autorelease];
+ NSString *pid = [[[NSString alloc] initWithUTF8String:pids[i].utf8().get_data()] autorelease];
[array addObject:pid];
};
- NSSet* products = [[[NSSet alloc] initWithArray:array] autorelease];
- SKProductsRequest* request = [[SKProductsRequest alloc] initWithProductIdentifiers:products];
+ NSSet *products = [[[NSSet alloc] initWithArray:array] autorelease];
+ SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:products];
ProductsDelegate *delegate = [[ProductsDelegate alloc] init];
@@ -155,131 +153,123 @@ Error InAppStore::request_product_info(Variant p_params) {
return OK;
};
-@interface TransObserver : NSObject<SKPaymentTransactionObserver> {
-
+@interface TransObserver : NSObject <SKPaymentTransactionObserver> {
};
@end
@implementation TransObserver
-- (void)paymentQueue:(SKPaymentQueue*)queue updatedTransactions:(NSArray*) transactions {
+- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
- printf("transactions updated!\n");
- for (SKPaymentTransaction* transaction in transactions) {
+ printf("transactions updated!\n");
+ for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
+ case SKPaymentTransactionStatePurchased: {
+ printf("status purchased!\n");
+ String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
+ String transactionId = String::utf8([transaction.transactionIdentifier UTF8String]);
+ InAppStore::get_singleton()->_record_purchase(pid);
+ Dictionary ret;
+ ret["type"] = "purchase";
+ ret["result"] = "ok";
+ ret["product_id"] = pid;
+ ret["transaction_id"] = transactionId;
+
+ NSData *receipt = nil;
+ int sdk_version = 6;
+
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
+
+ NSURL *receiptFileURL = nil;
+ NSBundle *bundle = [NSBundle mainBundle];
+ if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) {
+
+ // Get the transaction receipt file path location in the app bundle.
+ receiptFileURL = [bundle appStoreReceiptURL];
+
+ // Read in the contents of the transaction file.
+ receipt = [NSData dataWithContentsOfURL:receiptFileURL];
+ sdk_version = 7;
+
+ } else {
+ // Fall back to deprecated transaction receipt,
+ // which is still available in iOS 7.
+
+ // Use SKPaymentTransaction's transactionReceipt.
+ receipt = transaction.transactionReceipt;
+ }
+
+ } else {
+ receipt = transaction.transactionReceipt;
+ }
+
+ NSString *receipt_to_send = nil;
+ if (receipt != nil) {
+ receipt_to_send = [receipt description];
+ }
+ Dictionary receipt_ret;
+ receipt_ret["receipt"] = String::utf8(receipt_to_send != nil ? [receipt_to_send UTF8String] : "");
+ receipt_ret["sdk"] = sdk_version;
+ ret["receipt"] = receipt_ret;
+
+ InAppStore::get_singleton()->_post_event(ret);
+
+ if (auto_finish_transactions) {
+ [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+ } else {
+ [pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier];
+ }
- case SKPaymentTransactionStatePurchased: {
- printf("status purchased!\n");
- String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
- String transactionId = String::utf8([transaction.transactionIdentifier UTF8String]);
- InAppStore::get_singleton()->_record_purchase(pid);
- Dictionary ret;
- ret["type"] = "purchase";
- ret["result"] = "ok";
- ret["product_id"] = pid;
- ret["transaction_id"] = transactionId;
-
- NSData* receipt = nil;
- int sdk_version = 6;
-
- if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0){
-
- NSURL *receiptFileURL = nil;
- NSBundle *bundle = [NSBundle mainBundle];
- if ([bundle respondsToSelector:@selector(appStoreReceiptURL)]) {
-
- // Get the transaction receipt file path location in the app bundle.
- receiptFileURL = [bundle appStoreReceiptURL];
-
- // Read in the contents of the transaction file.
- receipt = [NSData dataWithContentsOfURL:receiptFileURL];
- sdk_version = 7;
-
- } else {
- // Fall back to deprecated transaction receipt,
- // which is still available in iOS 7.
-
- // Use SKPaymentTransaction's transactionReceipt.
- receipt = transaction.transactionReceipt;
- }
-
- }else{
- receipt = transaction.transactionReceipt;
- }
-
- NSString* receipt_to_send = nil;
- if (receipt != nil)
- {
- receipt_to_send = [receipt description];
- }
- Dictionary receipt_ret;
- receipt_ret["receipt"] = String::utf8(receipt_to_send != nil ? [receipt_to_send UTF8String] : "");
- receipt_ret["sdk"] = sdk_version;
- ret["receipt"] = receipt_ret;
-
- InAppStore::get_singleton()->_post_event(ret);
-
- if (auto_finish_transactions){
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
- }
- else{
- [pending_transactions setObject:transaction forKey:transaction.payment.productIdentifier];
- }
-
- #ifdef MODULE_FUSEBOXX_ENABLED
- printf("Registering transaction on Fuseboxx!\n");
- [FuseSDK registerInAppPurchase: transaction];
- #endif
- } break;
- case SKPaymentTransactionStateFailed: {
- printf("status transaction failed!\n");
- String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
- Dictionary ret;
- ret["type"] = "purchase";
- ret["result"] = "error";
- ret["product_id"] = pid;
- InAppStore::get_singleton()->_post_event(ret);
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
- } break;
- case SKPaymentTransactionStateRestored: {
- printf("status transaction restored!\n");
- String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
- InAppStore::get_singleton()->_record_purchase(pid);
- [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
- } break;
-
- default:
- printf("status default %i!\n", (int)transaction.transactionState);
-
- break;
+#ifdef MODULE_FUSEBOXX_ENABLED
+ printf("Registering transaction on Fuseboxx!\n");
+ [FuseSDK registerInAppPurchase:transaction];
+#endif
+ }; break;
+ case SKPaymentTransactionStateFailed: {
+ printf("status transaction failed!\n");
+ String pid = String::utf8([transaction.payment.productIdentifier UTF8String]);
+ Dictionary ret;
+ ret["type"] = "purchase";
+ ret["result"] = "error";
+ ret["product_id"] = pid;
+ InAppStore::get_singleton()->_post_event(ret);
+ [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+ } break;
+ case SKPaymentTransactionStateRestored: {
+ printf("status transaction restored!\n");
+ String pid = String::utf8([transaction.originalTransaction.payment.productIdentifier UTF8String]);
+ InAppStore::get_singleton()->_record_purchase(pid);
+ [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
+ } break;
+ default: {
+ printf("status default %i!\n", (int)transaction.transactionState);
+ }; break;
};
};
};
@end
-
Error InAppStore::purchase(Variant p_params) {
ERR_FAIL_COND_V(![SKPaymentQueue canMakePayments], ERR_UNAVAILABLE);
if (![SKPaymentQueue canMakePayments])
return ERR_UNAVAILABLE;
- printf("purchasing!\n");
+ printf("purchasing!\n");
Dictionary params = p_params;
ERR_FAIL_COND_V(!params.has("product_id"), ERR_INVALID_PARAMETER);
NSString *pid = [[[NSString alloc] initWithUTF8String:String(params["product_id"]).utf8().get_data()] autorelease];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:pid];
- SKPaymentQueue* defq = [SKPaymentQueue defaultQueue];
+ SKPaymentQueue *defq = [SKPaymentQueue defaultQueue];
[defq addPayment:payment];
- printf("purchase sent!\n");
+ printf("purchase sent!\n");
return OK;
};
-
int InAppStore::get_pending_event_count() {
return pending_events.size();
};
@@ -299,13 +289,13 @@ void InAppStore::_post_event(Variant p_event) {
void InAppStore::_record_purchase(String product_id) {
- String skey = "purchased/"+product_id;
- NSString* key = [[[NSString alloc] initWithUTF8String:skey.utf8().get_data()] autorelease];
+ String skey = "purchased/" + product_id;
+ NSString *key = [[[NSString alloc] initWithUTF8String:skey.utf8().get_data()] autorelease];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
};
-InAppStore* InAppStore::get_singleton() {
+InAppStore *InAppStore::get_singleton() {
return instance;
};
@@ -315,27 +305,24 @@ InAppStore::InAppStore() {
instance = this;
auto_finish_transactions = false;
- TransObserver* observer = [[TransObserver alloc] init];
+ TransObserver *observer = [[TransObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
- //pending_transactions = [NSMutableDictionary dictionary];
+ //pending_transactions = [NSMutableDictionary dictionary];
};
-void InAppStore::finish_transaction(String product_id){
- NSString* prod_id = [NSString stringWithCString:product_id.utf8().get_data() encoding:NSUTF8StringEncoding];
+void InAppStore::finish_transaction(String product_id) {
+ NSString *prod_id = [NSString stringWithCString:product_id.utf8().get_data() encoding:NSUTF8StringEncoding];
- if ([pending_transactions objectForKey:prod_id]){
+ if ([pending_transactions objectForKey:prod_id]) {
[[SKPaymentQueue defaultQueue] finishTransaction:[pending_transactions objectForKey:prod_id]];
- [pending_transactions removeObjectForKey:prod_id];
+ [pending_transactions removeObjectForKey:prod_id];
}
};
-void InAppStore::set_auto_finish_transaction(bool b){
- auto_finish_transactions = b;
+void InAppStore::set_auto_finish_transaction(bool b) {
+ auto_finish_transactions = b;
}
-InAppStore::~InAppStore() {
-
-};
-
+InAppStore::~InAppStore(){};
#endif
diff --git a/platform/iphone/ios.h b/platform/iphone/ios.h
index e5baf8f4d2..5329d4f02a 100644
--- a/platform/iphone/ios.h
+++ b/platform/iphone/ios.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm
index 4aca85dafc..cd64bbfafc 100644
--- a/platform/iphone/ios.mm
+++ b/platform/iphone/ios.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -32,7 +33,7 @@
void iOS::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_rate_url","app_id"),&iOS::get_rate_url);
+ ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url);
};
String iOS::get_rate_url(int p_app_id) const {
@@ -43,14 +44,11 @@ String iOS::get_rate_url(int p_app_id) const {
//ios7 before
String ret = templ;
- // iOS 7 needs a different templateReviewURL @see https://github.com/arashpayan/appirater/issues/131
- if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.1)
- {
+ if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7.1) {
+ // iOS 7 needs a different templateReviewURL @see https://github.com/arashpayan/appirater/issues/131
ret = templ_iOS7;
- }
- // iOS 8 needs a different templateReviewURL also @see https://github.com/arashpayan/appirater/issues/182
- else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
- {
+ } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
+ // iOS 8 needs a different templateReviewURL also @see https://github.com/arashpayan/appirater/issues/182
ret = templ_iOS8;
}
@@ -61,4 +59,4 @@ String iOS::get_rate_url(int p_app_id) const {
return ret;
};
-iOS::iOS() {};
+iOS::iOS(){};
diff --git a/platform/iphone/main.m b/platform/iphone/main.m
index 02a45737c5..6757cc8146 100644
--- a/platform/iphone/main.m
+++ b/platform/iphone/main.m
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,25 +27,24 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#import <UIKit/UIKit.h>
#import "app_delegate.h"
+
+#import <UIKit/UIKit.h>
#include <stdio.h>
int gargc;
-char** gargv;
+char **gargv;
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
printf("*********** main.m\n");
gargc = argc;
gargv = argv;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- AppDelegate* app = [AppDelegate alloc];
+ AppDelegate *app = [AppDelegate alloc];
printf("running app main\n");
UIApplicationMain(argc, argv, nil, @"AppDelegate");
printf("main done, pool release\n");
[pool release];
return 0;
}
-
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 57862131f9..bc25afabea 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -196,7 +197,6 @@ void OSIPhone::key(uint32_t p_key, bool p_pressed) {
InputEvent ev;
ev.type = InputEvent::KEY;
- ev.ID = ++last_event_id;
ev.key.echo = false;
ev.key.pressed = p_pressed;
ev.key.scancode = p_key;
@@ -209,7 +209,6 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
if (!GLOBAL_DEF("debug/disable_touch", false)) {
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = ++last_event_id;
ev.screen_touch.index = p_idx;
ev.screen_touch.pressed = p_pressed;
ev.screen_touch.x = p_x;
@@ -225,7 +224,6 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
ev.type = InputEvent::MOUSE_BUTTON;
ev.device = 0;
ev.mouse_button.pointer_index = p_idx;
- ev.ID = ++last_event_id;
// swaped it for tilted screen
//ev.mouse_button.x = ev.mouse_button.global_x = video_mode.height - p_y;
@@ -235,7 +233,7 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_
//mouse_list.pressed[p_idx] = p_pressed;
- input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
+ input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.doubleclick = p_doubleclick;
ev.mouse_button.pressed = p_pressed;
@@ -250,7 +248,6 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
InputEvent ev;
ev.type = InputEvent::SCREEN_DRAG;
- ev.ID = ++last_event_id;
ev.screen_drag.index = p_idx;
ev.screen_drag.x = p_x;
ev.screen_drag.y = p_y;
@@ -264,7 +261,6 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
ev.type = InputEvent::MOUSE_MOTION;
ev.device = 0;
ev.mouse_motion.pointer_index = p_idx;
- ev.ID = ++last_event_id;
if (true) { // vertical
@@ -280,7 +276,7 @@ void OSIPhone::mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_
ev.mouse_motion.relative_y = ev.mouse_motion.y - p_prev_x;
};
- input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
+ input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_motion.speed_x = input->get_last_mouse_speed().x;
ev.mouse_motion.speed_y = input->get_last_mouse_speed().y;
ev.mouse_motion.button_mask = 1; // pressed
@@ -325,9 +321,8 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0;
- ev.joy_motion.axis = JOY_ANALOG_0_X;
+ ev.joy_motion.axis = JOY_ANALOG_0;
ev.joy_motion.axis_value = (p_x / (float)ACCEL_RANGE);
- ev.ID = ++last_event_id;
last_accel.x = p_x;
queue_event(ev);
};
@@ -336,9 +331,8 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0;
- ev.joy_motion.axis = JOY_ANALOG_0_Y;
+ ev.joy_motion.axis = JOY_ANALOG_1;
ev.joy_motion.axis_value = (p_y / (float)ACCEL_RANGE);
- ev.ID = ++last_event_id;
last_accel.y = p_y;
queue_event(ev);
};
@@ -347,9 +341,8 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
InputEvent ev;
ev.type = InputEvent::JOYPAD_MOTION;
ev.device = 0;
- ev.joy_motion.axis = JOY_ANALOG_1_X;
+ ev.joy_motion.axis = JOY_ANALOG_2;
ev.joy_motion.axis_value = ( (1.0 - p_z) / (float)ACCEL_RANGE);
- ev.ID = ++last_event_id;
last_accel.z = p_z;
queue_event(ev);
};
@@ -400,7 +393,7 @@ bool OSIPhone::is_mouse_grab_enabled() const {
return true;
};
-Point2 OSIPhone::get_mouse_pos() const {
+Point2 OSIPhone::get_mouse_position() const {
return Point2();
};
@@ -566,7 +559,6 @@ OSIPhone::OSIPhone(int width, int height) {
vm.resizable = false;
set_video_mode(vm);
event_count = 0;
- last_event_id = 0;
};
OSIPhone::~OSIPhone() {
diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h
index 36261a62c2..754dea073f 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -119,7 +120,6 @@ private:
InputEvent event_queue[MAX_EVENTS];
int event_count;
- int last_event_id;
void queue_event(const InputEvent &p_event);
String data_dir;
@@ -150,7 +150,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h
index 64e9388910..7e4b533254 100644
--- a/platform/iphone/platform_config.h
+++ b/platform/iphone/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/platform_refcount.h b/platform/iphone/platform_refcount.h
index 6cfdc49369..c02e709ea1 100644
--- a/platform/iphone/platform_refcount.h
+++ b/platform/iphone/platform_refcount.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/power_iphone.cpp b/platform/iphone/power_iphone.cpp
index 7b1f9246f4..5192f8e593 100644
--- a/platform/iphone/power_iphone.cpp
+++ b/platform/iphone/power_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/power_iphone.h b/platform/iphone/power_iphone.h
index 8890c33e74..174ee6c63b 100644
--- a/platform/iphone/power_iphone.h
+++ b/platform/iphone/power_iphone.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/rasterizer_iphone.cpp b/platform/iphone/rasterizer_iphone.cpp
index 1a619f4305..ff13ff1b89 100644
--- a/platform/iphone/rasterizer_iphone.cpp
+++ b/platform/iphone/rasterizer_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -447,7 +448,7 @@ RID RasterizerIPhone::material_create() {
return material_owner.make_rid(memnew(Material));
}
-void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter, const Variant &p_value) {
+void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant &p_value) {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND(!m);
@@ -455,7 +456,7 @@ void RasterizerIPhone::fixed_material_set_parameter(RID p_material, VS::FixedSpa
m->parameters[p_parameter] = p_value;
}
-Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const {
+Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material, VS::SpatialMaterialParam p_parameter) const {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND_V(!m, Variant());
@@ -464,7 +465,7 @@ Variant RasterizerIPhone::fixed_material_get_parameter(RID p_material, VS::Fixed
return m->parameters[p_parameter];
}
-void RasterizerIPhone::fixed_material_set_texture(RID p_material, VS::FixedSpatialMaterialParam p_parameter, RID p_texture) {
+void RasterizerIPhone::fixed_material_set_texture(RID p_material, VS::SpatialMaterialParam p_parameter, RID p_texture) {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND(!m);
@@ -472,7 +473,7 @@ void RasterizerIPhone::fixed_material_set_texture(RID p_material, VS::FixedSpati
m->textures[p_parameter] = p_texture;
}
-RID RasterizerIPhone::fixed_material_get_texture(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const {
+RID RasterizerIPhone::fixed_material_get_texture(RID p_material, VS::SpatialMaterialParam p_parameter) const {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND_V(!m, RID());
@@ -496,7 +497,7 @@ VS::MaterialBlendMode RasterizerIPhone::fixed_material_get_detail_blend_mode(RID
return m->detail_blend_mode;
}
-void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material, VS::FixedSpatialMaterialParam p_parameter, VS::FixedSpatialMaterialTexCoordMode p_mode) {
+void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode) {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND(!m);
@@ -504,7 +505,7 @@ void RasterizerIPhone::fixed_material_set_texcoord_mode(RID p_material, VS::Fixe
m->texcoord_mode[p_parameter] = p_mode;
}
-VS::FixedSpatialMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const {
+VS::SpatialMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter) const {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXCOORD_TEXGEN);
@@ -513,7 +514,7 @@ VS::FixedSpatialMaterialTexCoordMode RasterizerIPhone::fixed_material_get_texcoo
return m->texcoord_mode[p_parameter]; // for now
}
-void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material, VS::FixedSpatialMaterialTexGenMode p_mode) {
+void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material, VS::SpatialMaterialTexGenMode p_mode) {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND(!m);
@@ -521,7 +522,7 @@ void RasterizerIPhone::fixed_material_set_texgen_mode(RID p_material, VS::FixedS
m->texgen_mode = p_mode;
};
-VS::FixedSpatialMaterialTexGenMode RasterizerIPhone::fixed_material_get_texgen_mode(RID p_material) const {
+VS::SpatialMaterialTexGenMode RasterizerIPhone::fixed_material_get_texgen_mode(RID p_material) const {
Material *m = material_owner.get(p_material);
ERR_FAIL_COND_V(!m, VS::FIXED_MATERIAL_TEXGEN_SPHERE);
@@ -1867,7 +1868,7 @@ void RasterizerIPhone::_setup_light(LightInstance *p_instance, int p_idx) {
switch (ld->type) {
case VS::LIGHT_DIRECTIONAL: {
- /* This doesnt have attenuation */
+ /* This doesn't have attenuation */
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
@@ -2088,7 +2089,7 @@ void RasterizerIPhone::_render_list_forward(RenderList *p_render_list) {
uint64_t prev_light_hash = 0;
const Skeleton *prev_skeleton = NULL;
const Geometry *prev_geometry = NULL;
- const ParamOverrideMap *prev_overrides = NULL; // make it diferent than NULL
+ const ParamOverrideMap *prev_overrides = NULL; // make it different than NULL
Geometry::Type prev_geometry_type = Geometry::GEOMETRY_INVALID;
diff --git a/platform/iphone/rasterizer_iphone.h b/platform/iphone/rasterizer_iphone.h
index 02cb985dc8..f886738da9 100644
--- a/platform/iphone/rasterizer_iphone.h
+++ b/platform/iphone/rasterizer_iphone.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -100,11 +101,11 @@ class RasterizerIPhone : public Rasterizer {
RID textures[VisualServer::FIXED_MATERIAL_PARAM_MAX];
Transform uv_transform;
- VS::FixedSpatialMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX];
+ VS::SpatialMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX];
VS::MaterialBlendMode detail_blend_mode;
- VS::FixedSpatialMaterialTexGenMode texgen_mode;
+ VS::SpatialMaterialTexGenMode texgen_mode;
Material() {
@@ -614,20 +615,20 @@ public:
virtual RID material_create();
- virtual void fixed_material_set_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter, const Variant &p_value);
- virtual Variant fixed_material_get_parameter(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const;
+ virtual void fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant &p_value);
+ virtual Variant fixed_material_get_parameter(RID p_material, VS::SpatialMaterialParam p_parameter) const;
- virtual void fixed_material_set_texture(RID p_material, VS::FixedSpatialMaterialParam p_parameter, RID p_texture);
- virtual RID fixed_material_get_texture(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const;
+ virtual void fixed_material_set_texture(RID p_material, VS::SpatialMaterialParam p_parameter, RID p_texture);
+ virtual RID fixed_material_get_texture(RID p_material, VS::SpatialMaterialParam p_parameter) const;
virtual void fixed_material_set_detail_blend_mode(RID p_material, VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const;
- virtual void fixed_material_set_texgen_mode(RID p_material, VS::FixedSpatialMaterialTexGenMode p_mode);
- virtual VS::FixedSpatialMaterialTexGenMode fixed_material_get_texgen_mode(RID p_material) const;
+ virtual void fixed_material_set_texgen_mode(RID p_material, VS::SpatialMaterialTexGenMode p_mode);
+ virtual VS::SpatialMaterialTexGenMode fixed_material_get_texgen_mode(RID p_material) const;
- virtual void fixed_material_set_texcoord_mode(RID p_material, VS::FixedSpatialMaterialParam p_parameter, VS::FixedSpatialMaterialTexCoordMode p_mode);
- virtual VS::FixedSpatialMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material, VS::FixedSpatialMaterialParam p_parameter) const;
+ virtual void fixed_material_set_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode);
+ virtual VS::SpatialMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material, VS::SpatialMaterialParam p_parameter) const;
virtual void fixed_material_set_uv_transform(RID p_material, const Transform &p_transform);
virtual Transform fixed_material_get_uv_transform(RID p_material) const;
diff --git a/platform/iphone/sem_iphone.cpp b/platform/iphone/sem_iphone.cpp
index e74c696607..4614b201a4 100644
--- a/platform/iphone/sem_iphone.cpp
+++ b/platform/iphone/sem_iphone.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/sem_iphone.h b/platform/iphone/sem_iphone.h
index 8a87ab47ca..90db0fb74d 100644
--- a/platform/iphone/sem_iphone.h
+++ b/platform/iphone/sem_iphone.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/view_controller.h b/platform/iphone/view_controller.h
index ca05818040..57ed576c25 100644
--- a/platform/iphone/view_controller.h
+++ b/platform/iphone/view_controller.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm
index 8b3dc7c984..574598e1d3 100644
--- a/platform/iphone/view_controller.mm
+++ b/platform/iphone/view_controller.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -32,44 +33,43 @@
extern "C" {
-int add_path(int, char**);
-int add_cmdline(int, char**);
+int add_path(int, char **);
+int add_cmdline(int, char **);
-int add_path(int p_argc, char** p_args) {
+int add_path(int p_argc, char **p_args) {
- NSString* str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
+ NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"];
if (!str)
return p_argc;
p_args[p_argc++] = "-path";
[str retain]; // memory leak lol (maybe make it static here and delete it in ViewController destructor? @todo
- p_args[p_argc++] = (char*)[str cString];
+ p_args[p_argc++] = (char *)[str cString];
p_args[p_argc] = NULL;
return p_argc;
};
-int add_cmdline(int p_argc, char** p_args) {
+int add_cmdline(int p_argc, char **p_args) {
- NSArray* arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
+ NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_cmdline"];
if (!arr)
return p_argc;
- for (int i=0; i < [arr count]; i++) {
+ for (int i = 0; i < [arr count]; i++) {
- NSString* str = [arr objectAtIndex:i];
+ NSString *str = [arr objectAtIndex:i];
if (!str)
continue;
[str retain]; // @todo delete these at some point
- p_args[p_argc++] = (char*)[str cString];
+ p_args[p_argc++] = (char *)[str cString];
};
p_args[p_argc] = NULL;
return p_argc;
};
-
-};
+}; // extern "C"
@interface ViewController ()
@@ -84,59 +84,58 @@ int add_cmdline(int p_argc, char** p_args) {
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)p_orientation {
- if (/*OSIPhone::get_singleton() == NULL*/TRUE) {
+ if (/*OSIPhone::get_singleton() == NULL*/ TRUE) {
printf("checking on info.plist\n");
- NSArray* arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
- switch(p_orientation) {
+ NSArray *arr = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];
+ switch (p_orientation) {
- case UIInterfaceOrientationLandscapeLeft:
- return [arr indexOfObject:@"UIInterfaceOrientationLandscapeLeft"] != NSNotFound ? YES : NO;
+ case UIInterfaceOrientationLandscapeLeft:
+ return [arr indexOfObject:@"UIInterfaceOrientationLandscapeLeft"] != NSNotFound ? YES : NO;
- case UIInterfaceOrientationLandscapeRight:
- return [arr indexOfObject:@"UIInterfaceOrientationLandscapeRight"] != NSNotFound ? YES : NO;
+ case UIInterfaceOrientationLandscapeRight:
+ return [arr indexOfObject:@"UIInterfaceOrientationLandscapeRight"] != NSNotFound ? YES : NO;
- case UIInterfaceOrientationPortrait:
- return [arr indexOfObject:@"UIInterfaceOrientationPortrait"] != NSNotFound ? YES : NO;
+ case UIInterfaceOrientationPortrait:
+ return [arr indexOfObject:@"UIInterfaceOrientationPortrait"] != NSNotFound ? YES : NO;
- case UIInterfaceOrientationPortraitUpsideDown:
- return [arr indexOfObject:@"UIInterfaceOrientationPortraitUpsideDown"] != NSNotFound ? YES : NO;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ return [arr indexOfObject:@"UIInterfaceOrientationPortraitUpsideDown"] != NSNotFound ? YES : NO;
- default:
- return NO;
+ default:
+ return NO;
}
};
uint8_t supported = OSIPhone::get_singleton()->get_orientations();
- switch(p_orientation) {
+ switch (p_orientation) {
- case UIInterfaceOrientationLandscapeLeft:
- return supported & (1<<OSIPhone::LandscapeLeft) ? YES : NO;
+ case UIInterfaceOrientationLandscapeLeft:
+ return supported & (1 << OSIPhone::LandscapeLeft) ? YES : NO;
- case UIInterfaceOrientationLandscapeRight:
- return supported & (1<<OSIPhone::LandscapeRight) ? YES : NO;
+ case UIInterfaceOrientationLandscapeRight:
+ return supported & (1 << OSIPhone::LandscapeRight) ? YES : NO;
- case UIInterfaceOrientationPortrait:
- return supported & (1<<OSIPhone::PortraitDown) ? YES : NO;
+ case UIInterfaceOrientationPortrait:
+ return supported & (1 << OSIPhone::PortraitDown) ? YES : NO;
- case UIInterfaceOrientationPortraitUpsideDown:
- return supported & (1<<OSIPhone::PortraitUp) ? YES : NO;
+ case UIInterfaceOrientationPortraitUpsideDown:
+ return supported & (1 << OSIPhone::PortraitUp) ? YES : NO;
- default:
- return NO;
+ default:
+ return NO;
}
};
-- (BOOL)prefersStatusBarHidden
-{
+- (BOOL)prefersStatusBarHidden {
return YES;
}
#ifdef GAME_CENTER_ENABLED
-- (void) gameCenterViewControllerDidFinish:(GKGameCenterViewController*) gameCenterViewController {
- //[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone
- GameCenter::get_singleton()->game_center_closed();
- [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
+- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController {
+ //[gameCenterViewController dismissViewControllerAnimated:YES completion:^{GameCenter::get_singleton()->game_center_closed();}];//version for signaling when overlay is completely gone
+ GameCenter::get_singleton()->game_center_closed();
+ [gameCenterViewController dismissViewControllerAnimated:YES completion:nil];
}
#endif
diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index 80bc7047ae..3e37ec293e 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h
index ca5dba7e5c..7ccaff0f43 100644
--- a/platform/javascript/audio_driver_javascript.h
+++ b/platform/javascript/audio_driver_javascript.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp
index 7dfd562402..f9b7890e12 100644
--- a/platform/javascript/audio_server_javascript.cpp
+++ b/platform/javascript/audio_server_javascript.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h
index 2f48e7e79e..58c240f793 100644
--- a/platform/javascript/audio_server_javascript.h
+++ b/platform/javascript/audio_server_javascript.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index f82eae9ff2..41fe3fb027 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -73,11 +73,11 @@ def configure(env):
env.Append(LINKFLAGS=['-O3'])
elif (env["target"] == "release_debug"):
env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED'])
- env.Append(LINKFLAGS=['-O2'])
+ env.Append(LINKFLAGS=['-O2', '-s', 'ASSERTIONS=1'])
# retain function names at the cost of file size, for backtraces and profiling
env.Append(LINKFLAGS=['--profiling-funcs'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-Wall', '-g', '-DDEBUG_ENABLED'])
+ env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-g', '-DDEBUG_ENABLED'])
env.Append(LINKFLAGS=['-O1', '-g'])
# TODO: Move that to opus module's config
diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h
index 53a2705577..979731d157 100644
--- a/platform/javascript/dom_keys.h
+++ b/platform/javascript/dom_keys.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 4fdb6f39c8..1a3c5f3e8f 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,399 +27,303 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "export.h"
-#include "editor/editor_export.h"
#include "editor/editor_node.h"
-#include "editor/editor_settings.h"
-#include "global_config.h"
-#include "io/marshalls.h"
+#include "editor_export.h"
#include "io/zip_io.h"
-#include "os/file_access.h"
-#include "os/os.h"
#include "platform/javascript/logo.h"
-#include "string.h"
-#include "version.h"
-#if 0
-class EditorExportPlatformJavaScript : public EditorExportPlatform {
-
- GDCLASS( EditorExportPlatformJavaScript,EditorExportPlatform );
-
- String custom_release_package;
- String custom_debug_package;
-
- enum PackMode {
- PACK_SINGLE_FILE,
- PACK_MULTIPLE_FILES
- };
-
- void _fix_html(Vector<uint8_t>& p_html, const String& p_name, bool p_debug);
+#define EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE "webassembly_release.zip"
+#define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip"
+#define EXPORT_TEMPLATE_ASMJS_RELEASE "javascript_release.zip"
+#define EXPORT_TEMPLATE_ASMJS_DEBUG "javascript_debug.zip"
- PackMode pack_mode;
-
- bool show_run;
-
- int max_memory;
- int version_code;
+class EditorExportPlatformJavaScript : public EditorExportPlatform {
- String html_title;
- String html_head_include;
- String html_font_family;
- String html_style_include;
- bool html_controls_enabled;
+ GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform)
Ref<ImageTexture> logo;
-protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug);
+ void _fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size);
public:
+ enum Target {
+ TARGET_WEBASSEMBLY,
+ TARGET_ASMJS
+ };
- virtual String get_name() const { return "HTML5"; }
- virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_BC; }
- virtual Ref<Texture> get_logo() const { return logo; }
+ virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
+ virtual void get_export_options(List<ExportOption> *r_options);
+ virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
- virtual bool poll_devices() { return show_run?true:false;}
- virtual int get_device_count() const { return show_run?1:0; };
- virtual String get_device_name(int p_device) const { return "Run in Browser"; }
- virtual String get_device_info(int p_device) const { return "Run exported HTML in the system's default browser."; }
- virtual Error run(int p_device,int p_flags=0);
+ virtual String get_name() const;
+ virtual Ref<Texture> get_logo() const;
- virtual bool requires_password(bool p_debug) const { return false; }
- virtual String get_binary_extension() const { return "html"; }
- virtual Error export_project(const String& p_path,bool p_debug,int p_flags=0);
+ virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
+ virtual String get_binary_extension() const;
+ virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
- virtual bool can_export(String *r_error=NULL) const;
+ virtual int get_device_count() const { return 1; }
+ virtual String get_device_name(int p_device) const { return TTR("Run in Browser"); }
+ virtual String get_device_info(int p_device) const { return TTR("Run exported HTML in the system's default browser."); }
+ virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags);
EditorExportPlatformJavaScript();
- ~EditorExportPlatformJavaScript();
};
-bool EditorExportPlatformJavaScript::_set(const StringName& p_name, const Variant& p_value) {
-
- String n=p_name;
-
- if (n=="custom_package/debug")
- custom_debug_package=p_value;
- else if (n=="custom_package/release")
- custom_release_package=p_value;
- else if (n=="browser/enable_run")
- show_run=p_value;
- else if (n=="options/memory_size")
- max_memory=p_value;
- else if (n=="html/title")
- html_title=p_value;
- else if (n=="html/head_include")
- html_head_include=p_value;
- else if (n=="html/font_family")
- html_font_family=p_value;
- else if (n=="html/style_include")
- html_style_include=p_value;
- else if (n=="html/controls_enabled")
- html_controls_enabled=p_value;
- else
- return false;
+void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug) {
- return true;
-}
+ String str_template = String::utf8(reinterpret_cast<const char *>(p_html.ptr()), p_html.size());
+ String str_export;
+ Vector<String> lines = str_template.split("\n");
-bool EditorExportPlatformJavaScript::_get(const StringName& p_name,Variant &r_ret) const{
-
- String n=p_name;
-
- if (n=="custom_package/debug")
- r_ret=custom_debug_package;
- else if (n=="custom_package/release")
- r_ret=custom_release_package;
- else if (n=="browser/enable_run")
- r_ret=show_run;
- else if (n=="options/memory_size")
- r_ret=max_memory;
- else if (n=="html/title")
- r_ret=html_title;
- else if (n=="html/head_include")
- r_ret=html_head_include;
- else if (n=="html/font_family")
- r_ret=html_font_family;
- else if (n=="html/style_include")
- r_ret=html_style_include;
- else if (n=="html/controls_enabled")
- r_ret=html_controls_enabled;
+ int memory_mb;
+ if (p_preset->get("options/target").operator int() != TARGET_ASMJS)
+ // WebAssembly allows memory growth, so start with a reasonable default
+ memory_mb = 1 << 4;
else
- return false;
-
- return true;
-}
-void EditorExportPlatformJavaScript::_get_property_list( List<PropertyInfo> *p_list) const{
-
- p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE,"zip"));
- p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"zip"));
- p_list->push_back( PropertyInfo( Variant::INT, "options/memory_size",PROPERTY_HINT_ENUM,"32mb,64mb,128mb,256mb,512mb,1024mb"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "browser/enable_run"));
- p_list->push_back( PropertyInfo( Variant::STRING, "html/title"));
- p_list->push_back( PropertyInfo( Variant::STRING, "html/head_include",PROPERTY_HINT_MULTILINE_TEXT));
- p_list->push_back( PropertyInfo( Variant::STRING, "html/font_family"));
- p_list->push_back( PropertyInfo( Variant::STRING, "html/style_include",PROPERTY_HINT_MULTILINE_TEXT));
- p_list->push_back( PropertyInfo( Variant::BOOL, "html/controls_enabled"));
+ memory_mb = 1 << (p_preset->get("options/memory_size").operator int() + 5);
+ for (int i = 0; i < lines.size(); i++) {
- //p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)"));
+ String current_line = lines[i];
+ current_line = current_line.replace("$GODOT_TMEM", itos(memory_mb * 1024 * 1024));
+ current_line = current_line.replace("$GODOT_BASE", p_name);
+ current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include"));
+ current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false");
+ str_export += current_line + "\n";
+ }
+ CharString cs = str_export.utf8();
+ p_html.resize(cs.length());
+ for (int i = 0; i < cs.length(); i++) {
+ p_html[i] = cs[i];
+ }
}
+void EditorExportPlatformJavaScript::_fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size) {
-void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const String& p_name, bool p_debug) {
+ String str_template = String::utf8(reinterpret_cast<const char *>(p_js.ptr()), p_js.size());
+ String str_export;
+ Vector<String> lines = str_template.split("\n");
+ for (int i = 0; i < lines.size(); i++) {
+ if (lines[i].find("$GODOT_PACK_NAME") != -1) {
+ str_export += lines[i].replace("$GODOT_PACK_NAME", p_pack_name);
+ } else if (lines[i].find("$GODOT_PACK_SIZE") != -1) {
+ str_export += lines[i].replace("$GODOT_PACK_SIZE", itos(p_pack_size));
+ } else {
+ str_export += lines[i] + "\n";
+ }
+ }
+ CharString cs = str_export.utf8();
+ p_js.resize(cs.length());
+ for (int i = 0; i < cs.length(); i++) {
+ p_js[i] = cs[i];
+ }
+}
- String str;
- String strnew;
- str.parse_utf8((const char*)p_html.ptr(),p_html.size());
- Vector<String> lines=str.split("\n");
- for(int i=0;i<lines.size();i++) {
+void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) {
- String current_line = lines[i];
- current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024));
- current_line = current_line.replace("$GODOT_BASE",p_name);
- current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/window/width"));
- current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/window/height"));
- current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) GlobalConfig::get_singleton()->get("application/name"));
- current_line = current_line.replace("$GODOT_HEAD_INCLUDE",html_head_include);
- current_line = current_line.replace("$GODOT_STYLE_FONT_FAMILY",html_font_family);
- current_line = current_line.replace("$GODOT_STYLE_INCLUDE",html_style_include);
- current_line = current_line.replace("$GODOT_CONTROLS_ENABLED",html_controls_enabled?"true":"false");
- current_line = current_line.replace("$GODOT_DEBUG_ENABLED",p_debug?"true":"false");
- strnew += current_line+"\n";
+ if (p_preset->get("texture_format/s3tc")) {
+ r_features->push_back("s3tc");
}
-
- CharString cs = strnew.utf8();
- p_html.resize(cs.length());
- for(int i=9;i<cs.length();i++) {
- p_html[i]=cs[i];
+ if (p_preset->get("texture_format/etc")) {
+ r_features->push_back("etc");
+ }
+ if (p_preset->get("texture_format/etc2")) {
+ r_features->push_back("etc2");
}
}
-static void _fix_files(Vector<uint8_t>& html,uint64_t p_data_size) {
+void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/target", PROPERTY_HINT_ENUM, "WebAssembly,asm.js"), TARGET_WEBASSEMBLY));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/memory_size", PROPERTY_HINT_ENUM, "32 MB,64 MB,128 MB,256 MB,512 MB,1 GB"), 3));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), true));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
+ 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"), ""));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
+}
- String str;
- String strnew;
- str.parse_utf8((const char*)html.ptr(),html.size());
- Vector<String> lines=str.split("\n");
- for(int i=0;i<lines.size();i++) {
- if (lines[i].find("$DPLEN")!=-1) {
- strnew+=lines[i].replace("$DPLEN",itos(p_data_size));
- } else {
- strnew+=lines[i]+"\n";
- }
- }
+bool EditorExportPlatformJavaScript::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
- CharString cs = strnew.utf8();
- html.resize(cs.length());
- for(int i=9;i<cs.length();i++) {
- html[i]=cs[i];
+ if (p_option == "options/memory_size") {
+ return p_options["options/target"].operator int() == TARGET_ASMJS;
}
+ return true;
+}
+String EditorExportPlatformJavaScript::get_name() const {
+
+ return "HTML5";
}
-struct JSExportData {
+Ref<Texture> EditorExportPlatformJavaScript::get_logo() const {
- EditorProgress *ep;
- FileAccess *f;
+ return logo;
+}
-};
+bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+ r_missing_templates = false;
+ if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) {
+ if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String())
+ r_missing_templates = true;
+ else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String())
+ r_missing_templates = true;
+ } else {
+ if (find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE) == String())
+ r_missing_templates = true;
+ else if (find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG) == String())
+ r_missing_templates = true;
+ }
-Error EditorExportPlatformJavaScript::export_project(const String& p_path, bool p_debug, int p_flags) {
+ return !r_missing_templates;
+}
+String EditorExportPlatformJavaScript::get_binary_extension() const {
- String src_template;
+ return "html";
+}
- EditorProgress ep("export","Exporting for javascript",104);
+Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
- if (p_debug)
- src_template=custom_debug_package;
- else
- src_template=custom_release_package;
+ String custom_debug = p_preset->get("custom_template/debug");
+ String custom_release = p_preset->get("custom_template/release");
+
+ String template_path = p_debug ? custom_debug : custom_release;
- if (src_template=="") {
- String err;
- if (p_debug) {
- src_template=find_export_template("javascript_debug.zip", &err);
+ template_path = template_path.strip_edges();
+
+ if (template_path == String()) {
+
+ if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) {
+ if (p_debug)
+ template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG);
+ else
+ template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
} else {
- src_template=find_export_template("javascript_release.zip", &err);
- }
- if (src_template=="") {
- EditorNode::add_io_error(err);
- return ERR_FILE_NOT_FOUND;
+ if (p_debug)
+ template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG);
+ else
+ template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE);
}
}
- FileAccess *src_f=NULL;
- zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
-
- ep.step("Exporting to HTML5",0);
+ 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;
+ }
- ep.step("Finding Files..",1);
+ String pck_path = p_path.get_basename() + ".pck";
+ Error error = save_pack(p_preset, pck_path);
+ if (error != OK) {
+ EditorNode::get_singleton()->show_warning(TTR("Could not write file:\n") + pck_path);
+ return error;
+ }
- FileAccess *f=FileAccess::open(p_path.get_base_dir()+"/data.pck",FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(pck_path, FileAccess::READ);
if (!f) {
- EditorNode::add_io_error("Could not create file for writing:\n"+p_path.get_basename()+"_files.js");
- return ERR_FILE_CANT_WRITE;
+ EditorNode::get_singleton()->show_warning(TTR("Could not read file:\n") + pck_path);
+ return ERR_FILE_CANT_READ;
}
- Error err = save_pack(f);
- size_t len = f->get_len();
+ size_t pack_size = f->get_len();
memdelete(f);
- if (err)
- return err;
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+ unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io);
- unzFile pkg = unzOpen2(src_template.utf8().get_data(), &io);
if (!pkg) {
- EditorNode::add_io_error("Could not find template HTML5 to export:\n"+src_template);
+ EditorNode::get_singleton()->show_warning(TTR("Could not open template for export:\n") + template_path);
return ERR_FILE_NOT_FOUND;
}
- ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(pkg);
-
-
- while(ret==UNZ_OK) {
+ while (ret == UNZ_OK) {
//get filename
unz_file_info info;
char fname[16384];
- ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0);
+ ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
- String file=fname;
+ String file = fname;
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
unzOpenCurrentFile(pkg);
- unzReadCurrentFile(pkg,data.ptr(),data.size());
+ unzReadCurrentFile(pkg, data.ptr(), data.size());
unzCloseCurrentFile(pkg);
//write
- if (file=="godot.html") {
+ if (file == "godot.html") {
- _fix_html(data,p_path.get_file().get_basename(), p_debug);
- file=p_path.get_file();
- }
- if (file=="godotfs.js") {
-
- _fix_files(data,len);
- file=p_path.get_file().get_basename()+"fs.js";
- }
- if (file=="godot.js") {
+ _fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug);
+ file = p_path.get_file();
+ } else if (file == "godotfs.js") {
- file=p_path.get_file().get_basename()+".js";
- }
+ _fix_fsloader_js(data, pck_path.get_file(), pack_size);
+ file = p_path.get_file().get_basename() + "fs.js";
+ } else if (file == "godot.js") {
- if (file=="godot.asm.js") {
+ file = p_path.get_file().get_basename() + ".js";
+ } else if (file == "godot.wasm") {
- file=p_path.get_file().get_basename()+".asm.js";
- }
+ file = p_path.get_file().get_basename() + ".wasm";
+ } else if (file == "godot.asm.js") {
- if (file=="godot.mem") {
+ file = p_path.get_file().get_basename() + ".asm.js";
+ } else if (file == "godot.mem") {
- file=p_path.get_file().get_basename()+".mem";
- }
-
- if (file=="godot.wasm") {
-
- file=p_path.get_file().get_basename()+".wasm";
+ file = p_path.get_file().get_basename() + ".mem";
}
String dst = p_path.get_base_dir().plus_file(file);
- FileAccess *f=FileAccess::open(dst,FileAccess::WRITE);
+ FileAccess *f = FileAccess::open(dst, FileAccess::WRITE);
if (!f) {
- EditorNode::add_io_error("Could not create file for writing:\n"+dst);
+ EditorNode::get_singleton()->show_warning(TTR("Could not write file:\n") + dst);
unzClose(pkg);
return ERR_FILE_CANT_WRITE;
}
- f->store_buffer(data.ptr(),data.size());
+ f->store_buffer(data.ptr(), data.size());
memdelete(f);
-
ret = unzGoToNextFile(pkg);
}
-
-
return OK;
-
}
+Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
-Error EditorExportPlatformJavaScript::run(int p_device, int p_flags) {
-
- String path = EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp_export.html";
- Error err = export_project(path,true,p_flags);
- if (err)
+ String path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp_export.html";
+ Error err = export_project(p_preset, true, path, p_debug_flags);
+ if (err) {
return err;
-
+ }
OS::get_singleton()->shell_open(path);
-
return OK;
}
-
EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() {
- show_run=false;
- Image img( _javascript_logo );
- logo = Ref<ImageTexture>( memnew( ImageTexture ));
+ Image img(_javascript_logo);
+ logo.instance();
logo->create_from_image(img);
- max_memory=3;
- html_title="";
- html_font_family="'Droid Sans',arial,sans-serif";
- html_controls_enabled=true;
- pack_mode=PACK_SINGLE_FILE;
-}
-
-bool EditorExportPlatformJavaScript::can_export(String *r_error) const {
-
-
- bool valid=true;
- String err;
-
- if (!exists_export_template("javascript_debug.zip") || !exists_export_template("javascript_release.zip")) {
- valid=false;
- err+="No export templates found.\nDownload and install export templates.\n";
- }
-
- if (custom_debug_package!="" && !FileAccess::exists(custom_debug_package)) {
- valid=false;
- err+="Custom debug package not found.\n";
- }
-
- if (custom_release_package!="" && !FileAccess::exists(custom_release_package)) {
- valid=false;
- err+="Custom release package not found.\n";
- }
-
- if (r_error)
- *r_error=err;
-
- return valid;
-}
-
-
-EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
-
}
-#endif
void register_javascript_exporter() {
- //Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) );
- //EditorImportExport::get_singleton()->add_export_platform(exporter);
+ Ref<EditorExportPlatformJavaScript> platform;
+ platform.instance();
+ EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/javascript/export/export.h b/platform/javascript/export/export.h
index 59c0a67e6d..910c4119f7 100644
--- a/platform/javascript/export/export.h
+++ b/platform/javascript/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html
index 65f3b4a340..6c7069a8f0 100644
--- a/platform/javascript/godot_shell.html
+++ b/platform/javascript/godot_shell.html
@@ -2,8 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
- <title>$GODOT_HEAD_TITLE</title>
-$GODOT_HEAD_INCLUDE
+ <title></title>
<style type="text/css">
body {
margin: 0;
@@ -11,7 +10,7 @@ $GODOT_HEAD_INCLUDE
padding: 0;
text-align: center;
background-color: #222226;
- font-family: $GODOT_STYLE_FONT_FAMILY;
+ font-family: 'Droid Sans', Arial, sans-serif;
}
@@ -27,7 +26,7 @@ $GODOT_HEAD_INCLUDE
}
button.godot {
- font-family: $GODOT_STYLE_FONT_FAMILY; /* override user agent style */
+ font-family: 'Droid Sans', Arial, sans-serif; /* override user agent style */
padding: 1px 5px;
background-color: #37353f;
background-image: linear-gradient(to bottom, #413e49, #3a3842);
@@ -109,53 +108,12 @@ $GODOT_HEAD_INCLUDE
}
- /* On-hover controls
- * ================= */
-
- #controls {
- visibility: hidden;
- opacity: 0.0;
- transition: opacity 500ms ease-in-out 200ms;
- position: absolute;
- right: 16px;
- top: 16px;
- padding: 3px 5px;
- font-size: small;
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- }
-
- :hover > #controls {
- opacity: 1.0;
- transition: opacity 60ms ease-in-out;
- }
-
- #controls > button,
- #controls > label {
- vertical-align: middle;
- margin-left: 2px;
- margin-right: 2px;
- }
-
- #controls > label > input {
- vertical-align: middle;
- }
-
- #controls > label > input[type="checkbox"] {
- /* override user agent style */
- margin-left: 0;
- }
-
- #output-toggle { display: none; }
-
-
/* Debug output
* ============ */
#output-panel {
display: none;
- max-width: $GODOT_CANVAS_WIDTHpx;
+ max-width: 700px;
font-size: small;
margin: 6px auto 0;
padding: 0 4px 4px;
@@ -184,32 +142,18 @@ $GODOT_HEAD_INCLUDE
font-size: small;
font-family: "Lucida Console", Monaco, monospace;
}
-
-
-/* Export style include
- * ==================== */
-
-$GODOT_STYLE_INCLUDE
-
</style>
+$GODOT_HEAD_INCLUDE
</head>
<body>
<div id="container">
- <canvas id="canvas" width="$GODOT_CANVAS_WIDTH" height="$GODOT_CANVAS_HEIGHT" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
+ <canvas id="canvas" width="640" height="480" onclick="canvas.ownerDocument.defaultView.focus();" oncontextmenu="event.preventDefault();">
HTML5 canvas appears to be unsupported in the current browser.<br />
Please try updating or use a different browser.
</canvas>
<div id="status-container">
<span id="status" class="godot" onclick="this.style.visibility='hidden';">Downloading page...</span>
</div>
- <div id="controls" class="godot">
- <label id="output-toggle"><input type="checkbox" checked="checked" autocomplete="off" onchange="Presentation.setOutputVisible(this.checked);" />Display Output</label>
- <!-- hidden until implemented
- <label><input class="postRun-enable" type="checkbox" disabled="disabled" autocomplete="off" />lock cursor</label>
- <label><input class="postRun-enable" type="checkbox" disabled="disabled" autocomplete="off" onchange="Presentation.setCanvasMaximized(this.checked);" />maximize</label>
- -->
- <button id="fullscreen" class="godot postRun-enable" type="button" disabled="disabled" autocomplete="off" onclick="Presentation.requestFullscreen();">Fullscreen</button>
- </div>
</div>
<div id="output-panel" class="godot">
<div id="output-header">
@@ -226,33 +170,9 @@ $GODOT_STYLE_INCLUDE
var canvasElement = document.getElementById("canvas");
var presentation = {
- postRun: [
- function() {
- var elements = document.getElementsByClassName("postRun-enable");
- Array.prototype.slice.call(elements).forEach(function(element) {
- element.disabled = false;
- });
- }
- ],
- requestFullscreen: function requestFullscreen() {
- if (typeof Module !== "undefined" && Module.requestFullscreen) {
- Module.requestFullscreen(false, false);
- }
- },
- /*
- requestPointerlock: function requestPointerlock() {
- if (typeof Module !== "undefined" && Module.requestPointerlock) {
- Module.requestPointerlock(false, false);
- }
- },
- setCanvasMaximized: function setCanvasMaximized(enabled) {
- if (typeof Module !== "undefined" && Module.setCanvasMaximized) {
- Module.setCanvasMaximized(enabled);
- }
- },
- */
+ postRun: [],
setStatusVisible: function setStatusVisible(visible) {
- statusElement.style.visibility = (visible?"visible":"hidden");
+ statusElement.style.visibility = (visible ? "visible" : "hidden");
},
setStatus: function setStatus(text) {
if (text.length === 0) {
@@ -288,18 +208,13 @@ $GODOT_STYLE_INCLUDE
window.onerror = function(event) { presentation.setStatus("Failure during start-up\nSee JavaScript console") };
- if ($GODOT_CONTROLS_ENABLED) { // controls enabled
- document.getElementById("controls").style.visibility="visible";
- }
-
if ($GODOT_DEBUG_ENABLED) { // debugging enabled
var outputRoot = document.getElementById("output-panel");
var outputElement = document.getElementById("output-scroll");
- var outputToggle = document.getElementById("output-toggle");
const maxOutputMessages = 400;
presentation.setOutputVisible = function setOutputVisible(visible) {
- outputRoot.style.display = (visible?"block":"none");
+ outputRoot.style.display = (visible ? "block" : "none");
};
presentation.clearOutput = function clearOutput() {
while (outputElement.firstChild) {
@@ -308,7 +223,6 @@ $GODOT_STYLE_INCLUDE
};
presentation.setOutputVisible(true);
- outputToggle.style.display = "inline";
presentation.print = function print(text) {
if (arguments.length > 1) {
@@ -347,56 +261,59 @@ $GODOT_STYLE_INCLUDE
})();
// Emscripten interface
- var Module = {
- TOTAL_MEMORY: $GODOT_TMEM,
- postRun: (function() {
- if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) {
- return Presentation.postRun;
- }
- })(),
- print: function print(text) {
- if (arguments.length > 1) {
- text = Array.prototype.slice.call(arguments).join(" ");
- }
- console.log(text);
- if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
- Presentation.print(text);
- }
- },
- printErr: function printErr(text) {
- if (arguments.length > 1) {
- text = Array.prototype.slice.call(arguments).join(" ");
- }
- console.error(text);
- if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
- Presentation.print("**ERROR**:", text)
- }
- },
- canvas: (function() {
- var canvas = document.getElementById("canvas");
- // As a default initial behavior, pop up an alert when WebGL context is lost. To make your
- // application robust, you may want to override this behavior before shipping!
- // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
- canvas.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
- return canvas;
-
- })(),
- setStatus: function setStatus(text) {
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m) {
- if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
- return;
- text = m[1];
- }
- if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") {
- Presentation.setStatus(text);
+ var Module = (function() {
+ const BASE_NAME = '$GODOT_BASE';
+ var module = {
+ thisProgram: BASE_NAME,
+ wasmBinaryFile: BASE_NAME + '.wasm',
+ TOTAL_MEMORY: $GODOT_TMEM,
+ print: function print(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ console.log(text);
+ if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
+ Presentation.print(text);
+ }
+ },
+ printErr: function printErr(text) {
+ if (arguments.length > 1) {
+ text = Array.prototype.slice.call(arguments).join(" ");
+ }
+ console.error(text);
+ if (typeof Presentation !== "undefined" && typeof Presentation.print === "function") {
+ Presentation.print("**ERROR**:", text)
+ }
+ },
+ canvas: document.getElementById("canvas"),
+ setStatus: function setStatus(text) {
+ var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
+ var now = Date.now();
+ if (m) {
+ if (now - Date.now() < 30) // if this is a progress update, skip it if too soon
+ return;
+ text = m[1];
+ }
+ if (typeof Presentation !== "undefined" && typeof Presentation.setStatus == "function") {
+ Presentation.setStatus(text);
+ }
}
+ };
+
+ // As a default initial behavior, pop up an alert when WebGL context is lost. To make your
+ // application robust, you may want to override this behavior before shipping!
+ // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
+ module.canvas.addEventListener("webglcontextlost", function(e) { alert("WebGL context lost. Plase reload the page."); e.preventDefault(); }, false);
+
+ if (typeof Presentation !== "undefined" && Presentation.postRun instanceof Array) {
+ module.postRun = Presentation.postRun;
}
- };
+
+ return module;
+ })();
if (!Presentation.isWebGL2Available()) {
- Presentation.setStatus("WebGL2 appears to be unsupported in the current browser.\nPlease try updating or use a different browser.");
+ Presentation.setStatus("WebGL 2 appears to be unsupported.\nPlease update browser and drivers.");
Presentation.preventLoading = true;
} else {
Presentation.setStatus("Downloading...");
diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp
index 897c2276bb..c9312e8d30 100644
--- a/platform/javascript/javascript_eval.cpp
+++ b/platform/javascript/javascript_eval.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/javascript_eval.h b/platform/javascript/javascript_eval.h
index 0050b855d8..4a732cec76 100644
--- a/platform/javascript/javascript_eval.h
+++ b/platform/javascript/javascript_eval.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 00e531baa1..ff29c21b1c 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -145,15 +146,10 @@ int main(int argc, char *argv[]) {
/* Initialize the window */
printf("let it go dude!\n");
glutInit(&argc, argv);
- os = new OS_JavaScript(_gfx_init, NULL, NULL);
-#if 0
- char *args[]={"-test","gui","-v",NULL};
- Error err = Main::setup("apk",3,args);
-#else
- char *args[] = { "-main_pack", "data.pck", NULL }; //pass location of main pack manually, because it wont get an executable name
- Error err = Main::setup("", 2, args);
-
-#endif
+ os = new OS_JavaScript(argv[0], _gfx_init, NULL, NULL);
+
+ Error err = Main::setup(argv[0], argc - 1, &argv[1]);
+
ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility
glutMouseFunc(_glut_mouse_button);
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 83072c30aa..71754502cb 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -331,9 +332,9 @@ bool OS_JavaScript::is_mouse_grab_enabled() const {
return false;
}
-Point2 OS_JavaScript::get_mouse_pos() const {
+Point2 OS_JavaScript::get_mouse_position() const {
- return input->get_mouse_pos();
+ return input->get_mouse_position();
}
int OS_JavaScript::get_mouse_button_state() const {
@@ -520,9 +521,8 @@ void OS_JavaScript::main_loop_focusin() {
void OS_JavaScript::push_input(const InputEvent &p_ev) {
InputEvent ev = p_ev;
- ev.ID = last_id++;
if (ev.type == InputEvent::MOUSE_MOTION) {
- input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
+ input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
} else if (ev.type == InputEvent::MOUSE_BUTTON) {
last_button_mask = ev.mouse_button.button_mask;
}
@@ -540,7 +540,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
//end all if exist
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = false;
@@ -554,7 +553,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -573,7 +571,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
//send mouse
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = true;
@@ -590,7 +587,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = true;
ev.screen_touch.x = touch[i].pos.x;
@@ -605,11 +601,10 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
//send mouse, should look for point 0?
InputEvent ev;
ev.type = InputEvent::MOUSE_MOTION;
- ev.ID = last_id++;
ev.mouse_motion.button_mask = BUTTON_MASK_LEFT;
ev.mouse_motion.x = p_points[0].pos.x;
ev.mouse_motion.y = p_points[0].pos.y;
- input->set_mouse_pos(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
+ input->set_mouse_position(Point2(ev.mouse_motion.x, ev.mouse_motion.y));
ev.mouse_motion.speed_x = input->get_last_mouse_speed().x;
ev.mouse_motion.speed_y = input->get_last_mouse_speed().y;
ev.mouse_motion.relative_x = p_points[0].pos.x - last_mouse.x;
@@ -638,7 +633,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_DRAG;
- ev.ID = last_id++;
ev.screen_drag.index = touch[i].id;
ev.screen_drag.x = p_points[idx].pos.x;
ev.screen_drag.y = p_points[idx].pos.y;
@@ -655,7 +649,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
//end all if exist
InputEvent ev;
ev.type = InputEvent::MOUSE_BUTTON;
- ev.ID = last_id++;
ev.mouse_button.button_index = BUTTON_LEFT;
ev.mouse_button.button_mask = BUTTON_MASK_LEFT;
ev.mouse_button.pressed = false;
@@ -669,7 +662,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -689,7 +681,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = tp.id;
ev.screen_touch.pressed = true;
ev.screen_touch.x = tp.pos.x;
@@ -704,7 +695,6 @@ void OS_JavaScript::process_touch(int p_what, int p_pointer, const Vector<TouchP
InputEvent ev;
ev.type = InputEvent::SCREEN_TOUCH;
- ev.ID = last_id++;
ev.screen_touch.index = touch[i].id;
ev.screen_touch.pressed = false;
ev.screen_touch.x = touch[i].pos.x;
@@ -761,7 +751,7 @@ String OS_JavaScript::get_data_dir() const {
String OS_JavaScript::get_executable_path() const {
- return String();
+ return OS::get_executable_path();
}
void OS_JavaScript::_close_notification_funcs(const String &p_file, int p_flags) {
@@ -790,9 +780,9 @@ void OS_JavaScript::process_joypads() {
InputDefault::JoyAxis jx;
jx.min = 0;
jx.value = value;
- last_id = input->joy_axis(last_id, i, j, jx);
+ input->joy_axis(i, j, jx);
} else {
- last_id = input->joy_button(last_id, i, j, value);
+ input->joy_button(i, j, value);
}
}
for (int j = 0; j < num_axes; j++) {
@@ -800,7 +790,7 @@ void OS_JavaScript::process_joypads() {
InputDefault::JoyAxis jx;
jx.min = -1;
jx.value = state.axis[j];
- last_id = input->joy_axis(last_id, i, j, jx);
+ input->joy_axis(i, j, jx);
}
}
}
@@ -839,12 +829,12 @@ int OS_JavaScript::get_power_percent_left() {
return power_manager->get_power_percent_left();
}
-OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func) {
+OS_JavaScript::OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func) {
+ set_cmdline(p_execpath, get_cmdline_args());
gfx_init_func = p_gfx_init_func;
gfx_init_ud = p_gfx_init_ud;
last_button_mask = 0;
main_loop = NULL;
- last_id = 1;
gl_extensions = NULL;
window_maximized = false;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index b16918b2da..ea906c560f 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -58,7 +59,6 @@ private:
Vector<TouchPos> touch;
Point2 last_mouse;
int last_button_mask;
- unsigned int last_id;
GFXInitFunc gfx_init_func;
void *gfx_init_ud;
@@ -122,7 +122,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
@@ -177,7 +177,7 @@ public:
virtual int get_power_seconds_left();
virtual int get_power_percent_left();
- OS_JavaScript(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func);
+ OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func);
~OS_JavaScript();
};
diff --git a/platform/javascript/platform_config.h b/platform/javascript/platform_config.h
index cdef185ff0..48bcadcc29 100644
--- a/platform/javascript/platform_config.h
+++ b/platform/javascript/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/power_javascript.cpp b/platform/javascript/power_javascript.cpp
index 24158a34fe..bd4502fc2a 100644
--- a/platform/javascript/power_javascript.cpp
+++ b/platform/javascript/power_javascript.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/javascript/power_javascript.h b/platform/javascript/power_javascript.h
index 78a896c430..c7b853ce11 100644
--- a/platform/javascript/power_javascript.h
+++ b/platform/javascript/power_javascript.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index 7ef0669656..7469d52976 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h
index b030570a6e..9b48dab405 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/platform/osx/audio_driver_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/context_gl_osx.cpp b/platform/osx/context_gl_osx.cpp
index 0737e3d3c6..1377d829b0 100644
--- a/platform/osx/context_gl_osx.cpp
+++ b/platform/osx/context_gl_osx.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h
index 66da8b1ecf..d0e2a2c0d3 100644
--- a/platform/osx/context_gl_osx.h
+++ b/platform/osx/context_gl_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/detect.py b/platform/osx/detect.py
index b59dfe1afb..39ee33ae82 100644
--- a/platform/osx/detect.py
+++ b/platform/osx/detect.py
@@ -51,7 +51,7 @@ def configure(env):
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g3', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
if (not os.environ.has_key("OSXCROSS_ROOT")):
# regular native build
diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h
index 56a8e057dd..6dcff3898c 100644
--- a/platform/osx/dir_access_osx.h
+++ b/platform/osx/dir_access_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
index 476da2635e..37ba0e6b19 100644
--- a/platform/osx/dir_access_osx.mm
+++ b/platform/osx/dir_access_osx.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -34,17 +35,14 @@
#include <Foundation/NSString.h>
-
-String DirAccessOSX::fix_unicode_name(const char* p_name) const {
+String DirAccessOSX::fix_unicode_name(const char *p_name) const {
String fname;
- NSString* nsstr = [[NSString stringWithUTF8String: p_name] precomposedStringWithCanonicalMapping];
+ NSString *nsstr = [[NSString stringWithUTF8String:p_name] precomposedStringWithCanonicalMapping];
fname.parse_utf8([nsstr UTF8String]);
return fname;
}
-
-
#endif //posix_enabled
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index ba4ef0300c..2033bc76a1 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/export/export.h b/platform/osx/export/export.h
index 98e63ff48e..50604f068f 100644
--- a/platform/osx/export/export.h
+++ b/platform/osx/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm
index 8eedd7f6fc..0bf678f9b7 100644
--- a/platform/osx/godot_main_osx.mm
+++ b/platform/osx/godot_main_osx.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,68 +27,62 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "os_osx.h"
#include "main/main.h"
+#include "os_osx.h"
+
#include <string.h>
#include <unistd.h>
-//#define main godot_main
-
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
int first_arg = 1;
- const char* dbg_arg = "-NSDocumentRevisionsDebugMode";
+ const char *dbg_arg = "-NSDocumentRevisionsDebugMode";
printf("arguments\n");
- for (int i=0; i<argc; i++) {
+ for (int i = 0; i < argc; i++) {
if (strcmp(dbg_arg, argv[i]) == 0)
- first_arg = i+2;
+ first_arg = i + 2;
printf("%i: %s\n", i, argv[i]);
};
-
- if (argc>=1 && argv[0][0]=='/') {
+ if (argc >= 1 && argv[0][0] == '/') {
//potentially launched from finder
int len = strlen(argv[0]);
while (len--) {
if (argv[0][len] == '/') break;
}
- if (len>=0) {
- char *path = (char *)malloc(len+1);
+ if (len >= 0) {
+ char *path = (char *)malloc(len + 1);
memcpy(path, argv[0], len);
- path[len]=0;
+ path[len] = 0;
- char *pathinfo = (char*)malloc(strlen(path)+strlen("/../Info.plist")+1);
- //in real code you would check for errors in malloc here
+ char *pathinfo = (char *)malloc(strlen(path) + strlen("/../Info.plist") + 1);
+ //in real code you would check for errors in malloc here
strcpy(pathinfo, path);
strcat(pathinfo, "/../Info.plist");
- FILE*f=fopen(pathinfo,"rb");
+ FILE *f = fopen(pathinfo, "rb");
if (f) {
//running from app bundle, as Info.plist was found
fclose(f);
chdir(path);
chdir("../Resources"); //data.pck, or just the files are here
-
}
free(path);
free(pathinfo);
}
-
-
-
}
OS_OSX os;
-
- Error err = Main::setup(argv[0],argc-first_arg,&argv[first_arg]);
- if (err!=OK)
+ Error err = Main::setup(argv[0], argc - first_arg, &argv[first_arg]);
+ if (err != OK)
return 255;
if (Main::start())
os.run(); // it is actually the OS that decides how to run
+
Main::cleanup();
return 0;
diff --git a/platform/osx/godot_osx.h b/platform/osx/godot_osx.h
index b6f2b06f26..48784ab7d5 100644
--- a/platform/osx/godot_osx.h
+++ b/platform/osx/godot_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/godot_osx.mm b/platform/osx/godot_osx.mm
index 2296fb016f..626406ad1d 100644
--- a/platform/osx/godot_osx.mm
+++ b/platform/osx/godot_osx.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,144 +27,139 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "godot_osx.h"
+
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
-#include "godot_osx.h"
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
but the method still is there and works. To avoid warnings, we declare
it ourselves here. */
-@interface NSApplication()
+@interface NSApplication ()
- (void)setAppleMenu:(NSMenu *)menu;
@end
-static int global_argc;
-static char **global_argv;
-static BOOL gCalledAppMainline = FALSE;
+static int global_argc;
+static char **global_argv;
+static BOOL gCalledAppMainline = FALSE;
-static NSString *getApplicationName(void)
-{
- const NSDictionary *dict;
- NSString *appName = 0;
+static NSString *getApplicationName(void) {
+ const NSDictionary *dict;
+ NSString *appName = 0;
- /* Determine the application name */
- dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
- if (dict)
- appName = [dict objectForKey: @"CFBundleName"];
+ /* Determine the application name */
+ dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
+ if (dict)
+ appName = [dict objectForKey:@"CFBundleName"];
- if (![appName length])
- appName = [[NSProcessInfo processInfo] processName];
+ if (![appName length])
+ appName = [[NSProcessInfo processInfo] processName];
- return appName;
+ return appName;
}
/* The main class of the application, the application's delegate */
@implementation GodotMain
-static void setApplicationMenu(void)
-{
- /* warning: this code is very odd */
- NSMenu *appleMenu;
- NSMenuItem *menuItem;
- NSString *title;
- NSString *appName;
+static void setApplicationMenu(void) {
+ /* warning: this code is very odd */
+ NSMenu *appleMenu;
+ NSMenuItem *menuItem;
+ NSString *title;
+ NSString *appName;
- appName = getApplicationName();
- appleMenu = [[NSMenu alloc] initWithTitle:@""];
+ appName = getApplicationName();
+ appleMenu = [[NSMenu alloc] initWithTitle:@""];
- /* Add menu items */
- title = [@"About " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+ /* Add menu items */
+ title = [@"About " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
- [appleMenu addItem:[NSMenuItem separatorItem]];
+ [appleMenu addItem:[NSMenuItem separatorItem]];
- title = [@"Hide " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
+ title = [@"Hide " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
- menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
+ menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
- [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
+ [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
- [appleMenu addItem:[NSMenuItem separatorItem]];
+ [appleMenu addItem:[NSMenuItem separatorItem]];
- title = [@"Quit " stringByAppendingString:appName];
- [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+ title = [@"Quit " stringByAppendingString:appName];
+ [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+ /* Put menu into the menubar */
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
+ [menuItem setSubmenu:appleMenu];
+ [[NSApp mainMenu] addItem:menuItem];
- /* Put menu into the menubar */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
- [menuItem setSubmenu:appleMenu];
- [[NSApp mainMenu] addItem:menuItem];
+ /* Tell the application object that this is now the application menu */
+ [NSApp setAppleMenu:appleMenu];
- /* Tell the application object that this is now the application menu */
- [NSApp setAppleMenu:appleMenu];
-
- /* Finally give up our references to the objects */
- [appleMenu release];
- [menuItem release];
+ /* Finally give up our references to the objects */
+ [appleMenu release];
+ [menuItem release];
}
/* Create a window menu */
-static void setupWindowMenu(void)
-{
- NSMenu *windowMenu;
- NSMenuItem *windowMenuItem;
- NSMenuItem *menuItem;
-
- windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-
- /* "Minimize" item */
- menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
- [windowMenu addItem:menuItem];
- [menuItem release];
-
- /* Put menu into the menubar */
- windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
- [windowMenuItem setSubmenu:windowMenu];
- [[NSApp mainMenu] addItem:windowMenuItem];
-
- /* Tell the application object that this is now the window menu */
- [NSApp setWindowsMenu:windowMenu];
-
- /* Finally give up our references to the objects */
- [windowMenu release];
- [windowMenuItem release];
+static void setupWindowMenu(void) {
+ NSMenu *windowMenu;
+ NSMenuItem *windowMenuItem;
+ NSMenuItem *menuItem;
+
+ windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
+
+ /* "Minimize" item */
+ menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
+ [windowMenu addItem:menuItem];
+ [menuItem release];
+
+ /* Put menu into the menubar */
+ windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
+ [windowMenuItem setSubmenu:windowMenu];
+ [[NSApp mainMenu] addItem:windowMenuItem];
+
+ /* Tell the application object that this is now the window menu */
+ [NSApp setWindowsMenu:windowMenu];
+
+ /* Finally give up our references to the objects */
+ [windowMenu release];
+ [windowMenuItem release];
}
/* Replacement for NSApplicationMain */
-static void CustomApplicationMain (int argc, char **argv)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GodotMain *main;
+static void CustomApplicationMain(int argc, char **argv) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ GodotMain *main;
- /* Ensure the application object is initialised */
- [NSApplication sharedApplication];
+ /* Ensure the application object is initialised */
+ [NSApplication sharedApplication];
- /* Set up the menubar */
- [NSApp setMainMenu:[[NSMenu alloc] init]];
- setApplicationMenu();
- setupWindowMenu();
+ /* Set up the menubar */
+ [NSApp setMainMenu:[[NSMenu alloc] init]];
+ setApplicationMenu();
+ setupWindowMenu();
main = [[main alloc] init];
[NSApp setDelegate:main];
- /* Start the main event loop */
- [NSApp run];
+ /* Start the main event loop */
+ [NSApp run];
[main release];
- [pool release];
+ [pool release];
}
-extern int godot_main(int argc, char** argv);
+extern int godot_main(int argc, char **argv);
/* Called when the internal event loop has just started running */
-- (void) applicationDidFinishLaunching: (NSNotification *) note
-{
- int status;
+- (void)applicationDidFinishLaunching:(NSNotification *)note {
+ int status;
- /* Hand off to main application code */
- gCalledAppMainline = TRUE;
+ /* Hand off to main application code */
+ gCalledAppMainline = TRUE;
int ret = godot_main(global_argc, global_argv);
@@ -172,16 +168,14 @@ extern int godot_main(int argc, char** argv);
@end
#ifdef main
-# undef main
+#undef main
#endif
-
-int main (int argc, char **argv)
-{
- /* Copy the arguments into a global variable */
- /* This is passed if we are launched by double-clicking */
- if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
- global_argv = (char **) malloc(sizeof (char *) * 2);
+int main(int argc, char **argv) {
+ /* Copy the arguments into a global variable */
+ /* This is passed if we are launched by double-clicking */
+ if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
+ global_argv = (char **)malloc(sizeof(char *) * 2);
global_argv[0] = argv[0];
global_argv[1] = NULL;
global_argc = 1;
@@ -189,27 +183,26 @@ int main (int argc, char **argv)
// chdir to binary's dir when launched from finder
int len = strlen(global_argv[0]);
- while (len--){
+ while (len--) {
if (global_argv[0][len] == '/') break;
}
- if (len>=0) {
- char *path = (char *)malloc(len+1);
+ if (len >= 0) {
+ char *path = (char *)malloc(len + 1);
memcpy(path, global_argv[0], len);
- path[len]=0;
+ path[len] = 0;
printf("Path: %s\n", path);
chdir(path);
}
- } else {
- int i;
+ } else {
+ int i;
global_argc = argc;
- global_argv = (char **) malloc(sizeof (char *) * (argc+1));
- for (i = 0; i <= argc; i++)
+ global_argv = (char **)malloc(sizeof(char *) * (argc + 1));
+ for (i = 0; i <= argc; i++)
global_argv[i] = argv[i];
- }
+ }
- CustomApplicationMain (argc, argv);
- return 0;
+ CustomApplicationMain(argc, argv);
+ return 0;
}
-
diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index c2b0e1f052..1a4b3a460e 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -458,7 +459,7 @@ static const InputDefault::JoyAxis axis_correct(int p_value, int p_min, int p_ma
return jx;
}
-uint32_t JoypadOSX::process_joypads(uint32_t p_last_id) {
+void JoypadOSX::process_joypads() {
poll_joypads();
for (int i = 0; i < device_list.size(); i++) {
@@ -467,17 +468,17 @@ uint32_t JoypadOSX::process_joypads(uint32_t p_last_id) {
for (int j = 0; j < joy.axis_elements.size(); j++) {
rec_element &elem = joy.axis_elements[j];
int value = joy.get_hid_element_state(&elem);
- p_last_id = input->joy_axis(p_last_id, joy.id, j, axis_correct(value, elem.min, elem.max));
+ input->joy_axis(joy.id, j, axis_correct(value, elem.min, elem.max));
}
for (int j = 0; j < joy.button_elements.size(); j++) {
int value = joy.get_hid_element_state(&joy.button_elements[j]);
- p_last_id = input->joy_button(p_last_id, joy.id, j, (value >= 1));
+ input->joy_button(joy.id, j, (value >= 1));
}
for (int j = 0; j < joy.hat_elements.size(); j++) {
rec_element &elem = joy.hat_elements[j];
int value = joy.get_hid_element_state(&elem);
int hat_value = process_hat_value(elem.min, elem.max, value);
- p_last_id = input->joy_hat(p_last_id, joy.id, hat_value);
+ input->joy_hat(joy.id, hat_value);
}
if (joy.ffservice) {
@@ -494,7 +495,6 @@ uint32_t JoypadOSX::process_joypads(uint32_t p_last_id) {
}
}
}
- return p_last_id;
}
void JoypadOSX::joypad_vibration_start(int p_id, float p_magnitude, float p_duration, uint64_t p_timestamp) {
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h
index dabd1b8aec..bfbc523cff 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -110,7 +111,7 @@ private:
void joypad_vibration_stop(int p_id, uint64_t p_timestamp);
public:
- uint32_t process_joypads(uint32_t p_last_id);
+ void process_joypads();
void _device_added(IOReturn p_res, IOHIDDeviceRef p_device);
void _device_removed(int p_id);
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 2c7ad09b89..2ecc379a7f 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -61,7 +62,6 @@ public:
List<String> args;
MainLoop *main_loop;
- unsigned int event_id;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
@@ -83,7 +83,6 @@ public:
// pthread_key_t current;
bool mouse_grab;
Point2 mouse_pos;
- uint32_t last_id;
id delegate;
id window_delegate;
@@ -146,7 +145,7 @@ public:
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
virtual void warp_mouse_pos(const Point2 &p_to);
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 0699978caf..c6c2e6dab1 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,35 +27,32 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#import <Cocoa/Cocoa.h>
+#include "os_osx.h"
+
+#include "dir_access_osx.h"
+#include "drivers/gles3/rasterizer_gles3.h"
+#include "main/main.h"
+#include "os/keyboard.h"
+#include "print_string.h"
+#include "sem_osx.h"
+#include "servers/physics/physics_server_sw.h"
+#include "servers/visual/visual_server_raster.h"
#include <Carbon/Carbon.h>
-#include <IOKit/IOKitLib.h>
+#import <Cocoa/Cocoa.h>
#include <IOKit/IOCFPlugIn.h>
-#include <IOKit/hid/IOHIDLib.h>
+#include <IOKit/IOKitLib.h>
#include <IOKit/hid/IOHIDKeys.h>
+#include <IOKit/hid/IOHIDLib.h>
-#include "sem_osx.h"
-#include "servers/visual/visual_server_raster.h"
-//#include "drivers/opengl/rasterizer_gl.h"
-//#include "drivers/gles2/rasterizer_gles2.h"
-#include "drivers/gles3/rasterizer_gles3.h"
-#include "os_osx.h"
+#include <fcntl.h>
+#include <libproc.h>
#include <stdio.h>
#include <stdlib.h>
-#include "print_string.h"
-#include "servers/physics/physics_server_sw.h"
-// #include "drivers/gles2/rasterizer_instance_gles2.h"
-// #include "servers/visual/visual_server_wrap_mt.h"
-#include "main/main.h"
-#include "os/keyboard.h"
-#include "dir_access_osx.h"
-
-#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <libproc.h>
+
//uses portions of glfw
//========================================================================
@@ -87,33 +85,29 @@
static NSRect convertRectToBacking(NSRect contentRect) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
- return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
- else
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
+ return [OS_OSX::singleton->window_view convertRectToBacking:contentRect];
+ else
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
- return contentRect;
-
+ return contentRect;
}
-static InputModifierState translateFlags(NSUInteger flags)
-{
- InputModifierState mod;
-
+static InputModifierState translateFlags(NSUInteger flags) {
+ InputModifierState mod;
- mod.shift = (flags & NSShiftKeyMask);
- mod.control = (flags & NSControlKeyMask);
- mod.alt = (flags & NSAlternateKeyMask);
- mod.meta = (flags & NSCommandKeyMask);
+ mod.shift = (flags & NSShiftKeyMask);
+ mod.control = (flags & NSControlKeyMask);
+ mod.alt = (flags & NSAlternateKeyMask);
+ mod.meta = (flags & NSCommandKeyMask);
- return mod;
+ return mod;
}
-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 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;
@interface GodotApplication : NSApplication
@end
@@ -123,12 +117,11 @@ static int button_mask=0;
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
-- (void)sendEvent:(NSEvent *)event
-{
- if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
- [[self keyWindow] sendEvent:event];
- else
- [super sendEvent:event];
+- (void)sendEvent:(NSEvent *)event {
+ if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
+ [[self keyWindow] sendEvent:event];
+ else
+ [super sendEvent:event];
}
@end
@@ -138,45 +131,39 @@ static int button_mask=0;
@implementation GodotApplicationDelegate
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
-{
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
return NSTerminateCancel;
}
-- (void)applicationDidHide:(NSNotification *)notification
-{
+- (void)applicationDidHide:(NSNotification *)notification {
/*
_Godotwindow* window;
for (window = _Godot.windowListHead; window; window = window->next)
_GodotInputWindowVisibility(window, GL_FALSE);
- */
+*/
}
-- (void)applicationDidUnhide:(NSNotification *)notification
-{
+- (void)applicationDidUnhide:(NSNotification *)notification {
/*
_Godotwindow* window;
- for (window = _Godot.windowListHead; window; window = window->next)
- {
- if ([window_object isVisible])
- _GodotInputWindowVisibility(window, GL_TRUE);
+ for (window = _Godot.windowListHead; window; window = window->next) {
+ if ([window_object isVisible])
+ _GodotInputWindowVisibility(window, GL_TRUE);
}
- */
+*/
}
-- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
-{
+- (void)applicationDidChangeScreenParameters:(NSNotification *)notification {
//_GodotInputMonitorChange();
}
@end
-@interface GodotWindowDelegate : NSObject
-{
+@interface GodotWindowDelegate : NSObject {
//_Godotwindow* window;
}
@@ -184,28 +171,22 @@ static int button_mask=0;
@implementation GodotWindowDelegate
-
-- (BOOL)windowShouldClose:(id)sender
-{
+- (BOOL)windowShouldClose:(id)sender {
//_GodotInputWindowCloseRequest(window);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
- return NO;
-}
-
-
-
-- (void)windowDidResize:(NSNotification *)notification
-{
- [OS_OSX::singleton->context update];
+ return NO;
+}
- const NSRect contentRect = [OS_OSX::singleton->window_view frame];
- const NSRect fbRect = contentRect;//convertRectToBacking(contentRect);
+- (void)windowDidResize:(NSNotification *)notification {
+ [OS_OSX::singleton->context update];
- OS_OSX::singleton->window_size.width=fbRect.size.width*OS_OSX::singleton->display_scale;
- OS_OSX::singleton->window_size.height=fbRect.size.height*OS_OSX::singleton->display_scale;
+ const NSRect contentRect = [OS_OSX::singleton->window_view frame];
+ const NSRect fbRect = contentRect; //convertRectToBacking(contentRect);
+ OS_OSX::singleton->window_size.width = fbRect.size.width * OS_OSX::singleton->display_scale;
+ OS_OSX::singleton->window_size.height = fbRect.size.height * OS_OSX::singleton->display_scale;
/*
_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
@@ -214,11 +195,10 @@ static int button_mask=0;
if (window->cursorMode == Godot_CURSOR_DISABLED)
centerCursor(window);
- */
+*/
}
-- (void)windowDidMove:(NSNotification *)notification
-{
+- (void)windowDidMove:(NSNotification *)notification {
/*
[window->nsgl.context update];
@@ -228,35 +208,30 @@ static int button_mask=0;
if (window->cursorMode == Godot_CURSOR_DISABLED)
centerCursor(window);
- */
+*/
}
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
+- (void)windowDidBecomeKey:(NSNotification *)notification {
//_GodotInputWindowFocus(window, GL_TRUE);
//_GodotPlatformSetCursorMode(window, window->cursorMode);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
}
-- (void)windowDidResignKey:(NSNotification *)notification
-{
+- (void)windowDidResignKey:(NSNotification *)notification {
//_GodotInputWindowFocus(window, GL_FALSE);
//_GodotPlatformSetCursorMode(window, Godot_CURSOR_NORMAL);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
}
-- (void)windowDidMiniaturize:(NSNotification*)notification
-{
+- (void)windowDidMiniaturize:(NSNotification *)notification {
OS_OSX::singleton->wm_minimized(true);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
};
-- (void)windowDidDeminiaturize:(NSNotification*)notification
-{
-
+- (void)windowDidDeminiaturize:(NSNotification *)notification {
OS_OSX::singleton->wm_minimized(false);
if (OS_OSX::singleton->get_main_loop())
OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
@@ -264,549 +239,525 @@ static int button_mask=0;
@end
-@interface GodotContentView : NSView
-{
- NSTrackingArea* trackingArea;
+@interface GodotContentView : NSView {
+ NSTrackingArea *trackingArea;
}
-
-
@end
@implementation GodotContentView
-+ (void)initialize
-{
- if (self == [GodotContentView class])
- {
++ (void)initialize {
+ if (self == [GodotContentView class]) {
/*
- if (_glfw.ns.cursor == nil)
- {
+ if (_glfw.ns.cursor == nil) {
NSImage* data = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
_glfw.ns.cursor = [[NSCursor alloc] initWithImage:data
hotSpot:NSZeroPoint];
[data release];
}
- */
+*/
}
}
-- (id)init
-{
- self = [super init];
- trackingArea = nil;
- [self updateTrackingAreas];
- [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
- return self;
+- (id)init {
+ self = [super init];
+ trackingArea = nil;
+ [self updateTrackingAreas];
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
+ return self;
}
-
--(void)dealloc
-{
- [trackingArea release];
- [super dealloc];
+- (void)dealloc {
+ [trackingArea release];
+ [super dealloc];
}
-- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender {
- return NSDragOperationCopy;
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
+ return NSDragOperationCopy;
}
- (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender {
- return NSDragOperationCopy;
+ return NSDragOperationCopy;
}
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
+ NSPasteboard *pboard = [sender draggingPasteboard];
+ NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
+
+ Vector<String> files;
+ for (int i = 0; i < filenames.count; i++) {
+ NSString *ns = [filenames objectAtIndex:i];
+ char *utfs = strdup([ns UTF8String]);
+ String ret;
+ ret.parse_utf8(utfs);
+ free(utfs);
+ files.push_back(ret);
+ }
- NSPasteboard *pboard = [sender draggingPasteboard];
- NSArray *filenames = [pboard propertyListForType:NSFilenamesPboardType];
-
- Vector<String> files;
- for(int i=0;i<filenames.count;i++) {
- NSString *ns = [filenames objectAtIndex:i];
- char *utfs = strdup([ns UTF8String]);
- String ret;
- ret.parse_utf8(utfs);
- free(utfs);
- files.push_back(ret);
-
-
- }
-
- if (files.size()) {
- OS_OSX::singleton->main_loop->drop_files(files,0);
- OS_OSX::singleton->move_window_to_foreground();
- }
+ if (files.size()) {
+ OS_OSX::singleton->main_loop->drop_files(files, 0);
+ OS_OSX::singleton->move_window_to_foreground();
+ }
- return NO;
+ return NO;
}
-
-- (BOOL)isOpaque
-{
- return YES;
+- (BOOL)isOpaque {
+ return YES;
}
-- (BOOL)canBecomeKeyView
-{
- return YES;
+- (BOOL)canBecomeKeyView {
+ return YES;
}
-- (BOOL)acceptsFirstResponder
-{
- return YES;
+- (BOOL)acceptsFirstResponder {
+ return YES;
}
-- (void)cursorUpdate:(NSEvent *)event
-{
- // setModeCursor(window, window->cursorMode);
+- (void)cursorUpdate:(NSEvent *)event {
+ //setModeCursor(window, window->cursorMode);
}
-- (void)mouseDown:(NSEvent *)event
-{
+- (void)mouseDown:(NSEvent *)event {
//print_line("mouse down:");
- button_mask|=BUTTON_MASK_LEFT;
+ button_mask |= BUTTON_MASK_LEFT;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_LEFT;
- ev.mouse_button.pressed=true;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
- ev.mouse_button.doubleclick = [event clickCount]==2;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_LEFT;
+ ev.mouse_button.pressed = true;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
+ ev.mouse_button.doubleclick = [event clickCount] == 2;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
-
- /* _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_LEFT,
- GLFW_PRESS,
- translateFlags([event modifierFlags]));*/
+ /*
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_LEFT,
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)mouseDragged:(NSEvent *)event
-{
- [self mouseMoved:event];
+- (void)mouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
}
-- (void)mouseUp:(NSEvent *)event
-{
+- (void)mouseUp:(NSEvent *)event {
- button_mask&=~BUTTON_MASK_LEFT;
+ button_mask &= ~BUTTON_MASK_LEFT;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_LEFT;
- ev.mouse_button.pressed=false;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_LEFT;
+ ev.mouse_button.pressed = false;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
- /* _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_LEFT,
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));*/
+ /*
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_LEFT,
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)mouseMoved:(NSEvent *)event
-{
+- (void)mouseMoved:(NSEvent *)event {
InputEvent ev;
- ev.type=InputEvent::MOUSE_MOTION;
- ev.mouse_motion.button_mask=button_mask;
- prev_mouse_x=mouse_x;
- prev_mouse_y=mouse_y;
+ ev.type = InputEvent::MOUSE_MOTION;
+ ev.mouse_motion.button_mask = button_mask;
+ prev_mouse_x = mouse_x;
+ prev_mouse_y = mouse_y;
const NSRect contentRect = [OS_OSX::singleton->window_view frame];
const NSPoint p = [event locationInWindow];
mouse_x = p.x * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
mouse_y = (contentRect.size.height - p.y) * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
- ev.mouse_motion.x=mouse_x;
- ev.mouse_motion.y=mouse_y;
- ev.mouse_motion.global_x=mouse_x;
- ev.mouse_motion.global_y=mouse_y;
- ev.mouse_motion.relative_x=[event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
- ev.mouse_motion.relative_y=[event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ ev.mouse_motion.x = mouse_x;
+ ev.mouse_motion.y = mouse_y;
+ ev.mouse_motion.global_x = mouse_x;
+ ev.mouse_motion.global_y = mouse_y;
+ ev.mouse_motion.relative_x = [event deltaX] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
+ ev.mouse_motion.relative_y = [event deltaY] * OS_OSX::singleton->_mouse_scale([[event window] backingScaleFactor]);
ev.mouse_motion.mod = translateFlags([event modifierFlags]);
- OS_OSX::singleton->input->set_mouse_pos(Point2(mouse_x,mouse_y));
+ OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
OS_OSX::singleton->push_input(ev);
+ /*
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
+ _glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
+ else {
+ const NSRect contentRect = [window->ns.view frame];
+ const NSPoint p = [event locationInWindow];
- /* if (window->cursorMode == GLFW_CURSOR_DISABLED)
- _glfwInputCursorMotion(window, [event deltaX], [event deltaY]);
- else
- {
- const NSRect contentRect = [window->ns.view frame];
- const NSPoint p = [event locationInWindow];
-
- _glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
- }*/
+ _glfwInputCursorMotion(window, p.x, contentRect.size.height - p.y);
+ }
+*/
}
-- (void)rightMouseDown:(NSEvent *)event
-{
+- (void)rightMouseDown:(NSEvent *)event {
- button_mask|=BUTTON_MASK_RIGHT;
+ button_mask |= BUTTON_MASK_RIGHT;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_RIGHT;
- ev.mouse_button.pressed=true;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_RIGHT;
+ ev.mouse_button.pressed = true;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
- /* _glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_RIGHT,
- GLFW_PRESS,
- translateFlags([event modifierFlags]));*/
+ /*
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_RIGHT,
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)rightMouseDragged:(NSEvent *)event
-{
- [self mouseMoved:event];
+- (void)rightMouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
}
-- (void)rightMouseUp:(NSEvent *)event
-{
+- (void)rightMouseUp:(NSEvent *)event {
- button_mask&=~BUTTON_MASK_RIGHT;
+ button_mask &= ~BUTTON_MASK_RIGHT;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_RIGHT;
- ev.mouse_button.pressed=false;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_RIGHT;
+ ev.mouse_button.pressed = false;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
- /*_glfwInputMouseClick(window,
- GLFW_MOUSE_BUTTON_RIGHT,
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));*/
+ /*
+ _glfwInputMouseClick(window,
+ GLFW_MOUSE_BUTTON_RIGHT,
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)otherMouseDown:(NSEvent *)event
-{
+- (void)otherMouseDown:(NSEvent *)event {
- if ((int) [event buttonNumber]!=2)
+ if ((int)[event buttonNumber] != 2)
return;
- button_mask|=BUTTON_MASK_MIDDLE;
+ button_mask |= BUTTON_MASK_MIDDLE;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_MIDDLE;
- ev.mouse_button.pressed=true;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_MIDDLE;
+ ev.mouse_button.pressed = true;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
- /*_glfwInputMouseClick(window,
- (int) [event buttonNumber],
- GLFW_PRESS,
- translateFlags([event modifierFlags]));*/
+ /*
+ _glfwInputMouseClick(window,
+ (int) [event buttonNumber],
+ GLFW_PRESS,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)otherMouseDragged:(NSEvent *)event
-{
- [self mouseMoved:event];
+- (void)otherMouseDragged:(NSEvent *)event {
+ [self mouseMoved:event];
}
-- (void)otherMouseUp:(NSEvent *)event
-{
+- (void)otherMouseUp:(NSEvent *)event {
- if ((int) [event buttonNumber]!=2)
+ if ((int)[event buttonNumber] != 2)
return;
- button_mask&=~BUTTON_MASK_MIDDLE;
+ button_mask &= ~BUTTON_MASK_MIDDLE;
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=BUTTON_MIDDLE;
- ev.mouse_button.pressed=false;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = BUTTON_MIDDLE;
+ ev.mouse_button.pressed = false;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
ev.mouse_button.mod = translateFlags([event modifierFlags]);
OS_OSX::singleton->push_input(ev);
- /* _glfwInputMouseClick(window,
- (int) [event buttonNumber],
- GLFW_RELEASE,
- translateFlags([event modifierFlags]));*/
+
+ /*
+ _glfwInputMouseClick(window,
+ (int) [event buttonNumber],
+ GLFW_RELEASE,
+ translateFlags([event modifierFlags]));
+*/
}
-- (void)mouseExited:(NSEvent *)event
-{
+- (void)mouseExited:(NSEvent *)event {
if (!OS_OSX::singleton)
return;
- if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
+ if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
if (OS_OSX::singleton->input)
OS_OSX::singleton->input->set_mouse_in_window(false);
- // _glfwInputCursorEnter(window, GL_FALSE);
+ //_glfwInputCursorEnter(window, GL_FALSE);
}
-- (void)mouseEntered:(NSEvent *)event
-{
- // _glfwInputCursorEnter(window, GL_TRUE);
+- (void)mouseEntered:(NSEvent *)event {
+ //_glfwInputCursorEnter(window, GL_TRUE);
if (!OS_OSX::singleton)
return;
- if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode!=OS::MOUSE_MODE_CAPTURED)
+ if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
if (OS_OSX::singleton->input)
OS_OSX::singleton->input->set_mouse_in_window(true);
-
}
-- (void)viewDidChangeBackingProperties
-{
- /* const NSRect contentRect = [window->ns.view frame];
- const NSRect fbRect = convertRectToBacking(window, contentRect);
+- (void)viewDidChangeBackingProperties {
+ /*
+ const NSRect contentRect = [window->ns.view frame];
+ const NSRect fbRect = convertRectToBacking(window, contentRect);
- _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);*/
+ _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
+*/
}
-- (void)updateTrackingAreas
-{
- if (trackingArea != nil)
- {
- [self removeTrackingArea:trackingArea];
- [trackingArea release];
- }
+- (void)updateTrackingAreas {
+ if (trackingArea != nil) {
+ [self removeTrackingArea:trackingArea];
+ [trackingArea release];
+ }
- NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
- NSTrackingActiveInKeyWindow |
- NSTrackingCursorUpdate |
- NSTrackingInVisibleRect;
+ NSTrackingAreaOptions options =
+ NSTrackingMouseEnteredAndExited |
+ NSTrackingActiveInKeyWindow |
+ NSTrackingCursorUpdate |
+ NSTrackingInVisibleRect;
- trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
- options:options
- owner:self
- userInfo:nil];
+ trackingArea = [[NSTrackingArea alloc]
+ initWithRect:[self bounds]
+ options:options
+ owner:self
+ userInfo:nil];
- [self addTrackingArea:trackingArea];
- [super updateTrackingAreas];
+ [self addTrackingArea:trackingArea];
+ [super updateTrackingAreas];
}
// 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,
- /* 01 */ KEY_S,
- /* 02 */ KEY_D,
- /* 03 */ KEY_F,
- /* 04 */ KEY_H,
- /* 05 */ KEY_G,
- /* 06 */ KEY_Z,
- /* 07 */ KEY_X,
- /* 08 */ KEY_C,
- /* 09 */ KEY_V,
- /* 0a */ KEY_UNKNOWN,
- /* 0b */ KEY_B,
- /* 0c */ KEY_Q,
- /* 0d */ KEY_W,
- /* 0e */ KEY_E,
- /* 0f */ KEY_R,
- /* 10 */ KEY_Y,
- /* 11 */ KEY_T,
- /* 12 */ KEY_1,
- /* 13 */ KEY_2,
- /* 14 */ KEY_3,
- /* 15 */ KEY_4,
- /* 16 */ KEY_6,
- /* 17 */ KEY_5,
- /* 18 */ KEY_EQUAL,
- /* 19 */ KEY_9,
- /* 1a */ KEY_7,
- /* 1b */ KEY_MINUS,
- /* 1c */ KEY_8,
- /* 1d */ KEY_0,
- /* 1e */ KEY_BRACERIGHT,
- /* 1f */ KEY_O,
- /* 20 */ KEY_U,
- /* 21 */ KEY_BRACELEFT,
- /* 22 */ KEY_I,
- /* 23 */ KEY_P,
- /* 24 */ KEY_RETURN,
- /* 25 */ KEY_L,
- /* 26 */ KEY_J,
- /* 27 */ KEY_APOSTROPHE,
- /* 28 */ KEY_K,
- /* 29 */ KEY_SEMICOLON,
- /* 2a */ KEY_BACKSLASH,
- /* 2b */ KEY_COMMA,
- /* 2c */ KEY_SLASH,
- /* 2d */ KEY_N,
- /* 2e */ KEY_M,
- /* 2f */ KEY_PERIOD,
- /* 30 */ KEY_TAB,
- /* 31 */ KEY_SPACE,
- /* 32 */ KEY_QUOTELEFT,
- /* 33 */ KEY_BACKSPACE,
- /* 34 */ KEY_UNKNOWN,
- /* 35 */ KEY_ESCAPE,
- /* 36 */ KEY_META,
- /* 37 */ KEY_META,
- /* 38 */ KEY_SHIFT,
- /* 39 */ KEY_CAPSLOCK,
- /* 3a */ KEY_ALT,
- /* 3b */ KEY_CONTROL,
- /* 3c */ KEY_SHIFT,
- /* 3d */ KEY_ALT,
- /* 3e */ KEY_CONTROL,
- /* 3f */ KEY_UNKNOWN, /* Function */
- /* 40 */ KEY_UNKNOWN,
- /* 41 */ KEY_KP_PERIOD,
- /* 42 */ KEY_UNKNOWN,
- /* 43 */ KEY_KP_MULTIPLY,
- /* 44 */ KEY_UNKNOWN,
- /* 45 */ KEY_KP_ADD,
- /* 46 */ KEY_UNKNOWN,
- /* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */
- /* 48 */ KEY_UNKNOWN, /* VolumeUp */
- /* 49 */ KEY_UNKNOWN, /* VolumeDown */
- /* 4a */ KEY_UNKNOWN, /* 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?
- /* 52 */ KEY_KP_0,
- /* 53 */ KEY_KP_1,
- /* 54 */ KEY_KP_2,
- /* 55 */ KEY_KP_3,
- /* 56 */ KEY_KP_4,
- /* 57 */ KEY_KP_5,
- /* 58 */ KEY_KP_6,
- /* 59 */ KEY_KP_7,
- /* 5a */ KEY_UNKNOWN,
- /* 5b */ KEY_KP_8,
- /* 5c */ KEY_KP_9,
- /* 5d */ KEY_UNKNOWN,
- /* 5e */ KEY_UNKNOWN,
- /* 5f */ KEY_UNKNOWN,
- /* 60 */ KEY_F5,
- /* 61 */ KEY_F6,
- /* 62 */ KEY_F7,
- /* 63 */ KEY_F3,
- /* 64 */ KEY_F8,
- /* 65 */ KEY_F9,
- /* 66 */ KEY_UNKNOWN,
- /* 67 */ KEY_F11,
- /* 68 */ KEY_UNKNOWN,
- /* 69 */ KEY_F13,
- /* 6a */ KEY_F16,
- /* 6b */ KEY_F14,
- /* 6c */ KEY_UNKNOWN,
- /* 6d */ KEY_F10,
- /* 6e */ KEY_UNKNOWN,
- /* 6f */ KEY_F12,
- /* 70 */ KEY_UNKNOWN,
- /* 71 */ KEY_F15,
- /* 72 */ KEY_INSERT, /* Really Help... */
- /* 73 */ KEY_HOME,
- /* 74 */ KEY_PAGEUP,
- /* 75 */ KEY_DELETE,
- /* 76 */ KEY_F4,
- /* 77 */ KEY_END,
- /* 78 */ KEY_F2,
- /* 79 */ KEY_PAGEDOWN,
- /* 7a */ KEY_F1,
- /* 7b */ KEY_LEFT,
- /* 7c */ KEY_RIGHT,
- /* 7d */ KEY_DOWN,
- /* 7e */ KEY_UP,
- /* 7f */ KEY_UNKNOWN,
- };
-
- if (key >= 128)
- return KEY_UNKNOWN;
-
- return table[key];
-}
-- (void)keyDown:(NSEvent *)event
-{
- InputEvent ev;
- ev.type=InputEvent::KEY;
- ev.key.pressed=true;
- ev.key.mod=translateFlags([event modifierFlags]);
- ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
- ev.key.echo = [event isARepeat];
-
- NSString* characters = [event characters];
- NSUInteger i, length = [characters length];
-
-
- if (length>0 && keycode_has_unicode(ev.key.scancode)) {
-
-
- for (i = 0; i < length; i++) {
- ev.key.unicode=[characters characterAtIndex:i];
+static int translateKey(unsigned int key) {
+ // Keyboard symbol translation table
+ static const unsigned int table[128] = {
+ /* 00 */ KEY_A,
+ /* 01 */ KEY_S,
+ /* 02 */ KEY_D,
+ /* 03 */ KEY_F,
+ /* 04 */ KEY_H,
+ /* 05 */ KEY_G,
+ /* 06 */ KEY_Z,
+ /* 07 */ KEY_X,
+ /* 08 */ KEY_C,
+ /* 09 */ KEY_V,
+ /* 0a */ KEY_UNKNOWN,
+ /* 0b */ KEY_B,
+ /* 0c */ KEY_Q,
+ /* 0d */ KEY_W,
+ /* 0e */ KEY_E,
+ /* 0f */ KEY_R,
+ /* 10 */ KEY_Y,
+ /* 11 */ KEY_T,
+ /* 12 */ KEY_1,
+ /* 13 */ KEY_2,
+ /* 14 */ KEY_3,
+ /* 15 */ KEY_4,
+ /* 16 */ KEY_6,
+ /* 17 */ KEY_5,
+ /* 18 */ KEY_EQUAL,
+ /* 19 */ KEY_9,
+ /* 1a */ KEY_7,
+ /* 1b */ KEY_MINUS,
+ /* 1c */ KEY_8,
+ /* 1d */ KEY_0,
+ /* 1e */ KEY_BRACERIGHT,
+ /* 1f */ KEY_O,
+ /* 20 */ KEY_U,
+ /* 21 */ KEY_BRACELEFT,
+ /* 22 */ KEY_I,
+ /* 23 */ KEY_P,
+ /* 24 */ KEY_RETURN,
+ /* 25 */ KEY_L,
+ /* 26 */ KEY_J,
+ /* 27 */ KEY_APOSTROPHE,
+ /* 28 */ KEY_K,
+ /* 29 */ KEY_SEMICOLON,
+ /* 2a */ KEY_BACKSLASH,
+ /* 2b */ KEY_COMMA,
+ /* 2c */ KEY_SLASH,
+ /* 2d */ KEY_N,
+ /* 2e */ KEY_M,
+ /* 2f */ KEY_PERIOD,
+ /* 30 */ KEY_TAB,
+ /* 31 */ KEY_SPACE,
+ /* 32 */ KEY_QUOTELEFT,
+ /* 33 */ KEY_BACKSPACE,
+ /* 34 */ KEY_UNKNOWN,
+ /* 35 */ KEY_ESCAPE,
+ /* 36 */ KEY_META,
+ /* 37 */ KEY_META,
+ /* 38 */ KEY_SHIFT,
+ /* 39 */ KEY_CAPSLOCK,
+ /* 3a */ KEY_ALT,
+ /* 3b */ KEY_CONTROL,
+ /* 3c */ KEY_SHIFT,
+ /* 3d */ KEY_ALT,
+ /* 3e */ KEY_CONTROL,
+ /* 3f */ KEY_UNKNOWN, /* Function */
+ /* 40 */ KEY_UNKNOWN,
+ /* 41 */ KEY_KP_PERIOD,
+ /* 42 */ KEY_UNKNOWN,
+ /* 43 */ KEY_KP_MULTIPLY,
+ /* 44 */ KEY_UNKNOWN,
+ /* 45 */ KEY_KP_ADD,
+ /* 46 */ KEY_UNKNOWN,
+ /* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */
+ /* 48 */ KEY_UNKNOWN, /* VolumeUp */
+ /* 49 */ KEY_UNKNOWN, /* VolumeDown */
+ /* 4a */ KEY_UNKNOWN, /* 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?
+ /* 52 */ KEY_KP_0,
+ /* 53 */ KEY_KP_1,
+ /* 54 */ KEY_KP_2,
+ /* 55 */ KEY_KP_3,
+ /* 56 */ KEY_KP_4,
+ /* 57 */ KEY_KP_5,
+ /* 58 */ KEY_KP_6,
+ /* 59 */ KEY_KP_7,
+ /* 5a */ KEY_UNKNOWN,
+ /* 5b */ KEY_KP_8,
+ /* 5c */ KEY_KP_9,
+ /* 5d */ KEY_UNKNOWN,
+ /* 5e */ KEY_UNKNOWN,
+ /* 5f */ KEY_UNKNOWN,
+ /* 60 */ KEY_F5,
+ /* 61 */ KEY_F6,
+ /* 62 */ KEY_F7,
+ /* 63 */ KEY_F3,
+ /* 64 */ KEY_F8,
+ /* 65 */ KEY_F9,
+ /* 66 */ KEY_UNKNOWN,
+ /* 67 */ KEY_F11,
+ /* 68 */ KEY_UNKNOWN,
+ /* 69 */ KEY_F13,
+ /* 6a */ KEY_F16,
+ /* 6b */ KEY_F14,
+ /* 6c */ KEY_UNKNOWN,
+ /* 6d */ KEY_F10,
+ /* 6e */ KEY_UNKNOWN,
+ /* 6f */ KEY_F12,
+ /* 70 */ KEY_UNKNOWN,
+ /* 71 */ KEY_F15,
+ /* 72 */ KEY_INSERT, /* Really Help... */
+ /* 73 */ KEY_HOME,
+ /* 74 */ KEY_PAGEUP,
+ /* 75 */ KEY_DELETE,
+ /* 76 */ KEY_F4,
+ /* 77 */ KEY_END,
+ /* 78 */ KEY_F2,
+ /* 79 */ KEY_PAGEDOWN,
+ /* 7a */ KEY_F1,
+ /* 7b */ KEY_LEFT,
+ /* 7c */ KEY_RIGHT,
+ /* 7d */ KEY_DOWN,
+ /* 7e */ KEY_UP,
+ /* 7f */ KEY_UNKNOWN,
+ };
+
+ if (key >= 128)
+ return KEY_UNKNOWN;
+
+ return table[key];
+}
+
+- (void)keyDown:(NSEvent *)event {
+ InputEvent ev;
+ ev.type = InputEvent::KEY;
+ ev.key.pressed = true;
+ ev.key.mod = translateFlags([event modifierFlags]);
+ ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
+ ev.key.echo = [event isARepeat];
+
+ NSString *characters = [event characters];
+ NSUInteger i, length = [characters length];
+
+ if (length > 0 && keycode_has_unicode(ev.key.scancode)) {
+ for (i = 0; i < length; i++) {
+ ev.key.unicode = [characters characterAtIndex:i];
+ OS_OSX::singleton->push_input(ev);
+ ev.key.scancode = 0;
+ }
+ } else {
OS_OSX::singleton->push_input(ev);
- ev.key.scancode=0;
}
-
- } else {
- OS_OSX::singleton->push_input(ev);
- }
}
-- (void)flagsChanged:(NSEvent *)event
-{
+- (void)flagsChanged:(NSEvent *)event {
InputEvent ev;
int key = [event keyCode];
int mod = [event modifierFlags];
- ev.type=InputEvent::KEY;
+ ev.type = InputEvent::KEY;
if (key == 0x36 || key == 0x37) {
if (mod & NSCommandKeyMask) {
- mod&= ~NSCommandKeyMask;
+ mod &= ~NSCommandKeyMask;
ev.key.pressed = true;
} else {
ev.key.pressed = false;
}
} else if (key == 0x38 || key == 0x3c) {
if (mod & NSShiftKeyMask) {
- mod&= ~NSShiftKeyMask;
+ mod &= ~NSShiftKeyMask;
ev.key.pressed = true;
} else {
ev.key.pressed = false;
}
} else if (key == 0x3a || key == 0x3d) {
if (mod & NSAlternateKeyMask) {
- mod&= ~NSAlternateKeyMask;
+ mod &= ~NSAlternateKeyMask;
ev.key.pressed = true;
} else {
ev.key.pressed = false;
}
} else if (key == 0x3b || key == 0x3e) {
if (mod & NSControlKeyMask) {
- mod&= ~NSControlKeyMask;
+ mod &= ~NSControlKeyMask;
ev.key.pressed = true;
} else {
ev.key.pressed = false;
@@ -815,108 +766,102 @@ static int translateKey(unsigned int key)
return;
}
- ev.key.mod=translateFlags(mod);
+ ev.key.mod = translateFlags(mod);
ev.key.scancode = latin_keyboard_keycode_convert(translateKey(key));
OS_OSX::singleton->push_input(ev);
}
-- (void)keyUp:(NSEvent *)event
-{
+- (void)keyUp:(NSEvent *)event {
InputEvent ev;
- ev.type=InputEvent::KEY;
- ev.key.pressed=false;
- ev.key.mod=translateFlags([event modifierFlags]);
+ ev.type = InputEvent::KEY;
+ ev.key.pressed = false;
+ ev.key.mod = translateFlags([event modifierFlags]);
ev.key.scancode = latin_keyboard_keycode_convert(translateKey([event keyCode]));
OS_OSX::singleton->push_input(ev);
-
- /* const int key = translateKey([event keyCode]);
- const int mods = translateFlags([event modifierFlags]);
- _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);*/
+ /*
+ const int key = translateKey([event keyCode]);
+ const int mods = translateFlags([event modifierFlags]);
+ _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
+*/
}
-- (void)scrollWheel:(NSEvent *)event
-{
-
- double deltaX, deltaY;
+- (void)scrollWheel:(NSEvent *)event {
+ double deltaX, deltaY;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
- {
- deltaX = [event scrollingDeltaX];
- deltaY = [event scrollingDeltaY];
-
- if ([event hasPreciseScrollingDeltas])
- {
- deltaX *= 0.1;
- deltaY *= 0.1;
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
+ deltaX = [event scrollingDeltaX];
+ deltaY = [event scrollingDeltaY];
+
+ if ([event hasPreciseScrollingDeltas]) {
+ deltaX *= 0.1;
+ deltaY *= 0.1;
+ }
+ } else {
+ deltaX = [event deltaX];
+ deltaY = [event deltaY];
}
- }
- else
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
- {
+#else
deltaX = [event deltaX];
deltaY = [event deltaY];
- }
-
+#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
if (fabs(deltaY)) {
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=deltaY >0 ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN;
- ev.mouse_button.pressed=true;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = deltaY > 0 ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN;
+ ev.mouse_button.pressed = true;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
OS_OSX::singleton->push_input(ev);
- ev.mouse_button.pressed=false;
+ ev.mouse_button.pressed = false;
OS_OSX::singleton->push_input(ev);
}
if (fabs(deltaX)) {
InputEvent ev;
- ev.type=InputEvent::MOUSE_BUTTON;
- ev.mouse_button.button_index=deltaX < 0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT;
- ev.mouse_button.pressed=true;
- ev.mouse_button.x=mouse_x;
- ev.mouse_button.y=mouse_y;
- ev.mouse_button.global_x=mouse_x;
- ev.mouse_button.global_y=mouse_y;
- ev.mouse_button.button_mask=button_mask;
+ ev.type = InputEvent::MOUSE_BUTTON;
+ ev.mouse_button.button_index = deltaX < 0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT;
+ ev.mouse_button.pressed = true;
+ ev.mouse_button.x = mouse_x;
+ ev.mouse_button.y = mouse_y;
+ ev.mouse_button.global_x = mouse_x;
+ ev.mouse_button.global_y = mouse_y;
+ ev.mouse_button.button_mask = button_mask;
OS_OSX::singleton->push_input(ev);
- ev.mouse_button.pressed=false;
+ ev.mouse_button.pressed = false;
OS_OSX::singleton->push_input(ev);
}
}
@end
-@interface GodotWindow : NSWindow {}
+@interface GodotWindow : NSWindow {
+}
@end
@implementation GodotWindow
-
-- (BOOL)canBecomeKeyWindow
-{
- // Required for NSBorderlessWindowMask windows
- return YES;
+- (BOOL)canBecomeKeyWindow {
+ // Required for NSBorderlessWindowMask windows
+ return YES;
}
@end
-
int OS_OSX::get_video_driver_count() const {
-
return 1;
}
-const char * OS_OSX::get_video_driver_name(int p_driver) const {
+
+const char *OS_OSX::get_video_driver_name(int p_driver) const {
return "GLES2";
}
@@ -924,14 +869,13 @@ const char * OS_OSX::get_video_driver_name(int p_driver) const {
OS::VideoMode OS_OSX::get_default_video_mode() const {
VideoMode vm;
- vm.width=1024;
- vm.height=600;
- vm.fullscreen=false;
- vm.resizable=true;
+ vm.width = 1024;
+ vm.height = 600;
+ vm.fullscreen = false;
+ vm.resizable = true;
return vm;
}
-
void OS_OSX::initialize_core() {
OS_Unix::initialize_core();
@@ -941,7 +885,6 @@ void OS_OSX::initialize_core() {
DirAccess::make_default<DirAccessOSX>(DirAccess::ACCESS_FILESYSTEM);
SemaphoreOSX::make_default();
-
}
static bool keyboard_layout_dirty = true;
@@ -949,7 +892,7 @@ static void keyboardLayoutChanged(CFNotificationCenterRef center, void *observer
keyboard_layout_dirty = true;
}
-void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) {
+void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
/*** OSX INITIALIZATION ***/
/*** OSX INITIALIZATION ***/
@@ -959,43 +902,42 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
// Register to be notified on keyboard layout changes
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
- NULL, keyboardLayoutChanged,
- kTISNotifySelectedKeyboardInputSourceChanged, NULL,
- CFNotificationSuspensionBehaviorDeliverImmediately);
+ NULL, keyboardLayoutChanged,
+ kTISNotifySelectedKeyboardInputSourceChanged, NULL,
+ CFNotificationSuspensionBehaviorDeliverImmediately);
if (is_hidpi_allowed() && [[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) {
- for (NSScreen *screen in [NSScreen screens]) {
- float s = [screen backingScaleFactor];
- if (s > display_scale) {
- display_scale=s;
- }
- }
+ for (NSScreen *screen in [NSScreen screens]) {
+ float s = [screen backingScaleFactor];
+ if (s > display_scale) {
+ display_scale = s;
+ }
+ }
}
window_delegate = [[GodotWindowDelegate alloc] init];
- // Don't use accumulation buffer support; it's not accelerated
- // Aux buffers probably aren't accelerated either
-
- unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable?NSResizableWindowMask:0);
+ // Don't use accumulation buffer support; it's not accelerated
+ // Aux buffers probably aren't accelerated either
+ unsigned int styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | (p_desired.resizable ? NSResizableWindowMask : 0);
window_object = [[GodotWindow alloc]
- initWithContentRect:NSMakeRect(0, 0, p_desired.width/display_scale, p_desired.height/display_scale)
- styleMask:styleMask
- backing:NSBackingStoreBuffered
- defer:NO];
+ initWithContentRect:NSMakeRect(0, 0, p_desired.width / display_scale, p_desired.height / display_scale)
+ styleMask:styleMask
+ backing:NSBackingStoreBuffered
+ defer:NO];
- ERR_FAIL_COND( window_object==nil );
+ ERR_FAIL_COND(window_object == nil);
window_view = [[GodotContentView alloc] init];
window_size.width = p_desired.width;
window_size.height = p_desired.height;
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale>1) {
- [window_view setWantsBestResolutionOpenGLSurface:YES];
- //if (current_videomode.resizable)
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6 && display_scale > 1) {
+ [window_view setWantsBestResolutionOpenGLSurface:YES];
+ //if (current_videomode.resizable)
[window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
}
@@ -1013,11 +955,15 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
// OS X needs non-zero color size, so set resonable values
int colorBits = 32;
- // Fail if a robustness strategy was requested
+// Fail if a robustness strategy was requested
-
-#define ADD_ATTR(x) { attributes[attributeCount++] = x; }
-#define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); }
+#define ADD_ATTR(x) \
+ { attributes[attributeCount++] = x; }
+#define ADD_ATTR2(x, y) \
+ { \
+ ADD_ATTR(x); \
+ ADD_ATTR(y); \
+ }
// Arbitrary array size here
NSOpenGLPixelFormatAttribute attributes[40];
@@ -1030,21 +976,26 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
ADD_ATTR2(NSOpenGLPFAColorSize, colorBits);
- /* if (fbconfig->alphaBits > 0)
- ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);*/
+ /*
+ if (fbconfig->alphaBits > 0)
+ ADD_ATTR2(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
+*/
ADD_ATTR2(NSOpenGLPFADepthSize, 24);
ADD_ATTR2(NSOpenGLPFAStencilSize, 8);
- /*if (fbconfig->stereo)
- ADD_ATTR(NSOpenGLPFAStereo);*/
+ /*
+ if (fbconfig->stereo)
+ ADD_ATTR(NSOpenGLPFAStereo);
+*/
- /* if (fbconfig->samples > 0)
- {
- ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
- ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
- }*/
+ /*
+ if (fbconfig->samples > 0) {
+ ADD_ATTR2(NSOpenGLPFASampleBuffers, 1);
+ ADD_ATTR2(NSOpenGLPFASamples, fbconfig->samples);
+ }
+*/
// NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
// frambuffer, so there's no need (and no way) to request it
@@ -1055,14 +1006,11 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
#undef ADD_ATTR2
pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
- ERR_FAIL_COND( pixelFormat == nil);
-
+ ERR_FAIL_COND(pixelFormat == nil);
- context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
- shareContext:nil];
-
- ERR_FAIL_COND(context==nil);
+ context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+ ERR_FAIL_COND(context == nil);
[context setView:window_view];
@@ -1079,79 +1027,77 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
/*** END OSX INITIALIZATION ***/
/*** END OSX INITIALIZATION ***/
- bool use_gl2=p_video_driver!=1;
-
-
+ bool use_gl2 = p_video_driver != 1;
AudioDriverManager::add_driver(&audio_driver_osx);
- // only opengl support here...
+ // only opengl support here...
RasterizerGLES3::register_config();
RasterizerGLES3::make_current();
//rasterizer = instance_RasterizerGLES2();
//visual_server = memnew( VisualServerRaster(rasterizer) );
- visual_server = memnew( VisualServerRaster );
+ visual_server = memnew(VisualServerRaster);
// FIXME: Reimplement threaded rendering? Or remove?
/*
if (get_render_thread_mode()!=RENDER_THREAD_UNSAFE) {
visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD));
}
- */
+*/
visual_server->init();
visual_server->cursor_set_visible(false, 0);
AudioDriverManager::get_driver(p_audio_driver)->set_singleton();
- if (AudioDriverManager::get_driver(p_audio_driver)->init()!=OK) {
+ if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) {
ERR_PRINT("Initializing audio failed.");
}
//
- physics_server = memnew( PhysicsServerSW );
+ physics_server = memnew(PhysicsServerSW);
physics_server->init();
//physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
- input = memnew( InputDefault );
- joypad_osx = memnew( JoypadOSX );
+ input = memnew(InputDefault);
+ joypad_osx = memnew(JoypadOSX);
- power_manager = memnew( power_osx );
+ power_manager = memnew(power_osx);
_ensure_data_dir();
NSArray *screenArray = [NSScreen screens];
printf("nscreen count %i\n", (int)[screenArray count]);
- for (int i=0; i<[screenArray count]; i++) {
+ for (int i = 0; i < [screenArray count]; i++) {
float displayScale = 1.0;
- if (display_scale>1.0 && [[screenArray objectAtIndex: i] respondsToSelector:@selector(backingScaleFactor)]) {
- displayScale = [[screenArray objectAtIndex: i] backingScaleFactor];
+ if (display_scale > 1.0 && [[screenArray objectAtIndex:i] respondsToSelector:@selector(backingScaleFactor)]) {
+ displayScale = [[screenArray objectAtIndex:i] backingScaleFactor];
}
- NSRect nsrect = [[screenArray objectAtIndex: i] visibleFrame];
+ NSRect nsrect = [[screenArray objectAtIndex:i] visibleFrame];
Rect2 rect = Rect2(nsrect.origin.x, nsrect.origin.y, nsrect.size.width, nsrect.size.height);
- rect.pos*=displayScale;
- rect.size*=displayScale;
+ rect.pos *= displayScale;
+ rect.size *= displayScale;
screens.push_back(rect);
- NSDictionary *description = [[screenArray objectAtIndex: i] deviceDescription];
+ NSDictionary *description = [[screenArray objectAtIndex:i] deviceDescription];
NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize displayPhysicalSize = CGDisplayScreenSize(
- [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
+ [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]);
//printf("width: %i pwidth %i rect width %i\n",int(displayPixelSize.width*displayScale),int(displayPhysicalSize.width*displayScale),int(nsrect.size.width));
- int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width)*displayScale;
+ int dpi = (displayPixelSize.width * 25.4f / displayPhysicalSize.width) * displayScale;
screen_dpi.push_back(dpi);
-
};
restore_rect = Rect2(get_window_position(), get_window_size());
}
+
void OS_OSX::finalize() {
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
@@ -1171,15 +1117,12 @@ void OS_OSX::finalize() {
memdelete(physics_2d_server);
screens.clear();
-
-
}
-void OS_OSX::set_main_loop( MainLoop * p_main_loop ) {
+void OS_OSX::set_main_loop(MainLoop *p_main_loop) {
- main_loop=p_main_loop;
+ main_loop = p_main_loop;
input->set_main_loop(p_main_loop);
-
}
void OS_OSX::delete_main_loop() {
@@ -1187,16 +1130,15 @@ void OS_OSX::delete_main_loop() {
if (!main_loop)
return;
memdelete(main_loop);
- main_loop=NULL;
+ main_loop = NULL;
}
-
String OS_OSX::get_name() {
return "OSX";
}
-void OS_OSX::alert(const String& p_alert, const String& p_title) {
+void OS_OSX::alert(const String &p_alert, const String &p_title) {
// Set OS X-compliant variables
NSAlert *window = [[NSAlert alloc] init];
NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
@@ -1214,10 +1156,10 @@ void OS_OSX::alert(const String& p_alert, const String& p_title) {
void OS_OSX::set_cursor_shape(CursorShape p_shape) {
- if (cursor_shape==p_shape)
+ if (cursor_shape == p_shape)
return;
- switch(p_shape) {
+ switch (p_shape) {
case CURSOR_ARROW: [[NSCursor arrowCursor] set]; break;
case CURSOR_IBEAM: [[NSCursor IBeamCursor] set]; break;
case CURSOR_POINTING_HAND: [[NSCursor pointingHandCursor] set]; break;
@@ -1238,101 +1180,100 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
default: {};
}
- cursor_shape=p_shape;
+ cursor_shape = p_shape;
}
void OS_OSX::set_mouse_show(bool p_show) {
-
}
-void OS_OSX::set_mouse_grab(bool p_grab) {
+void OS_OSX::set_mouse_grab(bool p_grab) {
}
+
bool OS_OSX::is_mouse_grab_enabled() const {
return mouse_grab;
}
-void OS_OSX::warp_mouse_pos(const Point2& p_to) {
+void OS_OSX::warp_mouse_pos(const Point2 &p_to) {
- //copied from windows impl with osx native calls
- if (mouse_mode == MOUSE_MODE_CAPTURED){
- mouse_x = p_to.x;
- mouse_y = p_to.y;
- }
- else{ //set OS position
+ //copied from windows impl with osx native calls
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
+ mouse_x = p_to.x;
+ mouse_y = p_to.y;
+ } else { //set OS position
- /* this code has not been tested, please be a kind soul and fix it if it fails! */
+ /* this code has not been tested, please be a kind soul and fix it if it fails! */
- //local point in window coords
- NSPoint localPoint = { p_to.x, p_to.y };
+ //local point in window coords
+ NSPoint localPoint = { p_to.x, p_to.y };
- NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil];
- NSRect pointInWindowRect;
- pointInWindowRect.origin = pointInWindow;
- NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
+ NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil];
+ NSRect pointInWindowRect;
+ pointInWindowRect.origin = pointInWindow;
+ NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin;
- //point in scren coords
- CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y};
+ //point in scren coords
+ CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y };
- //do the warping
- CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
- CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
- CGAssociateMouseAndMouseCursorPosition(false);
- CGWarpMouseCursorPosition(lMouseWarpPos);
- CGAssociateMouseAndMouseCursorPosition(true);
- }
+ //do the warping
+ CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
+ CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ CGWarpMouseCursorPosition(lMouseWarpPos);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
}
-Point2 OS_OSX::get_mouse_pos() const {
+Point2 OS_OSX::get_mouse_position() const {
- return Vector2(mouse_x,mouse_y);
+ return Vector2(mouse_x, mouse_y);
}
+
int OS_OSX::get_mouse_button_state() const {
return button_mask;
}
-void OS_OSX::set_window_title(const String& p_title) {
- [window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
+void OS_OSX::set_window_title(const String &p_title) {
+ [window_object setTitle:[NSString stringWithUTF8String:p_title.utf8().get_data()]];
}
-void OS_OSX::set_icon(const Image& p_icon) {
+void OS_OSX::set_icon(const Image &p_icon) {
- Image img=p_icon;
+ Image img = p_icon;
img.convert(Image::FORMAT_RGBA8);
- NSBitmapImageRep *imgrep= [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
- pixelsWide: p_icon.get_width()
- pixelsHigh: p_icon.get_height()
- bitsPerSample: 8
- samplesPerPixel: 4
- hasAlpha: YES
- isPlanar: NO
- colorSpaceName: NSDeviceRGBColorSpace
- bytesPerRow: p_icon.get_width()*4
- bitsPerPixel: 32] autorelease];
- ERR_FAIL_COND(imgrep==nil);
+ NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes:NULL
+ pixelsWide:p_icon.get_width()
+ pixelsHigh:p_icon.get_height()
+ bitsPerSample:8
+ samplesPerPixel:4
+ hasAlpha:YES
+ isPlanar:NO
+ colorSpaceName:NSDeviceRGBColorSpace
+ bytesPerRow:p_icon.get_width() * 4
+ bitsPerPixel:32] autorelease];
+ ERR_FAIL_COND(imgrep == nil);
uint8_t *pixels = [imgrep bitmapData];
- int len = img.get_width()*img.get_height();
+ int len = img.get_width() * img.get_height();
PoolVector<uint8_t> data = img.get_data();
PoolVector<uint8_t>::Read r = data.read();
/* Premultiply the alpha channel */
- for (int i = 0; i<len ; i++) {
- uint8_t alpha = r[i*4+3];
- pixels[i*4+0] = (uint8_t)(((uint16_t)r[i*4+0] * alpha) / 255);
- pixels[i*4+1] = (uint8_t)(((uint16_t)r[i*4+1] * alpha) / 255);
- pixels[i*4+2] = (uint8_t)(((uint16_t)r[i*4+2] * alpha) / 255);
- pixels[i*4+3] = alpha;
-
+ for (int i = 0; i < len; i++) {
+ uint8_t alpha = r[i * 4 + 3];
+ pixels[i * 4 + 0] = (uint8_t)(((uint16_t)r[i * 4 + 0] * alpha) / 255);
+ pixels[i * 4 + 1] = (uint8_t)(((uint16_t)r[i * 4 + 1] * alpha) / 255);
+ pixels[i * 4 + 2] = (uint8_t)(((uint16_t)r[i * 4 + 2] * alpha) / 255);
+ pixels[i * 4 + 3] = alpha;
}
- NSImage *nsimg = [[[NSImage alloc] initWithSize: NSMakeSize(img.get_width(),img.get_height())] autorelease];
+ NSImage *nsimg = [[[NSImage alloc] initWithSize:NSMakeSize(img.get_width(), img.get_height())] autorelease];
ERR_FAIL_COND(nsimg == nil);
- [nsimg addRepresentation: imgrep];
+ [nsimg addRepresentation:imgrep];
[NSApp setApplicationIconImage:nsimg];
-
}
MainLoop *OS_OSX::get_main_loop() const {
@@ -1345,27 +1286,26 @@ bool OS_OSX::can_draw() const {
return true;
}
-void OS_OSX::set_clipboard(const String& p_text) {
+void OS_OSX::set_clipboard(const String &p_text) {
- NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];
+ NSArray *types = [NSArray arrayWithObjects:NSStringPboardType, nil];
- NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes:types owner:nil];
[pasteboard setString:[NSString stringWithUTF8String:p_text.utf8().get_data()]
- forType:NSStringPboardType];
+ forType:NSStringPboardType];
}
+
String OS_OSX::get_clipboard() const {
- NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
- if (![[pasteboard types] containsObject:NSStringPboardType])
- {
+ if (![[pasteboard types] containsObject:NSStringPboardType]) {
return "";
}
- NSString* object = [pasteboard stringForType:NSStringPboardType];
- if (!object)
- {
+ NSString *object = [pasteboard stringForType:NSStringPboardType];
+ if (!object) {
return "";
}
@@ -1380,12 +1320,11 @@ String OS_OSX::get_clipboard() const {
void OS_OSX::release_rendering_thread() {
[NSOpenGLContext clearCurrentContext];
-
}
+
void OS_OSX::make_rendering_thread() {
[context makeCurrentContext];
-
}
Error OS_OSX::shell_open(String p_uri) {
@@ -1395,14 +1334,13 @@ Error OS_OSX::shell_open(String p_uri) {
}
String OS_OSX::get_locale() const {
- NSString* preferredLang = [[NSLocale preferredLanguages] objectAtIndex:0];
+ NSString *preferredLang = [[NSLocale preferredLanguages] objectAtIndex:0];
return [preferredLang UTF8String];
}
void OS_OSX::swap_buffers() {
[context flushBuffer];
-
}
void OS_OSX::wm_minimized(bool p_minimized) {
@@ -1410,23 +1348,21 @@ void OS_OSX::wm_minimized(bool p_minimized) {
minimized = p_minimized;
};
-void OS_OSX::set_video_mode(const VideoMode& p_video_mode,int p_screen) {
-
+void OS_OSX::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
}
OS::VideoMode OS_OSX::get_video_mode(int p_screen) const {
VideoMode vm;
- vm.width=window_size.width;
- vm.height=window_size.height;
+ vm.width = window_size.width;
+ vm.height = window_size.height;
return vm;
}
-void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const {
+void OS_OSX::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const {
}
-
int OS_OSX::get_screen_count() const {
return screens.size();
@@ -1463,35 +1399,33 @@ Size2 OS_OSX::get_screen_size(int p_screen) const {
Point2 OS_OSX::get_window_position() const {
Size2 wp([window_object frame].origin.x, [window_object frame].origin.y);
- wp*=display_scale;
+ wp *= display_scale;
return wp;
};
+void OS_OSX::set_window_position(const Point2 &p_position) {
-void OS_OSX::set_window_position(const Point2& p_position) {
-
- Point2 size=p_position;
- size/=display_scale;
+ Point2 size = p_position;
+ size /= display_scale;
[window_object setFrame:NSMakeRect(size.x, size.y, [window_object frame].size.width, [window_object frame].size.height) display:YES];
};
Size2 OS_OSX::get_window_size() const {
return window_size;
-
};
void OS_OSX::set_window_size(const Size2 p_size) {
- Size2 size=p_size;
+ Size2 size = p_size;
// NSRect used by setFrame includes the title bar, so add it to our size.y
CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
if (menuBarHeight != 0.f) {
- size.y+= menuBarHeight;
+ size.y += menuBarHeight;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101104
} else {
- size.y+= [[NSStatusBar systemStatusBar] thickness];
+ size.y += [[NSStatusBar systemStatusBar] thickness];
#endif
}
NSRect frame = [window_object frame];
@@ -1513,7 +1447,7 @@ void OS_OSX::set_window_fullscreen(bool p_enabled) {
bool OS_OSX::is_window_fullscreen() const {
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
- if ( [window_object respondsToSelector:@selector(isZoomed)] )
+ if ([window_object respondsToSelector:@selector(isZoomed)])
return [window_object isZoomed];
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
@@ -1523,9 +1457,9 @@ bool OS_OSX::is_window_fullscreen() const {
void OS_OSX::set_window_resizable(bool p_enabled) {
if (p_enabled)
- [window_object setStyleMask:[window_object styleMask] | NSResizableWindowMask ];
+ [window_object setStyleMask:[window_object styleMask] | NSResizableWindowMask];
else
- [window_object setStyleMask:[window_object styleMask] & ~NSResizableWindowMask ];
+ [window_object setStyleMask:[window_object styleMask] & ~NSResizableWindowMask];
};
bool OS_OSX::is_window_resizable() const {
@@ -1543,13 +1477,12 @@ void OS_OSX::set_window_minimized(bool p_enabled) {
bool OS_OSX::is_window_minimized() const {
- if ( [window_object respondsToSelector:@selector(isMiniaturized)])
+ if ([window_object respondsToSelector:@selector(isMiniaturized)])
return [window_object isMiniaturized];
return minimized;
};
-
void OS_OSX::set_window_maximized(bool p_enabled) {
if (p_enabled) {
@@ -1568,7 +1501,6 @@ bool OS_OSX::is_window_maximized() const {
return maximized;
};
-
void OS_OSX::move_window_to_foreground() {
[window_object orderFrontRegardless];
@@ -1586,8 +1518,8 @@ String OS_OSX::get_executable_path() const {
char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
pid = getpid();
- ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf));
- if ( ret <= 0 ) {
+ ret = proc_pidpath(pid, pathbuf, sizeof(pathbuf));
+ if (ret <= 0) {
return OS::get_executable_path();
} else {
String path;
@@ -1595,7 +1527,6 @@ String OS_OSX::get_executable_path() const {
return path;
}
-
}
// Returns string representation of keys, if they are printable.
@@ -1615,22 +1546,22 @@ static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
OSStatus err;
CFMutableStringRef output = CFStringCreateMutable(NULL, 0);
- for (int i=0; i<length; ++i) {
+ for (int i = 0; i < length; ++i) {
UInt32 keysDown = 0;
UniChar chars[4];
UniCharCount realLength;
err = UCKeyTranslate(keyboardLayout,
- keyCode[i],
- kUCKeyActionDisplay,
- 0,
- LMGetKbdType(),
- kUCKeyTranslateNoDeadKeysBit,
- &keysDown,
- sizeof(chars) / sizeof(chars[0]),
- &realLength,
- chars);
+ keyCode[i],
+ kUCKeyActionDisplay,
+ 0,
+ LMGetKbdType(),
+ kUCKeyTranslateNoDeadKeysBit,
+ &keysDown,
+ sizeof(chars) / sizeof(chars[0]),
+ &realLength,
+ chars);
if (err != noErr) {
CFRelease(output);
@@ -1644,6 +1575,7 @@ static NSString *createStringForKeys(const CGKeyCode *keyCode, int length) {
return (NSString *)output;
}
+
OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
static LatinKeyboardVariant layout = LATIN_KEYBOARD_QWERTY;
@@ -1652,7 +1584,7 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
layout = LATIN_KEYBOARD_QWERTY;
- CGKeyCode keys[] = {kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y};
+ CGKeyCode keys[] = { kVK_ANSI_Q, kVK_ANSI_W, kVK_ANSI_E, kVK_ANSI_R, kVK_ANSI_T, kVK_ANSI_Y };
NSString *test = createStringForKeys(keys, 6);
if ([test isEqualToString:@"qwertz"]) {
@@ -1679,10 +1611,12 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
void OS_OSX::process_events() {
while (true) {
- NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantPast]
- inMode:NSDefaultRunLoopMode
- dequeue:YES];
+ NSEvent *event = [NSApp
+ nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+
if (event == nil)
break;
@@ -1693,12 +1627,9 @@ void OS_OSX::process_events() {
autoreleasePool = [[NSAutoreleasePool alloc] init];
}
+void OS_OSX::push_input(const InputEvent &p_event) {
-
-void OS_OSX::push_input(const InputEvent& p_event) {
-
- InputEvent ev=p_event;
- ev.ID=last_id++;
+ InputEvent ev = p_event;
//print_line("EV: "+String(ev));
input->parse_input_event(ev);
}
@@ -1725,8 +1656,8 @@ void OS_OSX::run() {
while (!force_quit) {
process_events(); // get rid of pending events
- last_id = joypad_osx->process_joypads(last_id);
- if (Main::iteration()==true)
+ joypad_osx->process_joypads();
+ if (Main::iteration() == true)
break;
};
@@ -1735,32 +1666,31 @@ void OS_OSX::run() {
void OS_OSX::set_mouse_mode(MouseMode p_mode) {
- if (p_mode==mouse_mode)
- return;
+ if (p_mode == mouse_mode)
+ return;
- if (p_mode==MOUSE_MODE_CAPTURED) {
- // Apple Docs state that the display parameter is not used.
- // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
- // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
- CGDisplayHideCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(false);
- } else if (p_mode==MOUSE_MODE_HIDDEN) {
- CGDisplayHideCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(true);
- } else {
- CGDisplayShowCursor(kCGDirectMainDisplay);
- CGAssociateMouseAndMouseCursorPosition(true);
- }
+ if (p_mode == MOUSE_MODE_CAPTURED) {
+ // Apple Docs state that the display parameter is not used.
+ // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
+ // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ } else if (p_mode == MOUSE_MODE_HIDDEN) {
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ } else {
+ CGDisplayShowCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
- mouse_mode=p_mode;
+ mouse_mode = p_mode;
}
OS::MouseMode OS_OSX::get_mouse_mode() const {
- return mouse_mode;
+ return mouse_mode;
}
-
String OS_OSX::get_joy_guid(int p_device) const {
return input->get_joy_guid_remapped(p_device);
}
@@ -1777,13 +1707,13 @@ int OS_OSX::get_power_percent_left() {
return power_manager->get_power_percent_left();
}
-OS_OSX* OS_OSX::singleton=NULL;
+OS_OSX *OS_OSX::singleton = NULL;
OS_OSX::OS_OSX() {
-
- mouse_mode=OS::MOUSE_MODE_VISIBLE;
- main_loop=NULL;
- singleton=this;
+
+ mouse_mode = OS::MOUSE_MODE_VISIBLE;
+ main_loop = NULL;
+ singleton = this;
autoreleasePool = [[NSAutoreleasePool alloc] init];
eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
@@ -1791,13 +1721,12 @@ OS_OSX::OS_OSX() {
CGEventSourceSetLocalEventsSuppressionInterval(eventSource, 0.0);
-
- /*if (pthread_key_create(&_Godot.nsgl.current, NULL) != 0)
- {
- _GodotInputError(Godot_PLATFORM_ERROR,
- "NSGL: Failed to create context TLS");
- return GL_FALSE;
- }*/
+ /*
+ if (pthread_key_create(&_Godot.nsgl.current, NULL) != 0) {
+ _GodotInputError(Godot_PLATFORM_ERROR, "NSGL: Failed to create context TLS");
+ return GL_FALSE;
+ }
+*/
framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
ERR_FAIL_COND(!framework);
@@ -1808,12 +1737,12 @@ OS_OSX::OS_OSX() {
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
- #if 0
+#if 0
// Menu bar setup must go between sharedApplication above and
// finishLaunching below, in order to properly emulate the behavior
// of NSApplicationMain
createMenuBar();
- #endif
+#endif
[NSApp finishLaunching];
@@ -1821,15 +1750,13 @@ OS_OSX::OS_OSX() {
ERR_FAIL_COND(!delegate);
[NSApp setDelegate:delegate];
-
- last_id=1;
- cursor_shape=CURSOR_ARROW;
+ cursor_shape = CURSOR_ARROW;
current_screen = 0;
maximized = false;
minimized = false;
- window_size=Vector2(1024,600);
+ window_size = Vector2(1024, 600);
zoomed = false;
- display_scale=1.0;
+ display_scale = 1.0;
}
diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h
index 834d0141a3..487077e651 100644
--- a/platform/osx/platform_config.h
+++ b/platform/osx/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/power_osx.cpp b/platform/osx/power_osx.cpp
index de9bcaf6fc..0057fe8acc 100644
--- a/platform/osx/power_osx.cpp
+++ b/platform/osx/power_osx.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/power_osx.h b/platform/osx/power_osx.h
index c638dc675a..6d984ec466 100644
--- a/platform/osx/power_osx.h
+++ b/platform/osx/power_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp
index 069e3a5153..b1eeccfec5 100644
--- a/platform/osx/sem_osx.cpp
+++ b/platform/osx/sem_osx.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/osx/sem_osx.h b/platform/osx/sem_osx.h
index a30f3fcc98..3025318c4b 100644
--- a/platform/osx/sem_osx.h
+++ b/platform/osx/sem_osx.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/server/detect.py b/platform/server/detect.py
index 8bc85f342d..32f3c55135 100644
--- a/platform/server/detect.py
+++ b/platform/server/detect.py
@@ -64,7 +64,7 @@ def configure(env):
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
# Shared libraries, when requested
diff --git a/platform/server/godot_server.cpp b/platform/server/godot_server.cpp
index d06ade4a57..ed0100ac93 100644
--- a/platform/server/godot_server.cpp
+++ b/platform/server/godot_server.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp
index f44d976bd6..89af785d29 100644
--- a/platform/server/os_server.cpp
+++ b/platform/server/os_server.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -142,7 +143,7 @@ int OS_Server::get_mouse_button_state() const {
return 0;
}
-Point2 OS_Server::get_mouse_pos() const {
+Point2 OS_Server::get_mouse_position() const {
return Point2();
}
diff --git a/platform/server/os_server.h b/platform/server/os_server.h
index 7484d70e06..7c29b1e232 100644
--- a/platform/server/os_server.h
+++ b/platform/server/os_server.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -87,7 +88,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/server/platform_config.h b/platform/server/platform_config.h
index cdef185ff0..48bcadcc29 100644
--- a/platform/server/platform_config.h
+++ b/platform/server/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp
index 35b25b1de5..2946aa1eae 100644
--- a/platform/uwp/app.cpp
+++ b/platform/uwp/app.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/app.h b/platform/uwp/app.h
index fd6fc950a7..647ef0261b 100644
--- a/platform/uwp/app.h
+++ b/platform/uwp/app.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index a9b26056fc..4a164e5ba1 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -1032,7 +1033,7 @@ void AppxPackager::finish() {
Error err = read_cert_file(certificate_path, certificate_pass, &cert_file);
if (err != OK) {
- EditorNode::add_io_error(TTR("Couldn't read the certficate file. Are the path and password both correct?"));
+ EditorNode::add_io_error(TTR("Couldn't read the certificate file. Are the path and password both correct?"));
package->close();
memdelete(package);
package = NULL;
diff --git a/platform/uwp/export/export.h b/platform/uwp/export/export.h
index 2d6e02bb10..81bd848241 100644
--- a/platform/uwp/export/export.h
+++ b/platform/uwp/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp
index 6c9efc26b4..d79ce75db5 100644
--- a/platform/uwp/gl_context_egl.cpp
+++ b/platform/uwp/gl_context_egl.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/gl_context_egl.h b/platform/uwp/gl_context_egl.h
index c397c1206b..908b8dceec 100644
--- a/platform/uwp/gl_context_egl.h
+++ b/platform/uwp/gl_context_egl.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index dd57ed94ae..34e36f7b66 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -40,7 +41,7 @@ void JoypadUWP::register_events() {
ref new EventHandler<Gamepad ^>(this, &JoypadUWP::OnGamepadRemoved);
}
-uint32_t JoypadUWP::process_controllers(uint32_t p_last_id) {
+void JoypadUWP::process_controllers() {
for (int i = 0; i < MAX_CONTROLLERS; i++) {
@@ -55,23 +56,21 @@ uint32_t JoypadUWP::process_controllers(uint32_t p_last_id) {
int button_mask = (int)GamepadButtons::Menu;
for (int j = 0; j < 14; j++) {
- p_last_id = input->joy_button(p_last_id, controllers[i].id, j, (int)reading.Buttons & button_mask);
+ input->joy_button(controllers[i].id, j, (int)reading.Buttons & button_mask);
button_mask *= 2;
}
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
- p_last_id = input->joy_axis(p_last_id, controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
+ input->joy_axis(controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX));
+ input->joy_axis(controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true));
+ input->joy_axis(controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX));
+ input->joy_axis(controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true));
+ input->joy_axis(controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true));
+ input->joy_axis(controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true));
break;
}
}
}
-
- return p_last_id;
}
JoypadUWP::JoypadUWP() {
diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h
index e5a961e70e..7337ffb3ce 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -37,7 +38,7 @@ ref class JoypadUWP sealed {
/* clang-format off */
internal:
void register_events();
- uint32_t process_controllers(uint32_t p_last_id);
+ void process_controllers();
/* clang-format on */
JoypadUWP();
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 19ed2b57a3..8b7e821ab3 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -344,15 +345,12 @@ String OSUWP::get_clipboard() const {
void OSUWP::input_event(InputEvent &p_event) {
- p_event.ID = ++last_id;
-
input->parse_input_event(p_event);
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index > 3) {
//send release for mouse wheel
p_event.mouse_button.pressed = false;
- p_event.ID = ++last_id;
input->parse_input_event(p_event);
}
};
@@ -534,7 +532,7 @@ OSUWP::MouseMode OSUWP::get_mouse_mode() const {
return mouse_mode;
}
-Point2 OSUWP::get_mouse_pos() const {
+Point2 OSUWP::get_mouse_position() const {
return Point2(old_x, old_y);
}
@@ -680,7 +678,7 @@ uint64_t OSUWP::get_ticks_usec() const {
void OSUWP::process_events() {
- last_id = joypad->process_controllers(last_id);
+ joypad->process_controllers();
process_key_events();
}
@@ -907,7 +905,6 @@ OSUWP::OSUWP() {
pressrc = 0;
old_invalid = true;
- last_id = 0;
mouse_mode = MOUSE_MODE_VISIBLE;
#ifdef STDOUT_FILE
stdo = fopen("stdout.txt", "wb");
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index ebbb8af39c..88a1dddae3 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -92,7 +93,6 @@ private:
bool outside;
int old_x, old_y;
Point2i center;
- unsigned int last_id;
VisualServer *visual_server;
Rasterizer *rasterizer;
PhysicsServer *physics_server;
@@ -190,7 +190,7 @@ public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/uwp/platform_config.h b/platform/uwp/platform_config.h
index 7939e1c9ee..77d2c9cadb 100644
--- a/platform/uwp/platform_config.h
+++ b/platform/uwp/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp
index ff079be375..436941707c 100644
--- a/platform/uwp/thread_uwp.cpp
+++ b/platform/uwp/thread_uwp.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h
index b4e67c8b5c..0424f0f577 100644
--- a/platform/uwp/thread_uwp.h
+++ b/platform/uwp/thread_uwp.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index d737502bf5..f8aed0ccab 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -169,7 +170,7 @@ Error ContextGL_Win::initialize() {
if (wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported
{
- MessageBox(NULL, "Cannot get Proc Adress for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION);
+ MessageBox(NULL, "Cannot get Proc Address for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION);
wglDeleteContext(hRC);
return ERR_CANT_CREATE;
}
diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h
index 383197ba7f..b3cab7806d 100644
--- a/platform/windows/context_gl_win.h
+++ b/platform/windows/context_gl_win.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/ctxgl_procaddr.cpp b/platform/windows/ctxgl_procaddr.cpp
index 79c6f219f3..e01c3fc252 100644
--- a/platform/windows/ctxgl_procaddr.cpp
+++ b/platform/windows/ctxgl_procaddr.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/ctxgl_procaddr.h b/platform/windows/ctxgl_procaddr.h
index da17fbcbbe..ecef01aadf 100644
--- a/platform/windows/ctxgl_procaddr.h
+++ b/platform/windows/ctxgl_procaddr.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 382783d6bc..5e56c1db49 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -242,7 +242,7 @@ def configure(env):
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
env.Append(LINKFLAGS=['/DEBUG'])
- env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
+ env.Append(CCFLAGS=['/MT', '/Gd', '/GR', '/nologo'])
env.Append(CXXFLAGS=['/TP'])
env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
env.Append(CCFLAGS=['/I' + os.getenv("WindowsSdkDir") + "/Include"])
@@ -283,7 +283,7 @@ def configure(env):
+ " will be executed and inform you.")
sys.exit()
- # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt
+ # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the proper command prompt
# that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
env["bits"] = "32"
env["x86_libtheora_opt_vc"] = True
@@ -361,7 +361,7 @@ def configure(env):
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env["CC"] = mingw_prefix + "gcc"
env['AS'] = mingw_prefix + "as"
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index bb51474a8c..2d11bfe4d8 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -26,28 +27,25 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "export.h"
#include "editor/editor_export.h"
#include "platform/windows/logo.h"
void register_windows_exporter() {
-#if 0
+ Ref<EditorExportPlatformPC> platform;
+ platform.instance();
+
Image img(_windows_logo);
- Ref<ImageTexture> logo = memnew( ImageTexture );
+ Ref<ImageTexture> logo;
+ logo.instance();
logo->create_from_image(img);
+ platform->set_logo(logo);
+ platform->set_name("Windows Desktop");
+ platform->set_extension("exe");
+ platform->set_release_32("windows_32_release.exe");
+ platform->set_debug_32("windows_32_debug.exe");
+ platform->set_release_64("windows_64_release.exe");
+ platform->set_debug_64("windows_64_debug.exe");
- {
- Ref<EditorExportPlatformPC> exporter = Ref<EditorExportPlatformPC>( memnew(EditorExportPlatformPC) );
- exporter->set_binary_extension("exe");
- exporter->set_release_binary32("windows_32_release.exe");
- exporter->set_debug_binary32("windows_32_debug.exe");
- exporter->set_release_binary64("windows_64_release.exe");
- exporter->set_debug_binary64("windows_64_debug.exe");
- exporter->set_name("Windows Desktop");
- exporter->set_logo(logo);
- EditorImportExport::get_singleton()->add_export_platform(exporter);
- }
-
-#endif
+ EditorExport::get_singleton()->add_export_platform(platform);
}
diff --git a/platform/windows/export/export.h b/platform/windows/export/export.h
index b437efc48e..ea9113c674 100644
--- a/platform/windows/export/export.h
+++ b/platform/windows/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp
index f8f5fe8231..df2d96e516 100644
--- a/platform/windows/godot_win.cpp
+++ b/platform/windows/godot_win.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index 2472940ef3..7263e89c1a 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -319,7 +320,7 @@ void JoypadWindows::probe_joypads() {
}
}
-unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
+void JoypadWindows::process_joypads() {
HRESULT hr;
@@ -337,16 +338,16 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int i = 0; i <= 16; i++) {
- p_last_id = input->joy_button(p_last_id, joy.id, i, joy.state.Gamepad.wButtons & button_mask);
+ input->joy_button(joy.id, i, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2;
}
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
+ input->joy_axis(joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true));
+ input->joy_axis(joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true));
+ input->joy_axis(joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
+ input->joy_axis(joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
joy.last_packet = joy.state.dwPacketNumber;
}
uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id);
@@ -384,7 +385,7 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
continue;
}
- p_last_id = post_hat(p_last_id, joy->id, js.rgdwPOV[0]);
+ post_hat(joy->id, js.rgdwPOV[0]);
for (int j = 0; j < 128; j++) {
@@ -392,14 +393,14 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
if (!joy->last_buttons[j]) {
- p_last_id = input->joy_button(p_last_id, joy->id, j, true);
+ input->joy_button(joy->id, j, true);
joy->last_buttons[j] = true;
}
} else {
if (joy->last_buttons[j]) {
- p_last_id = input->joy_button(p_last_id, joy->id, j, false);
+ input->joy_button(joy->id, j, false);
joy->last_buttons[j] = false;
}
}
@@ -414,16 +415,16 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
for (int k = 0; k < count; k++) {
if (joy->joy_axis[j] == axes[k]) {
- p_last_id = input->joy_axis(p_last_id, joy->id, j, axis_correct(values[k]));
+ input->joy_axis(joy->id, j, axis_correct(values[k]));
break;
};
};
};
}
- return p_last_id;
+ return;
}
-unsigned int JoypadWindows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) {
+void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
int dpad_val = 0;
@@ -462,7 +463,7 @@ unsigned int JoypadWindows::post_hat(unsigned int p_last_id, int p_device, DWORD
dpad_val = (InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_UP);
}
- return input->joy_hat(p_last_id, p_device, dpad_val);
+ input->joy_hat(p_device, dpad_val);
};
InputDefault::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
diff --git a/platform/windows/joypad.h b/platform/windows/joypad.h
index 7e4f6ff328..7cd791e78f 100644
--- a/platform/windows/joypad.h
+++ b/platform/windows/joypad.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -53,7 +54,7 @@ public:
~JoypadWindows();
void probe_joypads();
- unsigned int process_joypads(unsigned int p_last_id);
+ void process_joypads();
private:
enum {
@@ -130,7 +131,7 @@ private:
void load_xinput();
void unload_xinput();
- unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad);
+ void post_hat(int p_device, DWORD p_dpad);
bool have_device(const GUID &p_guid);
bool is_xinput_device(const GUID *p_guid);
diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp
index 51cdba65d5..bffacb3a82 100644
--- a/platform/windows/key_mapping_win.cpp
+++ b/platform/windows/key_mapping_win.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/key_mapping_win.h b/platform/windows/key_mapping_win.h
index fbc79635c2..af91676dff 100644
--- a/platform/windows/key_mapping_win.h
+++ b/platform/windows/key_mapping_win.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/lang_table.h b/platform/windows/lang_table.h
index 7fe509d3e0..7cf2bb391b 100644
--- a/platform/windows/lang_table.h
+++ b/platform/windows/lang_table.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 2046ae9f44..99b6890913 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -216,7 +217,6 @@ void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) {
InputEvent event;
event.type = InputEvent::SCREEN_TOUCH;
- event.ID = ++last_id;
event.screen_touch.index = idx;
event.screen_touch.pressed = p_pressed;
@@ -233,7 +233,6 @@ void OS_Windows::_drag_event(int p_x, int p_y, int idx) {
InputEvent event;
event.type = InputEvent::SCREEN_DRAG;
- event.ID = ++last_id;
event.screen_drag.index = idx;
event.screen_drag.x = p_x;
@@ -370,7 +369,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InputEvent event;
event.type = InputEvent::MOUSE_MOTION;
- event.ID = ++last_id;
InputEventMouseMotion &mm = event.mouse_motion;
mm.mod.control = (wParam & MK_CONTROL) != 0;
@@ -404,7 +402,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetCursorPos(pos.x, pos.y);
}
- input->set_mouse_pos(Point2(mm.x, mm.y));
+ input->set_mouse_position(Point2(mm.x, mm.y));
mm.speed_x = input->get_last_mouse_speed().x;
mm.speed_y = input->get_last_mouse_speed().y;
@@ -451,7 +449,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InputEvent event;
event.type = InputEvent::MOUSE_BUTTON;
- event.ID = ++last_id;
InputEventMouseButton &mb = event.mouse_button;
switch (uMsg) {
@@ -582,7 +579,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (mb.pressed && mb.button_index > 3) {
//send release for mouse wheel
mb.pressed = false;
- event.ID = ++last_id;
input->parse_input_event(event);
}
}
@@ -780,7 +776,6 @@ void OS_Windows::process_key_events() {
if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
InputEvent event;
event.type = InputEvent::KEY;
- event.ID = ++last_id;
InputEventKey &k = event.key;
k.mod = ke.mod_state;
@@ -805,7 +800,6 @@ void OS_Windows::process_key_events() {
InputEvent event;
event.type = InputEvent::KEY;
- event.ID = ++last_id;
InputEventKey &k = event.key;
k.mod = ke.mod_state;
@@ -1324,7 +1318,7 @@ void OS_Windows::warp_mouse_pos(const Point2 &p_to) {
}
}
-Point2 OS_Windows::get_mouse_pos() const {
+Point2 OS_Windows::get_mouse_position() const {
return Point2(old_x, old_y);
}
@@ -1589,6 +1583,32 @@ bool OS_Windows::get_borderless_window() {
return video_mode.borderless_window;
}
+Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle) {
+ p_library_handle = (void *)LoadLibrary(p_path.utf8().get_data());
+ if (!p_library_handle) {
+ ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + String::num(GetLastError()));
+ ERR_FAIL_V(ERR_CANT_OPEN);
+ }
+ return OK;
+}
+
+Error OS_Windows::close_dynamic_library(void *p_library_handle) {
+ if (!FreeLibrary((HMODULE)p_library_handle)) {
+ return FAILED;
+ }
+ return OK;
+}
+
+Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) {
+ char *error;
+ p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data());
+ if (!p_symbol_handle) {
+ ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError()));
+ ERR_FAIL_V(ERR_CANT_RESOLVE);
+ }
+ return OK;
+}
+
void OS_Windows::request_attention() {
FLASHWINFO info;
@@ -1819,7 +1839,7 @@ void OS_Windows::process_events() {
MSG msg;
- last_id = joypad->process_joypads(last_id);
+ joypad->process_joypads();
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
@@ -1970,7 +1990,6 @@ String OS_Windows::get_executable_path() const {
wchar_t bufname[4096];
GetModuleFileNameW(NULL, bufname, 4096);
String s = bufname;
- print_line("EXEC PATHP??: " + s);
return s;
}
@@ -2303,7 +2322,6 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
hInstance = _hInstance;
pressrc = 0;
old_invalid = true;
- last_id = 0;
mouse_mode = MOUSE_MODE_VISIBLE;
#ifdef STDOUT_FILE
stdo = fopen("stdout.txt", "wb");
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index e7376d6800..87eceafa02 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -83,7 +84,6 @@ class OS_Windows : public OS {
bool outside;
int old_x, old_y;
Point2i center;
- unsigned int last_id;
#if defined(OPENGL_ENABLED)
ContextGL_Win *gl_context;
#endif
@@ -191,7 +191,7 @@ public:
MouseMode get_mouse_mode() const;
virtual void warp_mouse_pos(const Point2 &p_to);
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
@@ -223,6 +223,10 @@ public:
virtual void set_borderless_window(int p_borderless);
virtual bool get_borderless_window();
+ virtual Error open_dynamic_library(const String p_path, void *&p_library_handle);
+ virtual Error close_dynamic_library(void *p_library_handle);
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle);
+
virtual MainLoop *get_main_loop() const;
virtual String get_name();
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
index 2df8addece..f69c0bd2ed 100644
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ b/platform/windows/packet_peer_udp_winsock.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -82,7 +83,7 @@ Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer, int p_buffer_siz
struct sockaddr_storage addr;
size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, sock_type);
- _set_blocking(true);
+ _set_sock_blocking(blocking);
errno = 0;
int err;
@@ -90,7 +91,9 @@ Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer, int p_buffer_siz
if (WSAGetLastError() != WSAEWOULDBLOCK) {
return FAILED;
- };
+ } else if (!blocking) {
+ return ERR_UNAVAILABLE;
+ }
}
return OK;
@@ -101,15 +104,13 @@ int PacketPeerUDPWinsock::get_max_packet_size() const {
return 512; // uhm maybe not
}
-void PacketPeerUDPWinsock::_set_blocking(bool p_blocking) {
- //am no windows expert
- //hope this is the right thing
+void PacketPeerUDPWinsock::_set_sock_blocking(bool p_blocking) {
- if (blocking == p_blocking)
+ if (sock_blocking == p_blocking)
return;
- blocking = p_blocking;
- unsigned long par = blocking ? 0 : 1;
+ sock_blocking = p_blocking;
+ unsigned long par = sock_blocking ? 0 : 1;
if (ioctlsocket(sockfd, FIONBIO, &par)) {
perror("setting non-block mode");
//close();
@@ -139,8 +140,6 @@ Error PacketPeerUDPWinsock::listen(int p_port, IP_Address p_bind_address, int p_
return ERR_UNAVAILABLE;
}
- blocking = true;
-
printf("UDP Connection listening on port %i\n", p_port);
rb.resize(nearest_shift(p_recv_buffer_size));
return OK;
@@ -166,7 +165,7 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) {
return FAILED;
}
- _set_blocking(p_wait);
+ _set_sock_blocking(p_wait);
struct sockaddr_storage from = { 0 };
int len = sizeof(struct sockaddr_storage);
@@ -252,6 +251,9 @@ int PacketPeerUDPWinsock::_get_socket() {
sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP);
+ if (sockfd != -1)
+ _set_sock_blocking(false);
+
return sockfd;
}
@@ -273,6 +275,8 @@ PacketPeerUDP *PacketPeerUDPWinsock::_create() {
PacketPeerUDPWinsock::PacketPeerUDPWinsock() {
+ blocking = true;
+ sock_blocking = true;
sockfd = -1;
packet_port = 0;
queue_count = 0;
diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h
index 62107364af..ceb6df71aa 100644
--- a/platform/windows/packet_peer_udp_winsock.h
+++ b/platform/windows/packet_peer_udp_winsock.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -45,6 +46,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
mutable int packet_port;
mutable int queue_count;
int sockfd;
+ bool sock_blocking;
IP::Type sock_type;
IP_Address peer_addr;
@@ -54,8 +56,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
static PacketPeerUDP *_create();
- bool blocking;
- void _set_blocking(bool p_blocking);
+ void _set_sock_blocking(bool p_blocking);
Error _poll(bool p_wait);
diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h
index 0e16753156..a0fc65ca89 100644
--- a/platform/windows/platform_config.h
+++ b/platform/windows/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/power_windows.cpp b/platform/windows/power_windows.cpp
index d4641cd4ec..1d9756f68b 100644
--- a/platform/windows/power_windows.cpp
+++ b/platform/windows/power_windows.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/power_windows.h b/platform/windows/power_windows.h
index 5c26faa3d1..164f1d7d95 100644
--- a/platform/windows/power_windows.h
+++ b/platform/windows/power_windows.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp
index abf182c72a..18c5a40b80 100644
--- a/platform/windows/stream_peer_winsock.cpp
+++ b/platform/windows/stream_peer_winsock.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h
index c8c2dd4feb..aa60a6500b 100644
--- a/platform/windows/stream_peer_winsock.h
+++ b/platform/windows/stream_peer_winsock.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index 67713f5d1c..3292813d4e 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h
index d7b1aee054..7e5d1e750e 100644
--- a/platform/windows/tcp_server_winsock.h
+++ b/platform/windows/tcp_server_winsock.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index 41d110a1e1..ddf17481b1 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -151,8 +152,6 @@ Error ContextGL_X11::initialize() {
XSync(x11_display, False);
XSetErrorHandler(oldHandler);
- print_line("ALL IS GOOD");
-
glXMakeCurrent(x11_display, x11_window, p->glx_context);
/*
diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h
index be0f4c822c..acb3f38894 100644
--- a/platform/x11/context_gl_x11.h
+++ b/platform/x11/context_gl_x11.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index 89cf639114..34306c8d0f 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -133,7 +133,7 @@ def configure(env):
elif (env["target"] == "debug"):
- env.Prepend(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Prepend(CCFLAGS=['-g2', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env.ParseConfig('pkg-config x11 --cflags --libs')
env.ParseConfig('pkg-config xinerama --cflags --libs')
@@ -227,7 +227,7 @@ def configure(env):
env.Append(LIBS=['dl'])
# env.Append(CPPFLAGS=['-DMPC_FIXED_POINT'])
-# host compiler is default..
+ # host compiler is default..
if (is64 and env["bits"] == "32"):
env.Append(CPPFLAGS=['-m32'])
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index 2659c771ca..b9ded188bf 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -42,7 +43,11 @@ void register_x11_exporter() {
logo->create_from_image(img);
platform->set_logo(logo);
platform->set_name("Linux/X11");
- platform->set_extension("");
+ platform->set_extension("bin");
+ platform->set_release_32("linux_x11_32_release");
+ platform->set_debug_32("linux_x11_32_debug");
+ platform->set_release_64("linux_x11_64_release");
+ platform->set_debug_64("linux_x11_64_debug");
EditorExport::get_singleton()->add_export_platform(platform);
diff --git a/platform/x11/export/export.h b/platform/x11/export/export.h
index 5beaba2cfb..755b73d2c9 100644
--- a/platform/x11/export/export.h
+++ b/platform/x11/export/export.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp
index 078baf76ee..b293b1bebb 100644
--- a/platform/x11/godot_x11.cpp
+++ b/platform/x11/godot_x11.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index 62ece58f58..2502b2d51f 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -454,10 +455,10 @@ InputDefault::JoyAxis JoypadLinux::axis_correct(const input_absinfo *p_abs, int
return jx;
}
-uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
+void JoypadLinux::process_joypads() {
if (joy_mutex->try_lock() != OK) {
- return p_event_id;
+ return;
}
for (int i = 0; i < JOYPADS_MAX; i++) {
@@ -477,11 +478,11 @@ uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
// 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)
- return p_event_id;
+ return;
switch (ev.type) {
case EV_KEY:
- p_event_id = input->joy_button(p_event_id, i, joy->key_map[ev.code], ev.value);
+ input->joy_button(i, joy->key_map[ev.code], ev.value);
break;
case EV_ABS:
@@ -496,7 +497,7 @@ uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
} else
joy->dpad &= ~(InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_RIGHT);
- p_event_id = input->joy_hat(p_event_id, i, joy->dpad);
+ input->joy_hat(i, joy->dpad);
break;
case ABS_HAT0Y:
@@ -508,7 +509,7 @@ uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
} else
joy->dpad &= ~(InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_DOWN);
- p_event_id = input->joy_hat(p_event_id, i, joy->dpad);
+ input->joy_hat(i, joy->dpad);
break;
default:
@@ -525,7 +526,7 @@ uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
for (int j = 0; j < MAX_ABS; j++) {
int index = joy->abs_map[j];
if (index != -1) {
- p_event_id = input->joy_axis(p_event_id, i, index, joy->curr_axis[index]);
+ input->joy_axis(i, index, joy->curr_axis[index]);
}
}
if (len == 0 || (len < 0 && errno != EAGAIN)) {
@@ -546,6 +547,5 @@ uint32_t JoypadLinux::process_joypads(uint32_t p_event_id) {
}
}
joy_mutex->unlock();
- return p_event_id;
}
#endif
diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h
index f90ca9319a..a0ac559b1c 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -42,7 +43,7 @@ class JoypadLinux {
public:
JoypadLinux(InputDefault *in);
~JoypadLinux();
- uint32_t process_joypads(uint32_t p_event_id);
+ void process_joypads();
private:
enum {
diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp
index 4cfcffede0..362fc3618a 100644
--- a/platform/x11/key_mapping_x11.cpp
+++ b/platform/x11/key_mapping_x11.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h
index 8210df06e7..41060c9303 100644
--- a/platform/x11/key_mapping_x11.h
+++ b/platform/x11/key_mapping_x11.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index d7cb69f2b9..2e2fe3ba8a 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -94,7 +95,6 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
last_button_state = 0;
xmbstring = NULL;
- event_id = 0;
x11_window = 0;
last_click_ms = 0;
args = OS::get_singleton()->get_cmdline_args();
@@ -548,7 +548,7 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
XWarpPointer(x11_display, None, x11_window,
0, 0, 0, 0, (int)center.x, (int)center.y);
- input->set_mouse_pos(center);
+ input->set_mouse_position(center);
} else {
do_mouse_warp = false;
}
@@ -580,7 +580,7 @@ int OS_X11::get_mouse_button_state() const {
return last_button_state;
}
-Point2 OS_X11::get_mouse_pos() const {
+Point2 OS_X11::get_mouse_position() const {
return last_mouse_pos;
}
@@ -1019,7 +1019,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
// XKeycodeToKeysym to obtain internationalized
// input.. WRONG!!
// you must use XLookupString (???) which not only wastes
- // cycles generating an unnecesary string, but also
+ // cycles generating an unnecessary string, but also
// still works in half the cases. (won't handle deadkeys)
// For more complex input methods (deadkeys and more advanced)
// you have to use XmbLookupString (??).
@@ -1075,7 +1075,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
/* Phase 4, determine if event must be filtered */
// This seems to be a side-effect of using XIM.
- // XEventFilter looks like a core X11 funciton,
+ // XEventFilter looks like a core X11 function,
// but it's actually just used to see if we must
// ignore a deadkey, or events XIM determines
// must not reach the actual gui.
@@ -1143,7 +1143,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
/* Phase 7, send event to Window */
InputEvent event;
- event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = state;
@@ -1157,7 +1156,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) {
event.key.echo = p_echo;
if (event.key.scancode == KEY_BACKTAB) {
- //make it consistent accross platforms.
+ //make it consistent across platforms.
event.key.scancode = KEY_TAB;
event.key.mod.shift = true;
}
@@ -1334,7 +1333,6 @@ void OS_X11::process_xevents() {
}
InputEvent mouse_event;
- mouse_event.ID = ++event_id;
mouse_event.type = InputEvent::MOUSE_BUTTON;
mouse_event.device = 0;
mouse_event.mouse_button.mod = get_key_modifier_state(event.xbutton.state);
@@ -1360,7 +1358,6 @@ void OS_X11::process_xevents() {
last_click_ms = 0;
last_click_pos = Point2(-100, -100);
mouse_event.mouse_button.doubleclick = true;
- mouse_event.ID = ++event_id;
} else {
last_click_ms += diff;
@@ -1447,7 +1444,6 @@ void OS_X11::process_xevents() {
Point2i rel = pos - last_mouse_pos;
InputEvent motion_event;
- motion_event.ID = ++event_id;
motion_event.type = InputEvent::MOUSE_MOTION;
motion_event.device = 0;
@@ -1455,7 +1451,7 @@ void OS_X11::process_xevents() {
motion_event.mouse_motion.button_mask = get_mouse_button_state(event.xmotion.state);
motion_event.mouse_motion.x = pos.x;
motion_event.mouse_motion.y = pos.y;
- input->set_mouse_pos(pos);
+ input->set_mouse_position(pos);
motion_event.mouse_motion.global_x = pos.x;
motion_event.mouse_motion.global_y = pos.y;
motion_event.mouse_motion.speed_x = input->get_last_mouse_speed().x;
@@ -1916,7 +1912,7 @@ void OS_X11::run() {
process_xevents(); // get rid of pending events
#ifdef JOYDEV_ENABLED
- event_id = joypad->process_joypads(event_id);
+ joypad->process_joypads();
#endif
if (Main::iteration() == true)
break;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index cbda18c0bc..44994e40ec 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
@@ -116,7 +117,6 @@ class OS_X11 : public OS_Unix {
bool last_mouse_pos_valid;
Point2i last_click_pos;
uint64_t last_click_ms;
- unsigned int event_id;
uint32_t last_button_state;
PhysicsServer *physics_server;
@@ -202,7 +202,7 @@ public:
MouseMode get_mouse_mode() const;
virtual void warp_mouse_pos(const Point2 &p_to);
- virtual Point2 get_mouse_pos() const;
+ virtual Point2 get_mouse_position() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String &p_title);
diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h
index 342270b74a..1a1de42b47 100644
--- a/platform/x11/platform_config.h
+++ b/platform/x11/platform_config.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp
index 2f98d2f335..3454a6313e 100644
--- a/platform/x11/power_x11.cpp
+++ b/platform/x11/power_x11.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */
diff --git a/platform/x11/power_x11.h b/platform/x11/power_x11.h
index 7693a5b022..64ed5fe26a 100644
--- a/platform/x11/power_x11.h
+++ b/platform/x11/power_x11.h
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 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 */