diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 11 | ||||
-rw-r--r-- | main/input_default.h | 1 | ||||
-rw-r--r-- | main/tests/test_gui.cpp | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index bc409960d6..8e352ca8e3 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -478,6 +478,17 @@ void InputDefault::warp_mouse_pos(const Vector2 &p_to) { OS::get_singleton()->warp_mouse_pos(p_to); } +Point2i InputDefault::warp_mouse_motion(const InputEventMouseMotion &p_motion, const Rect2 &p_rect) { + + const Point2i rel_warped(Math::fmod(p_motion.relative_x, p_rect.size.x), Math::fmod(p_motion.relative_y, p_rect.size.y)); + const Point2i pos_local = Point2i(p_motion.global_x, p_motion.global_y) - p_rect.pos; + const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y)); + if (pos_warped != pos_local) { + OS::get_singleton()->warp_mouse_pos(pos_warped + p_rect.pos); + } + return rel_warped; +} + void InputDefault::iteration(float p_step) { } diff --git a/main/input_default.h b/main/input_default.h index fecdb215d7..4f298d6d55 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -200,6 +200,7 @@ public: virtual int get_mouse_button_mask() const; virtual void warp_mouse_pos(const Vector2 &p_to); + virtual Point2i warp_mouse_motion(const InputEventMouseMotion &p_motion, const Rect2 &p_rect); virtual void parse_input_event(const InputEvent &p_event); diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index c291afaf32..a2dd950af6 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -299,7 +299,7 @@ public: richtext->push_color(Color(0, 1.0, 0.5)); richtext->add_text("faeries.\n"); richtext->pop(); - richtext->add_text("In this new episode, we will attemp to "); + richtext->add_text("In this new episode, we will attempt to "); richtext->push_font(richtext->get_font("mono_font", "Fonts")); richtext->push_color(Color(0.7, 0.5, 1.0)); richtext->add_text("deliver something nice"); |