summaryrefslogtreecommitdiff
path: root/scene/main/scene_main_loop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/scene_main_loop.cpp')
-rw-r--r--scene/main/scene_main_loop.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index a43938c661..b55a925f55 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -379,9 +379,9 @@ bool SceneTree::is_input_handled() {
return input_handled;
}
-void SceneTree::input_event(const InputEvent &p_event) {
+void SceneTree::input_event(const Ref<InputEvent> &p_event) {
- if (is_editor_hint() && (p_event.type == InputEvent::JOYPAD_MOTION || p_event.type == InputEvent::JOYPAD_BUTTON))
+ if (is_editor_hint() && (p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventJoypadMotion>()))
return; //avoid joy input on editor
root_lock++;
@@ -389,8 +389,8 @@ void SceneTree::input_event(const InputEvent &p_event) {
input_handled = false;
- InputEvent ev = p_event;
- ev.ID = ++last_id; //this should work better
+ Ref<InputEvent> ev = p_event;
+ ev->set_id(++last_id); //this should work better
#if 0
switch(ev.type) {
@@ -398,9 +398,9 @@ void SceneTree::input_event(const InputEvent &p_event) {
Matrix32 ai = root->get_final_transform().affine_inverse();
Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
- Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
- ev.mouse_button.x=l.x;
- ev.mouse_button.y=l.y;
+ Vector2 l = ai.xform(Vector2(ev->get_pos().x,ev->get_pos().y));
+ ev->get_pos().x=l.x;
+ ev->get_pos().y=l.y;
ev.mouse_button.global_x=g.x;
ev.mouse_button.global_y=g.y;
@@ -410,13 +410,13 @@ void SceneTree::input_event(const InputEvent &p_event) {
Matrix32 ai = root->get_final_transform().affine_inverse();
Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
- Vector2 r = ai.xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
+ Vector2 r = ai.xform(Vector2(ev->get_relative().x,ev->get_relative().y));
ev.mouse_motion.x=l.x;
ev.mouse_motion.y=l.y;
ev.mouse_motion.global_x=g.x;
ev.mouse_motion.global_y=g.y;
- ev.mouse_motion.relative_x=r.x;
- ev.mouse_motion.relative_y=r.y;
+ ev->get_relative().x=r.x;
+ ev->get_relative().y=r.y;
} break;
case InputEvent::SCREEN_TOUCH: {
@@ -453,12 +453,12 @@ void SceneTree::input_event(const InputEvent &p_event) {
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev);
/*
- if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F12) {
+ if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F12) {
print_line("RAM: "+itos(Memory::get_static_mem_usage()));
print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage()));
}
- if (ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F11) {
+ if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F11) {
Memory::dump_static_mem_to_file("memdump.txt");
}
@@ -470,9 +470,13 @@ void SceneTree::input_event(const InputEvent &p_event) {
call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check
#endif
- if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type == InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode == KEY_F8) {
- ScriptDebugger::get_singleton()->request_quit();
+ if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) {
+ //quit from game window using F8
+ Ref<InputEventKey> k = ev;
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_F8) {
+ ScriptDebugger::get_singleton()->request_quit();
+ }
}
_flush_ugc();
@@ -878,7 +882,7 @@ bool SceneTree::is_paused() const {
return pause;
}
-void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const InputEvent &p_input) {
+void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input) {
Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)