fix mouse centering for windowed mode

This commit is contained in:
pierow 2023-09-15 12:47:53 -04:00
parent e241e23752
commit f9a8db4963
5 changed files with 11 additions and 5 deletions

View file

@ -185,7 +185,9 @@ void ScorePanel::HitTestPanel::internalMousePressed(MouseCode code)
if (SDL_GetRelativeMouseMode() == SDL_TRUE)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//Fix for windowed mode centering being incorrect.
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
//#ifdef WIN32
//ShowCursor(FALSE);

View file

@ -1524,7 +1524,8 @@ void TeamFortressViewport::HideOptionsMenu()
gHUD.GetManager().SetMouseVisibility(false);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
}
}

View file

@ -2881,7 +2881,8 @@ int AvHHud::MsgFunc_SetTopDown(const char* pszName, int iSize, void* pbuf)
if (CVAR_GET_FLOAT("m_rawinput") != 0)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
#ifdef WIN32
//Hide windows OS cursor while raw input is momentarily off.

View file

@ -90,7 +90,8 @@ void AvHParticleEditorHandler::ToggleEdit()
gHUD.ToggleMouse();
// Set mouse position to center so it doesn't jar our view
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
sInEditMode = false;
}

View file

@ -203,7 +203,8 @@ void AvHPieMenuHandler::OpenPieMenu(void)
if (CVAR_GET_FLOAT("m_rawinput") != 0 && !sPieMenuOpen)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
//gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
}
// Only do this when in full screen