From a858719a4b5a170504b07a9a4e0f1e5294aba5c5 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 8 Dec 2025 19:05:13 +0500 Subject: [PATCH] engine: platform: sdl2: restore scaling mouse position for hi-dpi support --- engine/platform/sdl2/in_sdl2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/platform/sdl2/in_sdl2.c b/engine/platform/sdl2/in_sdl2.c index 9d977089..44839159 100644 --- a/engine/platform/sdl2/in_sdl2.c +++ b/engine/platform/sdl2/in_sdl2.c @@ -44,6 +44,12 @@ Platform_GetMousePos void GAME_EXPORT Platform_GetMousePos( int *x, int *y ) { SDL_GetMouseState( x, y ); + + if( x ) + *x *= refState.scale_x; + + if( y ) + *y *= refState.scale_y; } /* @@ -208,7 +214,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) // restore the last mouse position if( in_visible_cursor_pos.pushed ) { - SDL_WarpMouseInWindow( host.hWnd, in_visible_cursor_pos.x, in_visible_cursor_pos.y ); + Platform_SetMousePos( in_visible_cursor_pos.x, in_visible_cursor_pos.y ); in_visible_cursor_pos.pushed = false; } } @@ -218,7 +224,7 @@ void Platform_SetCursorType( VGUI_DefaultCursor type ) if( !in_visible_cursor_pos.pushed ) { SDL_GetMouseState( &in_visible_cursor_pos.x, &in_visible_cursor_pos.y ); - SDL_WarpMouseInWindow( host.hWnd, host.window_center_x, host.window_center_y ); + Platform_SetMousePos( host.window_center_x, host.window_center_y ); in_visible_cursor_pos.pushed = true; }