mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-09 05:41:46 +08:00
engine: platform: sdl2: restore scaling mouse position for hi-dpi support
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user