Skip to content

Commit

Permalink
Merge pull request #32 from IntriguingTiles/fix/raw-mouse
Browse files Browse the repository at this point in the history
Fix camera not being consistently centered when raw mouse input is enabled
  • Loading branch information
Solokiller authored Aug 24, 2021
2 parents c2902f8 + 49ecab8 commit d872ad0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cl_dll/inputw32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,25 @@ void IN_ResetMouse()
{
// no work to do in SDL
#ifdef _WIN32
if ( gpGlobals && ( gpGlobals->time - s_flRawInputUpdateTime > 1.0f || s_flRawInputUpdateTime == 0.0f ) )
{
s_flRawInputUpdateTime = gpGlobals->time;
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;

if ( m_bRawInput )
{
mouseRelative = SDL_TRUE;
SDL_SetRelativeMouseMode( SDL_TRUE );
}
}

if ( !m_bRawInput && mouseactive && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY )
{

SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() );
ThreadInterlockedExchange( &old_mouse_pos.x, gEngfuncs.GetWindowCenterX() );
ThreadInterlockedExchange( &old_mouse_pos.y, gEngfuncs.GetWindowCenterY() );
}

if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f )
{
s_flRawInputUpdateTime = gpGlobals->time;
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
}
#endif
}

Expand Down

0 comments on commit d872ad0

Please sign in to comment.