mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-05-30 23:44:13 +00:00
Fixed y mouse offset issue on macOS devices with camera notch.
This commit is contained in:
parent
ed8209cc35
commit
e6cfd1c970
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user