diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 23:51:26 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 23:51:26 +0100 |
commit | cd0f1e9b102fe899d37921c1155df08966549363 (patch) | |
tree | ce35d1c6f721a69f35d8fb6b1655c0fa288ed64e /core | |
parent | 6a58f4e305bc013199a2a7631775fb084d3c1510 (diff) | |
parent | 8748f4dcaa9a7f703529e48c22064948d5121fd3 (diff) |
Merge pull request #72740 from Sauermann/fix-event-device-id
Fix mouse/drag/touch InputEvents having no device id
Diffstat (limited to 'core')
-rw-r--r-- | core/input/input.cpp | 9 | ||||
-rw-r--r-- | core/input/input_event.cpp | 2 | ||||
-rw-r--r-- | core/input/input_event.h | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index 2e886f9093..071d9ba648 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -533,6 +533,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em touch_event->set_pressed(mb->is_pressed()); touch_event->set_position(mb->get_position()); touch_event->set_double_tap(mb->is_double_click()); + touch_event->set_device(InputEvent::DEVICE_ID_EMULATION); event_dispatch_function(touch_event); } } @@ -557,6 +558,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em drag_event->set_pen_inverted(mm->get_pen_inverted()); drag_event->set_pressure(mm->get_pressure()); drag_event->set_velocity(get_last_mouse_velocity()); + drag_event->set_device(InputEvent::DEVICE_ID_EMULATION); event_dispatch_function(drag_event); } @@ -592,7 +594,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em Ref<InputEventMouseButton> button_event; button_event.instantiate(); - button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); + button_event->set_device(InputEvent::DEVICE_ID_EMULATION); button_event->set_position(st->get_position()); button_event->set_global_position(st->get_position()); button_event->set_pressed(st->is_pressed()); @@ -623,7 +625,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em Ref<InputEventMouseMotion> motion_event; motion_event.instantiate(); - motion_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); + motion_event->set_device(InputEvent::DEVICE_ID_EMULATION); motion_event->set_tilt(sd->get_tilt()); motion_event->set_pen_inverted(sd->get_pen_inverted()); motion_event->set_pressure(sd->get_pressure()); @@ -832,7 +834,7 @@ void Input::ensure_touch_mouse_raised() { Ref<InputEventMouseButton> button_event; button_event.instantiate(); - button_event->set_device(InputEvent::DEVICE_ID_TOUCH_MOUSE); + button_event->set_device(InputEvent::DEVICE_ID_EMULATION); button_event->set_position(mouse_pos); button_event->set_global_position(mouse_pos); button_event->set_pressed(false); @@ -869,6 +871,7 @@ void Input::set_default_cursor_shape(CursorShape p_shape) { mm.instantiate(); mm->set_position(mouse_pos); mm->set_global_position(mouse_pos); + mm->set_device(InputEvent::DEVICE_ID_INTERNAL); parse_input_event(mm); } diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 5a9ec74184..7c4642a8a5 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -34,7 +34,7 @@ #include "core/input/shortcut.h" #include "core/os/keyboard.h" -const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1; +const int InputEvent::DEVICE_ID_EMULATION = -1; const int InputEvent::DEVICE_ID_INTERNAL = -2; void InputEvent::set_device(int p_device) { diff --git a/core/input/input_event.h b/core/input/input_event.h index 797761b208..eff8d479db 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -59,7 +59,7 @@ protected: static void _bind_methods(); public: - static const int DEVICE_ID_TOUCH_MOUSE; + static const int DEVICE_ID_EMULATION; static const int DEVICE_ID_INTERNAL; void set_device(int p_device); |