Skip to content

Commit

Permalink
Port fix for getting mouse stuck in box
Browse files Browse the repository at this point in the history
Apparently, the problem is caused by this issue:
ValveSoftware/halflife#1377

Which Solokiller has a fix for:
twhl-community/halflife-updated@92ffa23

But seems to be originated from L453rh4wk:
ValveSoftware/halflife#1546 (comment)
  • Loading branch information
MegaBrutal committed Mar 11, 2022
1 parent 8570d26 commit 5f31297
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cl_dll/inputw32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ DWORD s_hMouseThreadId = 0;
HANDLE s_hMouseThread = 0;
HANDLE s_hMouseQuitEvent = 0;
HANDLE s_hMouseDoneQuitEvent = 0;
SDL_bool mouseRelative = SDL_TRUE;
#endif

/*
Expand Down Expand Up @@ -235,6 +236,21 @@ void DLLEXPORT IN_ActivateMouse (void)
#endif
mouseactive = 1;
}

#ifdef _WIN32
if (!m_bRawInput)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
mouseRelative = SDL_FALSE;
}
else
{
mouseRelative = SDL_TRUE;
SDL_SetRelativeMouseMode(SDL_TRUE);
}
#else
SDL_SetRelativeMouseMode(SDL_TRUE);
#endif
}


Expand All @@ -255,6 +271,15 @@ void DLLEXPORT IN_DeactivateMouse (void)

mouseactive = 0;
}

#ifdef _WIN32
if (m_bRawInput)
{
mouseRelative = SDL_FALSE;
}

#endif
SDL_SetRelativeMouseMode(SDL_FALSE);
}

/*
Expand Down Expand Up @@ -572,6 +597,19 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd)

gEngfuncs.SetViewAngles( (float *)viewangles );

#ifdef _WIN32
if (!m_bRawInput && mouseRelative)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
mouseRelative = SDL_FALSE;
}
else if (m_bRawInput && !mouseRelative)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
mouseRelative = SDL_TRUE;
}
#endif

/*
//#define TRACE_TEST
#if defined( TRACE_TEST )
Expand Down

0 comments on commit 5f31297

Please sign in to comment.