diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2023-02-04 23:16:54 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2023-02-06 22:49:42 +0100 |
commit | 8748f4dcaa9a7f703529e48c22064948d5121fd3 (patch) | |
tree | 10113a88d2d9c796ac82e8d94e4ebb4171b2d0dc /scene/main | |
parent | 945207885b3cd97012215334e56fcd3139d25e9f (diff) |
Fix mouse/drag/touch InputEvents having no device id
Some internally created emulated/instantiated events didn't have a
device id. This PR sets for these cases a device id.
Also rename `DEVICE_ID_TOUCH_MOUSE` to the more generic
`DEVICE_ID_EMULATION`.
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 5 | ||||
-rw-r--r-- | scene/main/window.cpp | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 7091dd0388..841e6e4df9 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -614,7 +614,7 @@ void Viewport::_process_picking() { physics_last_mouse_state.mouse_mask.clear_flag(mouse_button_to_mask(mb->get_button_index())); // If touch mouse raised, assume we don't know last mouse pos until new events come - if (mb->get_device() == InputEvent::DEVICE_ID_TOUCH_MOUSE) { + if (mb->get_device() == InputEvent::DEVICE_ID_EMULATION) { physics_has_last_mousepos = false; } } @@ -2290,6 +2290,7 @@ void Viewport::_drop_mouse_focus() { mb->set_global_position(c->get_local_mouse_position()); mb->set_button_index(MouseButton(i + 1)); mb->set_pressed(false); + mb->set_device(InputEvent::DEVICE_ID_INTERNAL); c->_call_gui_input(mb); } } @@ -2401,6 +2402,7 @@ void Viewport::_post_gui_grab_click_focus() { mb->set_position(click); mb->set_button_index(MouseButton(i + 1)); mb->set_pressed(false); + mb->set_device(InputEvent::DEVICE_ID_INTERNAL); gui.mouse_focus->_call_gui_input(mb); } } @@ -2418,6 +2420,7 @@ void Viewport::_post_gui_grab_click_focus() { mb->set_position(click); mb->set_button_index(MouseButton(i + 1)); mb->set_pressed(true); + mb->set_device(InputEvent::DEVICE_ID_INTERNAL); MessageQueue::get_singleton()->push_callable(callable_mp(gui.mouse_focus, &Control::_call_gui_input), mb); } } diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 33946246b0..9fcfb29ef7 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -647,6 +647,7 @@ void Window::update_mouse_cursor_shape() { mm.instantiate(); mm->set_position(pos); mm->set_global_position(xform.xform(pos)); + mm->set_device(InputEvent::DEVICE_ID_INTERNAL); push_input(mm); } |