diff options
Diffstat (limited to 'platform/javascript/os_javascript.cpp')
-rw-r--r-- | platform/javascript/os_javascript.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
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; |