mirror of
https://github.com/izzy2lost/libultraship.git
synced 2026-06-19 01:16:13 -07:00
Implemented SetMousePos (#738)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user