Added global and window mouse warps
This commit is contained in:
@@ -38,6 +38,13 @@ class NativeMouse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function warpGlobal (x:Int,y:Int):Void {
|
||||||
|
|
||||||
|
return lime_mouse_warp_global (x,y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function setRelative (value:Bool):Int {
|
public static function setRelative (value:Bool):Int {
|
||||||
|
|
||||||
return lime_mouse_set_relative (value);
|
return lime_mouse_set_relative (value);
|
||||||
@@ -101,6 +108,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_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_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_set_cursor = System.load ("lime", "lime_mouse_set_cursor", 1);
|
||||||
|
|||||||
@@ -142,6 +142,17 @@ class NativeWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function warpMouse (x:Int, y:Int):Void {
|
||||||
|
|
||||||
|
if (handle != null) {
|
||||||
|
|
||||||
|
lime_window_warp_mouse (handle, x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static var lime_window_close = System.load ("lime", "lime_window_close", 1);
|
private static var lime_window_close = System.load ("lime", "lime_window_close", 1);
|
||||||
private static var lime_window_create = System.load ("lime", "lime_window_create", 5);
|
private static var lime_window_create = System.load ("lime", "lime_window_create", 5);
|
||||||
private static var lime_window_move = System.load ("lime", "lime_window_move", 3);
|
private static var lime_window_move = System.load ("lime", "lime_window_move", 3);
|
||||||
@@ -149,6 +160,7 @@ class NativeWindow {
|
|||||||
private static var lime_window_set_fullscreen = System.load ("lime", "lime_window_set_fullscreen", 2);
|
private static var lime_window_set_fullscreen = System.load ("lime", "lime_window_set_fullscreen", 2);
|
||||||
private static var lime_window_set_icon = System.load ("lime", "lime_window_set_icon", 2);
|
private static var lime_window_set_icon = System.load ("lime", "lime_window_set_icon", 2);
|
||||||
private static var lime_window_set_minimized = System.load ("lime", "lime_window_set_minimized", 2);
|
private static var lime_window_set_minimized = System.load ("lime", "lime_window_set_minimized", 2);
|
||||||
|
private static var lime_window_warp_mouse = System.load ("lime", "lime_window_warp_mouse", 3);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ class Mouse {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function warpGlobal(x:Int,y:Int):Void {
|
||||||
|
|
||||||
|
MouseBackend.warpGlobal(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
public static function setRelative(value:Bool):Int {
|
public static function setRelative(value:Bool):Int {
|
||||||
|
|
||||||
return MouseBackend.setRelative(value);
|
return MouseBackend.setRelative(value);
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ class Window {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function warpMouse(x:Int, y:Int){
|
||||||
|
|
||||||
|
backend.warpMouse(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace lime {
|
|||||||
|
|
||||||
static MouseCursor currentCursor;
|
static MouseCursor currentCursor;
|
||||||
|
|
||||||
|
static void WarpGlobal (int x, int y);
|
||||||
static int SetRelative (bool value);
|
static int SetRelative (bool value);
|
||||||
static void Hide ();
|
static void Hide ();
|
||||||
static void SetCursor (MouseCursor cursor);
|
static void SetCursor (MouseCursor cursor);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace lime {
|
|||||||
virtual bool SetFullscreen (bool fullscreen) = 0;
|
virtual bool SetFullscreen (bool fullscreen) = 0;
|
||||||
virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
|
virtual void SetIcon (ImageBuffer *imageBuffer) = 0;
|
||||||
virtual bool SetMinimized (bool minimized) = 0;
|
virtual bool SetMinimized (bool minimized) = 0;
|
||||||
|
virtual void WarpMouse (int x, int y) = 0;
|
||||||
|
|
||||||
Application* currentApplication;
|
Application* currentApplication;
|
||||||
int flags;
|
int flags;
|
||||||
|
|||||||
@@ -516,6 +516,14 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
value lime_mouse_warp_global (value x, value y) {
|
||||||
|
|
||||||
|
Mouse::WarpGlobal (val_int(x),val_int(y));
|
||||||
|
return alloc_null ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
value lime_mouse_set_relative (value input_value) {
|
value lime_mouse_set_relative (value input_value) {
|
||||||
|
|
||||||
Mouse::SetRelative (input_value);
|
Mouse::SetRelative (input_value);
|
||||||
@@ -761,6 +769,15 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
value lime_window_warp_mouse (value window, value x, value y) {
|
||||||
|
|
||||||
|
Window* targetWindow = (Window*)(intptr_t)val_float (window);
|
||||||
|
targetWindow->WarpMouse (val_int (x), val_int (y));
|
||||||
|
return alloc_null ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DEFINE_PRIM (lime_application_create, 1);
|
DEFINE_PRIM (lime_application_create, 1);
|
||||||
DEFINE_PRIM (lime_application_exec, 1);
|
DEFINE_PRIM (lime_application_exec, 1);
|
||||||
DEFINE_PRIM (lime_application_init, 1);
|
DEFINE_PRIM (lime_application_init, 1);
|
||||||
@@ -793,6 +810,7 @@ namespace lime {
|
|||||||
DEFINE_PRIM (lime_key_event_manager_register, 2);
|
DEFINE_PRIM (lime_key_event_manager_register, 2);
|
||||||
DEFINE_PRIM (lime_lzma_encode, 1);
|
DEFINE_PRIM (lime_lzma_encode, 1);
|
||||||
DEFINE_PRIM (lime_lzma_decode, 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_relative, 1);
|
||||||
DEFINE_PRIM (lime_mouse_hide, 0);
|
DEFINE_PRIM (lime_mouse_hide, 0);
|
||||||
DEFINE_PRIM (lime_mouse_set_cursor, 1);
|
DEFINE_PRIM (lime_mouse_set_cursor, 1);
|
||||||
@@ -819,6 +837,7 @@ namespace lime {
|
|||||||
DEFINE_PRIM (lime_window_set_fullscreen, 2);
|
DEFINE_PRIM (lime_window_set_fullscreen, 2);
|
||||||
DEFINE_PRIM (lime_window_set_icon, 2);
|
DEFINE_PRIM (lime_window_set_icon, 2);
|
||||||
DEFINE_PRIM (lime_window_set_minimized, 2);
|
DEFINE_PRIM (lime_window_set_minimized, 2);
|
||||||
|
DEFINE_PRIM (lime_window_warp_mouse, 3);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace lime {
|
|||||||
SDL_Cursor* SDLMouse::waitCursor = 0;
|
SDL_Cursor* SDLMouse::waitCursor = 0;
|
||||||
SDL_Cursor* SDLMouse::waitArrowCursor = 0;
|
SDL_Cursor* SDLMouse::waitArrowCursor = 0;
|
||||||
|
|
||||||
|
void Mouse::WarpGlobal(int x, int y){
|
||||||
|
|
||||||
|
SDL_WarpMouseGlobal(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Mouse::SetRelative (bool value) {
|
int Mouse::SetRelative (bool value) {
|
||||||
if(value)
|
if(value)
|
||||||
|
|||||||
@@ -146,6 +146,13 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SDLWindow::WarpMouse (int x, int y) {
|
||||||
|
|
||||||
|
SDL_WarpMouseInWindow (sdlWindow,x,y);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {
|
Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) {
|
||||||
|
|
||||||
return new SDLWindow (application, width, height, flags, title);
|
return new SDLWindow (application, width, height, flags, title);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace lime {
|
|||||||
virtual bool SetFullscreen (bool fullscreen);
|
virtual bool SetFullscreen (bool fullscreen);
|
||||||
virtual void SetIcon (ImageBuffer *imageBuffer);
|
virtual void SetIcon (ImageBuffer *imageBuffer);
|
||||||
virtual bool SetMinimized (bool minimized);
|
virtual bool SetMinimized (bool minimized);
|
||||||
|
virtual void WarpMouse (int x, int y);
|
||||||
|
|
||||||
SDL_Window* sdlWindow;
|
SDL_Window* sdlWindow;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user