diff --git a/lime/_backend/native/NativeMouse.hx b/lime/_backend/native/NativeMouse.hx index 9733cb964..5fd3b02a1 100644 --- a/lime/_backend/native/NativeMouse.hx +++ b/lime/_backend/native/NativeMouse.hx @@ -10,7 +10,8 @@ class NativeMouse { private static var __cursor:MouseCursor; private static var __hidden:Bool; - + private static var __lock:Bool; + public static function hide ():Void { @@ -45,16 +46,30 @@ class NativeMouse { } - public static function setRelative (value:Bool):Int { + // Get & Set Methods + + + + + public static function get_lock ():Bool { - return lime_mouse_set_relative (value); + return __lock; } - // Get & Set Methods - - + public static function set_lock (value:Bool):Bool { + + if (__lock != value) { + + lime_mouse_set_lock (value); + __lock = value; + + } + + return __lock; + + } public static function get_cursor ():MouseCursor { @@ -109,7 +124,7 @@ class NativeMouse { private static var lime_mouse_warp_global = System.load ("lime", "lime_mouse_warp_global", 2); - private static var lime_mouse_set_relative = System.load ("lime", "lime_mouse_set_relative", 1); + private static var lime_mouse_set_lock = System.load ("lime", "lime_mouse_set_lock", 1); private static var lime_mouse_hide = System.load ("lime", "lime_mouse_hide", 0); private static var lime_mouse_set_cursor = System.load ("lime", "lime_mouse_set_cursor", 1); private static var lime_mouse_show = System.load ("lime", "lime_mouse_show", 0); diff --git a/lime/ui/Mouse.hx b/lime/ui/Mouse.hx index 9d59b4fc1..4df412491 100644 --- a/lime/ui/Mouse.hx +++ b/lime/ui/Mouse.hx @@ -4,6 +4,7 @@ package lime.ui; class Mouse { + public static var lock (get, set):Bool; public static var cursor (get, set):MouseCursor; @@ -24,12 +25,6 @@ class Mouse { MouseBackend.warpGlobal(x,y); } - - public static function setRelative(value:Bool):Int { - - return MouseBackend.setRelative(value); - } - @@ -38,6 +33,19 @@ class Mouse { + private static function get_lock ():Bool { + + return MouseBackend.get_lock (); + + } + + + private static function set_lock (value:Bool):Bool { + + return MouseBackend.set_lock (value); + + } + private static function get_cursor ():MouseCursor { return MouseBackend.get_cursor (); diff --git a/project/include/ui/Mouse.h b/project/include/ui/Mouse.h index 5eb86de00..f5db702b6 100644 --- a/project/include/ui/Mouse.h +++ b/project/include/ui/Mouse.h @@ -15,7 +15,7 @@ namespace lime { static MouseCursor currentCursor; static void WarpGlobal (int x, int y); - static int SetRelative (bool value); + static void SetLock (bool value); static void Hide (); static void SetCursor (MouseCursor cursor); static void Show (); diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index a0cab79e1..b5795a21f 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -524,9 +524,9 @@ namespace lime { } - value lime_mouse_set_relative (value input_value) { + value lime_mouse_set_lock (value input_value) { - Mouse::SetRelative (input_value); + Mouse::SetLock (input_value); return alloc_null (); } @@ -811,7 +811,7 @@ namespace lime { DEFINE_PRIM (lime_lzma_encode, 1); DEFINE_PRIM (lime_lzma_decode, 1); DEFINE_PRIM (lime_mouse_warp_global, 2); - DEFINE_PRIM (lime_mouse_set_relative, 1); + DEFINE_PRIM (lime_mouse_set_lock, 1); DEFINE_PRIM (lime_mouse_hide, 0); DEFINE_PRIM (lime_mouse_set_cursor, 1); DEFINE_PRIM (lime_mouse_show, 0); diff --git a/project/src/backend/sdl/SDLMouse.cpp b/project/src/backend/sdl/SDLMouse.cpp index 4bce36a07..21b8fe97c 100644 --- a/project/src/backend/sdl/SDLMouse.cpp +++ b/project/src/backend/sdl/SDLMouse.cpp @@ -24,14 +24,15 @@ namespace lime { } - int Mouse::SetRelative (bool value) { + void Mouse::SetLock (bool value) { + if(value) { - return SDL_SetRelativeMouseMode(SDL_TRUE); + SDL_SetRelativeMouseMode(SDL_TRUE); } else { - return SDL_SetRelativeMouseMode(SDL_FALSE); + SDL_SetRelativeMouseMode(SDL_FALSE); } }