diff --git a/src/graphic/Fast3D/Fast3dWindow.cpp b/src/graphic/Fast3D/Fast3dWindow.cpp index dee1739..ac96b6d 100644 --- a/src/graphic/Fast3D/Fast3dWindow.cpp +++ b/src/graphic/Fast3D/Fast3dWindow.cpp @@ -185,6 +185,10 @@ int32_t Fast3dWindow::GetPosY() { return posY; } +void Fast3dWindow::SetMousePos(Ship::Coords pos) { + mWindowManagerApi->set_mouse_pos(pos.x, pos.y); +} + Ship::Coords Fast3dWindow::GetMousePos() { int32_t x, y; mWindowManagerApi->get_mouse_pos(&x, &y); diff --git a/src/graphic/Fast3D/Fast3dWindow.h b/src/graphic/Fast3D/Fast3dWindow.h index adbd9a4..1eccdd0 100644 --- a/src/graphic/Fast3D/Fast3dWindow.h +++ b/src/graphic/Fast3D/Fast3dWindow.h @@ -20,6 +20,7 @@ class Fast3dWindow : public Ship::Window { uint32_t GetHeight() override; int32_t GetPosX() override; int32_t GetPosY() override; + void SetMousePos(Ship::Coords pos) override; Ship::Coords GetMousePos() override; Ship::Coords GetMouseDelta() override; Ship::CoordsF GetMouseWheel() override; diff --git a/src/graphic/Fast3D/gfx_dxgi.cpp b/src/graphic/Fast3D/gfx_dxgi.cpp index cf677d1..0fdefba 100644 --- a/src/graphic/Fast3D/gfx_dxgi.cpp +++ b/src/graphic/Fast3D/gfx_dxgi.cpp @@ -515,6 +515,10 @@ static void gfx_dxgi_set_cursor_visibility(bool visible) { } } +static void gfx_dxgi_set_mouse_pos(int32_t x, int32_t y) { + SetCursorPos(x, y); +} + static void gfx_dxgi_get_mouse_pos(int32_t* x, int32_t* y) { POINT p; GetCursorPos(&p); @@ -982,6 +986,7 @@ extern "C" struct GfxWindowManagerAPI gfx_dxgi_api = { gfx_dxgi_init, gfx_dxgi_set_fullscreen, gfx_dxgi_get_active_window_refresh_rate, gfx_dxgi_set_cursor_visibility, + gfx_dxgi_set_mouse_pos, gfx_dxgi_get_mouse_pos, gfx_dxgi_get_mouse_delta, gfx_dxgi_get_mouse_wheel, diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index e5be3e8..a53591d 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -440,6 +440,10 @@ static void gfx_sdl_set_cursor_visibility(bool visible) { } } +static void gfx_sdl_set_mouse_pos(int32_t x, int32_t y) { + SDL_WarpMouseInWindow(wnd, x, y); +} + static void gfx_sdl_get_mouse_pos(int32_t* x, int32_t* y) { SDL_GetMouseState(x, y); } @@ -658,6 +662,7 @@ struct GfxWindowManagerAPI gfx_sdl = { gfx_sdl_init, gfx_sdl_set_fullscreen, gfx_sdl_get_active_window_refresh_rate, gfx_sdl_set_cursor_visibility, + gfx_sdl_set_mouse_pos, gfx_sdl_get_mouse_pos, gfx_sdl_get_mouse_delta, gfx_sdl_get_mouse_wheel, diff --git a/src/graphic/Fast3D/gfx_window_manager_api.h b/src/graphic/Fast3D/gfx_window_manager_api.h index 38809cf..70f92b3 100644 --- a/src/graphic/Fast3D/gfx_window_manager_api.h +++ b/src/graphic/Fast3D/gfx_window_manager_api.h @@ -14,6 +14,7 @@ struct GfxWindowManagerAPI { void (*set_fullscreen)(bool enable); void (*get_active_window_refresh_rate)(uint32_t* refresh_rate); void (*set_cursor_visibility)(bool visible); + void (*set_mouse_pos)(int32_t x, int32_t y); void (*get_mouse_pos)(int32_t* x, int32_t* y); void (*get_mouse_delta)(int32_t* x, int32_t* y); void (*get_mouse_wheel)(float* x, float* y); diff --git a/src/window/Window.h b/src/window/Window.h index 533eaef..5da4c3c 100644 --- a/src/window/Window.h +++ b/src/window/Window.h @@ -42,6 +42,7 @@ class Window { virtual uint32_t GetHeight() = 0; virtual int32_t GetPosX() = 0; virtual int32_t GetPosY() = 0; + virtual void SetMousePos(Coords pos) = 0; virtual Coords GetMousePos() = 0; virtual Coords GetMouseDelta() = 0; virtual CoordsF GetMouseWheel() = 0;