Browse Source

engine: platform: sdl: fix incorrect mouse cursor positioning on high-dpi displays (#1623)

Signed-off-by: SheridanR <sheridan.rathbun@gmail.com>
master
Sheridan Kane Rathbun 9 months ago committed by GitHub
parent
commit
98d88266a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      engine/platform/sdl/in_sdl.c
  2. 2
      engine/platform/sdl/vid_sdl.c

11
engine/platform/sdl/in_sdl.c

@ -43,7 +43,18 @@ Platform_GetMousePos @@ -43,7 +43,18 @@ Platform_GetMousePos
*/
void GAME_EXPORT Platform_GetMousePos( int *x, int *y )
{
float factorX;
float factorY;
{
int w1, w2, h1, h2;
SDL_GL_GetDrawableSize( host.hWnd, &w1, &h1 );
SDL_GetWindowSize( host.hWnd, &w2, &h2 );
factorX = (float)w1 / w2;
factorY = (float)h1 / h2;
}
SDL_GetMouseState( x, y );
*x = *x * factorX;
*y = *y * factorY;
}
/*

2
engine/platform/sdl/vid_sdl.c

@ -576,10 +576,8 @@ static qboolean VID_SetScreenResolution( int width, int height, window_mode_t wi @@ -576,10 +576,8 @@ static qboolean VID_SetScreenResolution( int width, int height, window_mode_t wi
SDL_DisplayMode got;
Uint32 wndFlags = 0;
#if !XASH_APPLE
if( vid_highdpi.value )
SetBits( wndFlags, SDL_WINDOW_ALLOW_HIGHDPI );
#endif
SDL_SetWindowBordered( host.hWnd, SDL_FALSE );

Loading…
Cancel
Save