diff --git a/lime/_backend/flash/FlashMouse.hx b/lime/_backend/flash/FlashMouse.hx index 643327d8d..d24372953 100644 --- a/lime/_backend/flash/FlashMouse.hx +++ b/lime/_backend/flash/FlashMouse.hx @@ -38,6 +38,10 @@ class FlashMouse { } + public static function setRelative (value:Bool):Int{ + + return -1; + } diff --git a/lime/_backend/html5/HTML5Mouse.hx b/lime/_backend/html5/HTML5Mouse.hx index 583fa380b..578c4dab2 100644 --- a/lime/_backend/html5/HTML5Mouse.hx +++ b/lime/_backend/html5/HTML5Mouse.hx @@ -30,6 +30,11 @@ class HTML5Mouse { } } + + public static function setRelative (value:Bool):Int{ + + return -1; + } public static function show ():Void { diff --git a/lime/_backend/native/NativeMouse.hx b/lime/_backend/native/NativeMouse.hx index f42191631..13bf5d379 100644 --- a/lime/_backend/native/NativeMouse.hx +++ b/lime/_backend/native/NativeMouse.hx @@ -38,6 +38,11 @@ class NativeMouse { } + public static function setRelative (value:Bool):Int { + + return lime_mouse_set_relative (value); + + } // Get & Set Methods @@ -76,7 +81,7 @@ class NativeMouse { } - lime_mouse_set_cursor (type); + lime_mouse_set_cursor (value); } @@ -96,6 +101,7 @@ class NativeMouse { + private static var lime_mouse_set_relative = System.load ("lime", "lime_mouse_set_relative", 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 2bd2beaf4..e3eaae6c9 100644 --- a/lime/ui/Mouse.hx +++ b/lime/ui/Mouse.hx @@ -5,6 +5,8 @@ class Mouse { public static var cursor (get, set):MouseCursor; + + // public static var relative (default, set):Bool = false; public static function hide ():Void { @@ -20,13 +22,14 @@ class Mouse { } - - - + public static function setRelative(value:Bool):Int { + + return MouseBackend.setRelative(value); + } + // Get & Set Methods - - + private static function get_cursor ():MouseCursor { diff --git a/project/include/ui/Mouse.h b/project/include/ui/Mouse.h index f444b6b89..1cd4472c8 100644 --- a/project/include/ui/Mouse.h +++ b/project/include/ui/Mouse.h @@ -14,6 +14,7 @@ namespace lime { static MouseCursor currentCursor; + static int SetRelative (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 762800821..0789a11e3 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -516,6 +516,14 @@ namespace lime { } + value lime_mouse_set_relative (value input_value) { + + Mouse::SetRelative (input_value); + return alloc_null (); + + } + + value lime_mouse_set_cursor (value cursor) { Mouse::SetCursor ((MouseCursor)val_int (cursor)); @@ -785,6 +793,7 @@ namespace lime { DEFINE_PRIM (lime_key_event_manager_register, 2); DEFINE_PRIM (lime_lzma_encode, 1); DEFINE_PRIM (lime_lzma_decode, 1); + DEFINE_PRIM (lime_mouse_set_relative, 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 0c11d7be1..ef7916017 100644 --- a/project/src/backend/sdl/SDLMouse.cpp +++ b/project/src/backend/sdl/SDLMouse.cpp @@ -17,6 +17,18 @@ namespace lime { SDL_Cursor* SDLMouse::textCursor = 0; SDL_Cursor* SDLMouse::waitCursor = 0; SDL_Cursor* SDLMouse::waitArrowCursor = 0; + + + int Mouse::SetRelative (bool value) { + if(value) + { + return SDL_SetRelativeMouseMode(SDL_TRUE); + } + else + { + return SDL_SetRelativeMouseMode(SDL_FALSE); + } + } void Mouse::Hide () {