Skip to content

Commit

Permalink
Fix instant camera movement after closing the VGUI menu
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed May 28, 2024
1 parent 951a95c commit f276c45
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cl_dll/input_goldsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,11 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
mx = my = 0;
}

if (ignoreNextDelta)
{
ignoreNextDelta = false;
mx = my = 0;
}
if(pOutX) *pOutX = mx;
if(pOutY) *pOutY = my;
}
Expand Down Expand Up @@ -1580,6 +1585,7 @@ IN_Init
*/
void GoldSourceInput::IN_Init (void)
{
ignoreNextDelta = false;
m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE );
sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting.

Expand Down Expand Up @@ -1680,4 +1686,9 @@ void GoldSourceInput::IN_Init (void)
IN_StartupJoystick ();
}

void GoldSourceInput::IgnoreNextMouseDelta()
{
ignoreNextDelta = true;
}

#endif
7 changes: 6 additions & 1 deletion cl_dll/input_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ void IN_ResetMouse()
currentInput->IN_ResetMouse();
}

void IgnoreNextMouseDelta()
{
currentInput->IgnoreNextMouseDelta();
}

AbstractInput* CurrentMouseInput()
{
return currentInput;
return currentInput;
}
4 changes: 4 additions & 0 deletions cl_dll/input_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AbstractInput
virtual void IN_Init( void ) = 0;
virtual void IN_ResetMouse( void ) = 0;
virtual void Joy_AdvancedUpdate( void ) = 0;
virtual void IgnoreNextMouseDelta() = 0;
};

class FWGSInput : public AbstractInput
Expand All @@ -39,6 +40,7 @@ class FWGSInput : public AbstractInput
virtual void IN_Init( void );
virtual void IN_ResetMouse( void ) {}
virtual void Joy_AdvancedUpdate( void ) {}
virtual void IgnoreNextMouseDelta() {}

protected:
float ac_forwardmove;
Expand Down Expand Up @@ -82,6 +84,7 @@ class GoldSourceInput : public AbstractInput
virtual void IN_Init( void );
virtual void IN_ResetMouse( void );
virtual void Joy_AdvancedUpdate( void );
virtual void IgnoreNextMouseDelta();

protected:
void IN_GetMouseDelta( int *pOutX, int *pOutY);
Expand All @@ -98,6 +101,7 @@ class GoldSourceInput : public AbstractInput
int old_mouse_x, old_mouse_y, mx_accum, my_accum;
int mouseinitialized;
void* sdl2Lib;
bool ignoreNextDelta;
};
#endif

Expand Down
4 changes: 4 additions & 0 deletions cl_dll/vgui_TeamFortressViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include "screenfade.h"

void IN_SetVisibleMouse(bool visible);
void IgnoreNextMouseDelta();

class CCommandMenu;

// Scoreboard positions
Expand Down Expand Up @@ -1672,6 +1674,7 @@ void TeamFortressViewport::UpdateCursorState()
if( m_pSpectatorPanel->m_menuVisible || m_pCurrentMenu || m_pTeamMenu->isVisible() || GetClientVoiceMgr()->IsInSquelchMode() )
{
IN_SetVisibleMouse(true);
IgnoreNextMouseDelta();
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_arrow) );
return;
}
Expand All @@ -1681,6 +1684,7 @@ void TeamFortressViewport::UpdateCursorState()
if( gHUD.m_pCvarStealMouse->value != 0.0f )
{
IN_SetVisibleMouse(true);
IgnoreNextMouseDelta();
App::getInstance()->setCursorOveride( App::getInstance()->getScheme()->getCursor(Scheme::scu_arrow) );
return;
}
Expand Down
3 changes: 3 additions & 0 deletions cl_dll/vgui_TeamFortressViewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,8 @@ class CTransparentPanel : public Panel
}
};

extern void IgnoreNextMouseDelta();

//================================================================
// Menu Panel that supports buffering of menus
class CMenuPanel : public CTransparentPanel
Expand Down Expand Up @@ -1541,6 +1543,7 @@ class CMenuPanel : public CTransparentPanel

virtual void Close( void )
{
IgnoreNextMouseDelta();
setVisible( false );
m_iIsActive = false;

Expand Down

0 comments on commit f276c45

Please sign in to comment.