Added SetRelative function to lime.Mouse to allow for locking the mouse to the screen in native.
This commit is contained in:
@@ -38,6 +38,10 @@ class FlashMouse {
|
||||
|
||||
}
|
||||
|
||||
public static function setRelative (value:Bool):Int{
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@ class HTML5Mouse {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function setRelative (value:Bool):Int{
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public static function show ():Void {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user