Fixed y mouse offset issue on macOS devices with camera notch.

This commit is contained in:
Tris 2025-12-05 14:36:23 +01:00
parent ed8209cc35
commit e6cfd1c970

View File

@ -1472,9 +1472,6 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )
}
mode.format = (Uint32)SDL_PIXELFORMAT_RGBX8888;
m_flMouseXScale = ( float )nWidth / ( float )mode.w;
m_flMouseYScale = ( float )nHeight / ( float )mode.h;
}
else
{
@ -1483,8 +1480,6 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )
mode.w = nWidth;
mode.h = nHeight;
mode.driverdata = 0;
m_flMouseXScale = 1.0f;
m_flMouseYScale = 1.0f;
}
SDL_SetWindowDisplayMode( m_Window, &mode );
@ -1531,6 +1526,31 @@ void CSDLMgr::SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight )
m_bFullScreen = bFullScreen;
}
if (bFullScreen)
{
int drawableW, drawableH;
SDL_GL_GetDrawableSize(m_Window, &drawableW, &drawableH);
if ( drawableW > 0 && drawableH > 0 )
{
// Use drawable size for accurate mouse scaling, including macOS devices
// with camera notch
m_flMouseXScale = (float)nWidth / (float)drawableW;
m_flMouseYScale = (float)nHeight / (float)drawableH;
}
else {
// Fallback to mode dimensions if drawable size unavailable
m_flMouseXScale = (float)nWidth / (float)mode.w;
m_flMouseYScale = (float)nHeight / (float)mode.h;
}
}
else
{
// Use 1:1 scaling for windowed mode
m_flMouseXScale = 1.0f;
m_flMouseYScale = 1.0f;
}
}