mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
Merge pull request #56754 from madmiraal/fix-45592
This commit is contained in:
commit
57a057f7ff
@ -518,18 +518,20 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
|
||||
if (mm.is_valid()) {
|
||||
Point2 pos = mm->get_global_position();
|
||||
if (mouse_pos != pos) {
|
||||
set_mouse_position(pos);
|
||||
Point2 position = mm->get_global_position();
|
||||
if (mouse_pos != position) {
|
||||
set_mouse_position(position);
|
||||
}
|
||||
Vector2 relative = mm->get_relative();
|
||||
mouse_velocity_track.update(relative);
|
||||
|
||||
if (event_dispatch_function && emulate_touch_from_mouse && !p_is_emulated && (mm->get_button_mask() & MouseButton::LEFT) != MouseButton::NONE) {
|
||||
Ref<InputEventScreenDrag> drag_event;
|
||||
drag_event.instantiate();
|
||||
|
||||
drag_event->set_position(mm->get_position());
|
||||
drag_event->set_relative(mm->get_relative());
|
||||
drag_event->set_velocity(mm->get_velocity());
|
||||
drag_event->set_position(position);
|
||||
drag_event->set_relative(relative);
|
||||
drag_event->set_velocity(get_last_mouse_velocity());
|
||||
|
||||
event_dispatch_function(drag_event);
|
||||
}
|
||||
@ -710,7 +712,6 @@ void Input::set_gyroscope(const Vector3 &p_gyroscope) {
|
||||
}
|
||||
|
||||
void Input::set_mouse_position(const Point2 &p_posf) {
|
||||
mouse_velocity_track.update(p_posf - mouse_pos);
|
||||
mouse_pos = p_posf;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,6 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button,
|
||||
DisplayServerJavaScript *ds = get_singleton();
|
||||
|
||||
Point2 pos(p_x, p_y);
|
||||
Input::get_singleton()->set_mouse_position(pos);
|
||||
Ref<InputEventMouseButton> ev;
|
||||
ev.instantiate();
|
||||
ev->set_position(pos);
|
||||
@ -219,7 +218,6 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double
|
||||
}
|
||||
|
||||
Point2 pos(p_x, p_y);
|
||||
Input::get_singleton()->set_mouse_position(pos);
|
||||
Ref<InputEventMouseMotion> ev;
|
||||
ev.instantiate();
|
||||
dom2godot_mod(ev, p_modifiers);
|
||||
@ -229,7 +227,6 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double
|
||||
ev->set_global_position(pos);
|
||||
|
||||
ev->set_relative(Vector2(p_rel_x, p_rel_y));
|
||||
Input::get_singleton()->set_mouse_position(ev->get_position());
|
||||
ev->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
|
||||
|
||||
Input::get_singleton()->parse_input_event(ev);
|
||||
|
@ -3631,7 +3631,6 @@ void DisplayServerX11::process_events() {
|
||||
mm->set_button_mask((MouseButton)mouse_get_button_state());
|
||||
mm->set_position(pos);
|
||||
mm->set_global_position(pos);
|
||||
Input::get_singleton()->set_mouse_position(pos);
|
||||
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
|
||||
|
||||
mm->set_relative(rel);
|
||||
|
@ -787,7 +787,6 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M
|
||||
mm->set_relative(relativeMotion);
|
||||
_get_key_modifier_state([event modifierFlags], mm);
|
||||
|
||||
Input::get_singleton()->set_mouse_position(wd.mouse_pos);
|
||||
Input::get_singleton()->parse_input_event(mm);
|
||||
}
|
||||
|
||||
|
@ -2072,7 +2072,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
mm->set_position(c);
|
||||
mm->set_global_position(c);
|
||||
Input::get_singleton()->set_mouse_position(c);
|
||||
mm->set_velocity(Vector2(0, 0));
|
||||
|
||||
if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) {
|
||||
@ -2177,7 +2176,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
SetCursorPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
Input::get_singleton()->set_mouse_position(mm->get_position());
|
||||
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
|
||||
|
||||
if (old_invalid) {
|
||||
@ -2319,7 +2317,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
SetCursorPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
Input::get_singleton()->set_mouse_position(mm->get_position());
|
||||
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
|
||||
|
||||
if (old_invalid) {
|
||||
@ -2420,7 +2417,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
SetCursorPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
Input::get_singleton()->set_mouse_position(mm->get_position());
|
||||
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());
|
||||
|
||||
if (old_invalid) {
|
||||
|
Loading…
Reference in New Issue
Block a user