From 72558b617332a7e9499f4d40ba782f99a1789ead Mon Sep 17 00:00:00 2001 From: mikica1986vee Date: Thu, 25 Sep 2014 20:48:38 +0200 Subject: [PATCH] warp_mouse_pos for osx Just copied windows behavior. --- platform/osx/os_osx.mm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index c09dadc066..643c287c95 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1070,7 +1070,20 @@ bool OS_OSX::is_mouse_grab_enabled() const { void OS_OSX::warp_mouse_pos(const Point2& p_to) { -//not done, must be done + //copied from windows impl with osx native calls + if (mouse_mode == MOUSE_MODE_CAPTURED){ + mouse_x = p_to.x; + mouse_y = p_to.y; + } + else{ //set OS position + CGPoint lMouseWarpPos = {p_to.x, p_to.y}; + + CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); + CGEventSourceSetLocalEventsSuppressionInterval(lEventRef, 0.0); + CGAssociateMouseAndMouseCursorPosition(false); + CGWarpMouseCursorPosition(lMouseWarpPos); + CGAssociateMouseAndMouseCursorPosition(true); + } } Point2 OS_OSX::get_mouse_pos() const {