mirror of
https://github.com/ENSL/NS.git
synced 2024-11-21 20:21:14 +00:00
fix view spin when disabling the cursor
-revisit this when HL25 SDK is released
This commit is contained in:
parent
56512a8f45
commit
abef5c5cca
3 changed files with 55 additions and 23 deletions
|
@ -105,6 +105,9 @@ int mouseinitialized;
|
|||
static int mouseparmsvalid;
|
||||
static int mouseshowtoggle = 1;
|
||||
|
||||
////2024 - Added to fix view spin when disabling the cursor.
|
||||
static bool cursorDisabledThisFrame = false;
|
||||
|
||||
// joystick defines and variables
|
||||
// where should defines be moved?
|
||||
#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
|
||||
|
@ -312,7 +315,21 @@ void IN_SetVisibleMouse(bool visible)
|
|||
|
||||
g_iVisibleMouse = visible;
|
||||
|
||||
IN_SetMouseMode(!visible);
|
||||
////2024 - Disabled this as SDL mouse mode is handled per use of UIManager::SetMouseVisibility to fix edge case bugs with centering and showing/not showing cursor in game and in the escape menu.
|
||||
//IN_SetMouseMode(!visible);
|
||||
|
||||
//2024 - Added to fix view spin when disabling the cursor. Reassess after new SDK is released.
|
||||
cursorDisabledThisFrame = (!visible);
|
||||
|
||||
////2024 - Move centering here?
|
||||
//if (visible && gHUD.m_bWindowed)
|
||||
//{
|
||||
// gEngfuncs.pfnSetMousePos(ScreenWidth() / 2, ScreenHeight() / 2);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// gEngfuncs.pfnSetMousePos(gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY());
|
||||
//}
|
||||
|
||||
#ifdef _WIN32
|
||||
UpdateMouseThreadActive();
|
||||
|
@ -642,6 +659,14 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
mx = deltaX + mx_accum;
|
||||
my = deltaY + my_accum;
|
||||
}
|
||||
//2024 - Added to fix view spin when disabling the cursor.
|
||||
if (cursorDisabledThisFrame)
|
||||
{
|
||||
mx = 0;
|
||||
my = 0;
|
||||
|
||||
cursorDisabledThisFrame = false;
|
||||
}
|
||||
|
||||
mx_accum = 0;
|
||||
my_accum = 0;
|
||||
|
@ -756,7 +781,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gEngfuncs.SetViewAngles( (float *)viewangles );
|
||||
|
||||
/*
|
||||
|
@ -801,7 +826,7 @@ void CL_DLLEXPORT IN_Accumulate (void)
|
|||
int deltaX, deltaY;
|
||||
SDL_GetRelativeMouseState( &deltaX, &deltaY );
|
||||
mx_accum += deltaX;
|
||||
my_accum += deltaY;
|
||||
my_accum += deltaY;
|
||||
}
|
||||
|
||||
// force the mouse to the center, so there's room to move
|
||||
|
|
|
@ -79,7 +79,7 @@ PieMenu* AvHPieMenuHandler::GetActivePieMenu()
|
|||
|
||||
void AvHPieMenuHandler::ClosePieMenu(void)
|
||||
{
|
||||
|
||||
|
||||
//if (!sPieMenuOpen)
|
||||
//{
|
||||
// return;
|
||||
|
@ -138,7 +138,7 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
|
|||
if(!gHUD.GetInTopDownMode())
|
||||
{
|
||||
gHUD.GetManager().SetMouseVisibility(false);
|
||||
|
||||
|
||||
// OS cursor displaying over in game cursor fix. Remove if showcursor code in SetMouseVisibility is made bug free.
|
||||
#ifdef WIN32
|
||||
if(sPieMenuOpen)
|
||||
|
@ -153,11 +153,12 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
|
|||
}
|
||||
sLastNodeHighlighted = NULL;
|
||||
|
||||
// Return to raw input after menu closes
|
||||
if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
}
|
||||
//// Not needed post-HL25.
|
||||
//// Return to raw input after menu closes
|
||||
//if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
|
||||
//{
|
||||
// SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
//}
|
||||
|
||||
// if(sTheDebugBool)
|
||||
// {
|
||||
|
@ -199,10 +200,11 @@ void AvHPieMenuHandler::OpenPieMenu(void)
|
|||
|
||||
gHUD.HideCrosshair();
|
||||
|
||||
// Workaround for not being able to center mouse with raw input enabled.
|
||||
// Center mouse for raw input.
|
||||
if (CVAR_GET_FLOAT("m_rawinput") != 0 && !sPieMenuOpen)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
//// Not needed post-HL25.
|
||||
//SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
|
||||
if (gHUD.m_bWindowed)
|
||||
{
|
||||
|
@ -299,13 +301,15 @@ void AvHPieMenuHandler::cursorMoved(int x,int y,Panel* panel)
|
|||
// char theMessage[128];
|
||||
// sprintf(theMessage, "AvHPieMenuHandler::cursorMoved %d, %d (panel ptr: %d).\n", x, y, (int)panel);
|
||||
// CenterPrint(theMessage);
|
||||
if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
|
||||
{
|
||||
if (SDL_GetRelativeMouseMode() != SDL_TRUE)
|
||||
{
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
//// Not needed post-HL25.
|
||||
//if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
|
||||
//{
|
||||
// if (SDL_GetRelativeMouseMode() != SDL_TRUE)
|
||||
// {
|
||||
// SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void AvHPieMenuHandler::cursorEntered(Panel* panel)
|
||||
|
|
|
@ -27,6 +27,7 @@ extern "C"
|
|||
void* VGui_GetPanel();
|
||||
}
|
||||
extern int g_iVisibleMouse;
|
||||
void IN_SetVisibleMouse(bool visible);
|
||||
|
||||
UIManager::UIManager(UIFactory* inFactory)
|
||||
{
|
||||
|
@ -295,12 +296,14 @@ bool UIManager::SetLMBActionRelative(const TRTag& inTag)
|
|||
void UIManager::SetMouseVisibility(bool inState)
|
||||
{
|
||||
// 2021 - Check if we need to run code. Prevents showcursor from incrementing or decrementing outside of useful range.
|
||||
int NewDesiredState = (inState) ? 1 : 0;
|
||||
int newDesiredState = (inState) ? 1 : 0;
|
||||
|
||||
if (g_iVisibleMouse != NewDesiredState)
|
||||
if (g_iVisibleMouse != newDesiredState)
|
||||
{
|
||||
// To change whether the mouse is visible, just change this variable
|
||||
g_iVisibleMouse = NewDesiredState;
|
||||
//g_iVisibleMouse = newDesiredState;
|
||||
//2024 - Using this to fix view spin on reactivation in HL25. SDL mouse modes are changed alongside the use of SetMouseVisibility instead of in this function so the cursor doesn't disappear in the escape menu.
|
||||
IN_SetVisibleMouse(newDesiredState);
|
||||
|
||||
// Update cursor
|
||||
if(g_iVisibleMouse)
|
||||
|
@ -326,7 +329,7 @@ void UIManager::SetMouseVisibility(bool inState)
|
|||
// Move mouse to center of screen so mouse look isn't changed
|
||||
|
||||
// Only do this when in full screen
|
||||
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
|
||||
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
|
||||
|
||||
// Hide cursor again
|
||||
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) );
|
||||
|
|
Loading…
Reference in a new issue