mirror of
https://github.com/ENSL/NS.git
synced 2024-11-28 23:32:04 +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 mouseparmsvalid;
|
||||||
static int mouseshowtoggle = 1;
|
static int mouseshowtoggle = 1;
|
||||||
|
|
||||||
|
////2024 - Added to fix view spin when disabling the cursor.
|
||||||
|
static bool cursorDisabledThisFrame = false;
|
||||||
|
|
||||||
// joystick defines and variables
|
// joystick defines and variables
|
||||||
// where should defines be moved?
|
// where should defines be moved?
|
||||||
#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
|
#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick
|
||||||
|
@ -312,7 +315,21 @@ void IN_SetVisibleMouse(bool visible)
|
||||||
|
|
||||||
g_iVisibleMouse = 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
|
#ifdef _WIN32
|
||||||
UpdateMouseThreadActive();
|
UpdateMouseThreadActive();
|
||||||
|
@ -642,6 +659,14 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY)
|
||||||
mx = deltaX + mx_accum;
|
mx = deltaX + mx_accum;
|
||||||
my = deltaY + my_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;
|
mx_accum = 0;
|
||||||
my_accum = 0;
|
my_accum = 0;
|
||||||
|
|
|
@ -153,11 +153,12 @@ void AvHPieMenuHandler::InternalClosePieMenu(void)
|
||||||
}
|
}
|
||||||
sLastNodeHighlighted = NULL;
|
sLastNodeHighlighted = NULL;
|
||||||
|
|
||||||
// Return to raw input after menu closes
|
//// Not needed post-HL25.
|
||||||
if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
|
//// Return to raw input after menu closes
|
||||||
{
|
//if (CVAR_GET_FLOAT("m_rawinput") != 0 && sPieMenuOpen)
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
//{
|
||||||
}
|
// SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
//}
|
||||||
|
|
||||||
// if(sTheDebugBool)
|
// if(sTheDebugBool)
|
||||||
// {
|
// {
|
||||||
|
@ -199,10 +200,11 @@ void AvHPieMenuHandler::OpenPieMenu(void)
|
||||||
|
|
||||||
gHUD.HideCrosshair();
|
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)
|
if (CVAR_GET_FLOAT("m_rawinput") != 0 && !sPieMenuOpen)
|
||||||
{
|
{
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
//// Not needed post-HL25.
|
||||||
|
//SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
|
||||||
if (gHUD.m_bWindowed)
|
if (gHUD.m_bWindowed)
|
||||||
{
|
{
|
||||||
|
@ -299,13 +301,15 @@ void AvHPieMenuHandler::cursorMoved(int x,int y,Panel* panel)
|
||||||
// char theMessage[128];
|
// char theMessage[128];
|
||||||
// sprintf(theMessage, "AvHPieMenuHandler::cursorMoved %d, %d (panel ptr: %d).\n", x, y, (int)panel);
|
// sprintf(theMessage, "AvHPieMenuHandler::cursorMoved %d, %d (panel ptr: %d).\n", x, y, (int)panel);
|
||||||
// CenterPrint(theMessage);
|
// CenterPrint(theMessage);
|
||||||
if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
|
|
||||||
{
|
//// Not needed post-HL25.
|
||||||
if (SDL_GetRelativeMouseMode() != SDL_TRUE)
|
//if (sPieMenuOpen && CVAR_GET_FLOAT("m_rawinput") != 0)
|
||||||
{
|
//{
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
// if (SDL_GetRelativeMouseMode() != SDL_TRUE)
|
||||||
}
|
// {
|
||||||
}
|
// SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvHPieMenuHandler::cursorEntered(Panel* panel)
|
void AvHPieMenuHandler::cursorEntered(Panel* panel)
|
||||||
|
|
|
@ -27,6 +27,7 @@ extern "C"
|
||||||
void* VGui_GetPanel();
|
void* VGui_GetPanel();
|
||||||
}
|
}
|
||||||
extern int g_iVisibleMouse;
|
extern int g_iVisibleMouse;
|
||||||
|
void IN_SetVisibleMouse(bool visible);
|
||||||
|
|
||||||
UIManager::UIManager(UIFactory* inFactory)
|
UIManager::UIManager(UIFactory* inFactory)
|
||||||
{
|
{
|
||||||
|
@ -295,12 +296,14 @@ bool UIManager::SetLMBActionRelative(const TRTag& inTag)
|
||||||
void UIManager::SetMouseVisibility(bool inState)
|
void UIManager::SetMouseVisibility(bool inState)
|
||||||
{
|
{
|
||||||
// 2021 - Check if we need to run code. Prevents showcursor from incrementing or decrementing outside of useful range.
|
// 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
|
// 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
|
// Update cursor
|
||||||
if(g_iVisibleMouse)
|
if(g_iVisibleMouse)
|
||||||
|
@ -326,7 +329,7 @@ void UIManager::SetMouseVisibility(bool inState)
|
||||||
// Move mouse to center of screen so mouse look isn't changed
|
// Move mouse to center of screen so mouse look isn't changed
|
||||||
|
|
||||||
// Only do this when in full screen
|
// Only do this when in full screen
|
||||||
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
|
App::getInstance()->setCursorPos(ScreenWidth()/2, ScreenHeight()/2);
|
||||||
|
|
||||||
// Hide cursor again
|
// Hide cursor again
|
||||||
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) );
|
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_none) );
|
||||||
|
|
Loading…
Reference in a new issue