summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/build.gradle.template1
-rw-r--r--platform/android/detect.py4
-rw-r--r--platform/android/os_android.cpp36
-rw-r--r--platform/android/os_android.h1
-rw-r--r--platform/bb10/os_bb10.cpp6
-rw-r--r--platform/bb10/os_bb10.h2
-rw-r--r--platform/haiku/detect.py2
-rw-r--r--platform/haiku/haiku_direct_window.cpp6
-rw-r--r--platform/haiku/haiku_direct_window.h1
-rw-r--r--platform/iphone/detect.py12
-rw-r--r--platform/iphone/os_iphone.cpp9
-rw-r--r--platform/iphone/os_iphone.h1
-rw-r--r--platform/javascript/detect.py4
-rw-r--r--platform/javascript/export/export.cpp456
-rw-r--r--platform/javascript/godot_shell.html199
-rw-r--r--platform/javascript/javascript_main.cpp13
-rw-r--r--platform/javascript/os_javascript.cpp23
-rw-r--r--platform/javascript/os_javascript.h3
-rw-r--r--platform/osx/detect.py2
-rw-r--r--platform/osx/joypad_osx.cpp9
-rw-r--r--platform/osx/joypad_osx.h2
-rw-r--r--platform/osx/os_osx.h2
-rw-r--r--platform/osx/os_osx.mm4
-rw-r--r--platform/server/detect.py2
-rw-r--r--platform/uwp/joypad_uwp.cpp18
-rw-r--r--platform/uwp/joypad_uwp.h2
-rw-r--r--platform/uwp/os_uwp.cpp6
-rw-r--r--platform/uwp/os_uwp.h1
-rw-r--r--platform/windows/detect.py2
-rw-r--r--platform/windows/joypad.cpp30
-rw-r--r--platform/windows/joypad.h4
-rw-r--r--platform/windows/os_windows.cpp13
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/detect.py4
-rw-r--r--platform/x11/joypad_linux.cpp15
-rw-r--r--platform/x11/joypad_linux.h2
-rw-r--r--platform/x11/os_x11.cpp16
-rw-r--r--platform/x11/os_x11.h1
38 files changed, 331 insertions, 584 deletions
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 24aab8e01f..ec5bbb6630 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$$
}
diff --git a/platform/android/detect.py b/platform/android/detect.py
index d1b33fe649..0e78a4618d 100644
--- a/platform/android/detect.py
+++ b/platform/android/detect.py
@@ -168,9 +168,7 @@ 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
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 1484ccfb8c..77536448e4 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -129,7 +129,7 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int
RasterizerGLES3::make_current();
visual_server = memnew(VisualServerRaster);
-/* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
+ /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
visual_server = memnew(VisualServerWrapMT(visual_server, false));
};*/
@@ -343,16 +343,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;
@@ -361,7 +361,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);
}
@@ -376,7 +375,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;
@@ -390,7 +388,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;
@@ -409,7 +406,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;
@@ -417,7 +413,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_pos(Point2(touch[0].pos.x, touch[0].pos.y));
last_mouse = touch[0].pos;
input->parse_input_event(ev);
}
@@ -427,7 +423,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;
@@ -442,7 +437,6 @@ 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;
@@ -475,7 +469,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;
@@ -492,7 +485,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;
@@ -500,14 +492,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_pos(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;
@@ -527,7 +518,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;
@@ -542,7 +532,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;
@@ -627,8 +616,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) {
@@ -746,9 +735,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) {
@@ -774,9 +763,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 ad438d8626..28abbf934d 100644
--- a/platform/android/os_android.h
+++ b/platform/android/os_android.h
@@ -94,7 +94,6 @@ private:
Vector<TouchPos> touch;
Point2 last_mouse;
- unsigned int last_id;
GFXInitFunc gfx_init_func;
void *gfx_init_ud;
diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp
index 80e846d3cd..c8d5b82a98 100644
--- a/platform/bb10/os_bb10.cpp
+++ b/platform/bb10/os_bb10.cpp
@@ -282,7 +282,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 +300,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 +316,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,7 +344,6 @@ 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;
@@ -366,7 +362,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 +590,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..30978d2f60 100644
--- a/platform/bb10/os_bb10.h
+++ b/platform/bb10/os_bb10.h
@@ -48,8 +48,6 @@
class OSBB10 : public OS_Unix {
- unsigned int last_id;
-
screen_context_t screen_cxt;
float fullscreen_mixer_volume;
float fullscreen_stream_volume;
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/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index 3ed7a84eb5..f64fb706c1 100644
--- a/platform/haiku/haiku_direct_window.cpp
+++ b/platform/haiku/haiku_direct_window.cpp
@@ -151,7 +151,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 +207,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;
@@ -237,7 +235,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 +249,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 +271,6 @@ void HaikuDirectWindow::HandleKeyboardEvent(BMessage *message) {
}
InputEvent event;
- event.ID = ++event_id;
event.type = InputEvent::KEY;
event.device = 0;
event.key.mod = GetKeyModifierState(modifiers);
@@ -313,7 +308,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..d4fd05e45f 100644
--- a/platform/haiku/haiku_direct_window.h
+++ b/platform/haiku/haiku_direct_window.h
@@ -43,7 +43,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/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/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 752690762e..576518011f 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -196,7 +196,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 +208,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 +223,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;
@@ -250,7 +247,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 +260,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
@@ -327,7 +322,6 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
ev.device = 0;
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);
};
@@ -338,7 +332,6 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
ev.device = 0;
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);
};
@@ -349,7 +342,6 @@ void OSIPhone::update_accelerometer(float p_x, float p_y, float p_z) {
ev.device = 0;
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);
};
@@ -566,7 +558,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..7557453a02 100644
--- a/platform/iphone/os_iphone.h
+++ b/platform/iphone/os_iphone.h
@@ -119,7 +119,6 @@ private:
InputEvent event_queue[MAX_EVENTS];
int event_count;
- int last_event_id;
void queue_event(const InputEvent &p_event);
String data_dir;
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/export/export.cpp b/platform/javascript/export/export.cpp
index 4fdb6f39c8..9a1e6672cb 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -26,399 +26,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/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_main.cpp b/platform/javascript/javascript_main.cpp
index 00e531baa1..a0fb9b83e2 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -145,15 +145,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..bcb7365204 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -520,7 +520,6 @@ 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));
} else if (ev.type == InputEvent::MOUSE_BUTTON) {
@@ -540,7 +539,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 +552,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 +570,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 +586,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,7 +600,6 @@ 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;
@@ -638,7 +632,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 +648,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 +661,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 +680,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 +694,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 +750,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 +779,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 +789,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 +828,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..1bf001e46f 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -58,7 +58,6 @@ private:
Vector<TouchPos> touch;
Point2 last_mouse;
int last_button_mask;
- unsigned int last_id;
GFXInitFunc gfx_init_func;
void *gfx_init_ud;
@@ -177,7 +176,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/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/joypad_osx.cpp b/platform/osx/joypad_osx.cpp
index c2b0e1f052..7b77f3bb68 100644
--- a/platform/osx/joypad_osx.cpp
+++ b/platform/osx/joypad_osx.cpp
@@ -458,7 +458,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 +467,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 +494,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..e565f4f46d 100644
--- a/platform/osx/joypad_osx.h
+++ b/platform/osx/joypad_osx.h
@@ -110,7 +110,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..8676c86131 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -61,7 +61,6 @@ public:
List<String> args;
MainLoop *main_loop;
- unsigned int event_id;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
@@ -83,7 +82,6 @@ public:
// pthread_key_t current;
bool mouse_grab;
Point2 mouse_pos;
- uint32_t last_id;
id delegate;
id window_delegate;
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 0699978caf..8411bdb114 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1698,7 +1698,6 @@ void OS_OSX::process_events() {
void OS_OSX::push_input(const InputEvent& p_event) {
InputEvent ev=p_event;
- ev.ID=last_id++;
//print_line("EV: "+String(ev));
input->parse_input_event(ev);
}
@@ -1725,7 +1724,7 @@ void OS_OSX::run() {
while (!force_quit) {
process_events(); // get rid of pending events
- last_id = joypad_osx->process_joypads(last_id);
+ joypad_osx->process_joypads();
if (Main::iteration()==true)
break;
};
@@ -1822,7 +1821,6 @@ OS_OSX::OS_OSX() {
[NSApp setDelegate:delegate];
- last_id=1;
cursor_shape=CURSOR_ARROW;
current_screen = 0;
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/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp
index dd57ed94ae..7860994a79 100644
--- a/platform/uwp/joypad_uwp.cpp
+++ b/platform/uwp/joypad_uwp.cpp
@@ -40,7 +40,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 +55,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..a2572eae3d 100644
--- a/platform/uwp/joypad_uwp.h
+++ b/platform/uwp/joypad_uwp.h
@@ -37,7 +37,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..907156d280 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -344,15 +344,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);
}
};
@@ -680,7 +677,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 +904,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..95b834acc4 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -92,7 +92,6 @@ private:
bool outside;
int old_x, old_y;
Point2i center;
- unsigned int last_id;
VisualServer *visual_server;
Rasterizer *rasterizer;
PhysicsServer *physics_server;
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index a3e410ec64..6080c6f1dc 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -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/joypad.cpp b/platform/windows/joypad.cpp
index 2472940ef3..86f7033d40 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -319,7 +319,7 @@ void JoypadWindows::probe_joypads() {
}
}
-unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
+void JoypadWindows::process_joypads() {
HRESULT hr;
@@ -337,16 +337,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 +384,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 +392,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 +414,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 +462,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..9e6aa41a34 100644
--- a/platform/windows/joypad.h
+++ b/platform/windows/joypad.h
@@ -53,7 +53,7 @@ public:
~JoypadWindows();
void probe_joypads();
- unsigned int process_joypads(unsigned int p_last_id);
+ void process_joypads();
private:
enum {
@@ -130,7 +130,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/os_windows.cpp b/platform/windows/os_windows.cpp
index 2046ae9f44..83a6aa6079 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -216,7 +216,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 +232,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 +368,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;
@@ -451,7 +448,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 +578,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 +775,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 +799,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;
@@ -1819,7 +1812,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)) {
@@ -2174,6 +2167,9 @@ void OS_Windows::run() {
if (!main_loop)
return;
+ // Process all events before the main initialization so the cursor will get initialized properly
+ process_events(); // get rid of pending events
+
main_loop->init();
uint64_t last_ticks = get_ticks_usec();
@@ -2303,7 +2299,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..25c3102ee6 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -83,7 +83,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
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/joypad_linux.cpp b/platform/x11/joypad_linux.cpp
index 62ece58f58..db4a501b4c 100644
--- a/platform/x11/joypad_linux.cpp
+++ b/platform/x11/joypad_linux.cpp
@@ -454,10 +454,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 +477,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 +496,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 +508,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 +525,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 +546,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..7b8ebf5bc3 100644
--- a/platform/x11/joypad_linux.h
+++ b/platform/x11/joypad_linux.h
@@ -42,7 +42,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/os_x11.cpp b/platform/x11/os_x11.cpp
index fe162370aa..4606a90835 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -94,7 +94,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();
@@ -1143,7 +1142,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;
@@ -1279,8 +1277,12 @@ void OS_X11::process_xevents() {
case EnterNotify: {
if (main_loop && !mouse_mode_grab)
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
- if (input)
+ if (input) {
+ // Update mouse position. It is triggered before mouse motion.
+ Point2i pos(event.xmotion.x, event.xmotion.y);
+ input->set_mouse_pos(pos);
input->set_mouse_in_window(true);
+ }
} break;
case FocusIn:
minimized = false;
@@ -1334,7 +1336,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 +1361,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 +1447,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;
@@ -1905,6 +1904,9 @@ void OS_X11::run() {
if (!main_loop)
return;
+ // Process all events before the main initialization so the cursor will get initialized properly
+ process_xevents(); // get rid of pending events
+
main_loop->init();
//uint64_t last_ticks=get_ticks_usec();
@@ -1916,7 +1918,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..b5a74c68b8 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -116,7 +116,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;