Skip to content

Commit

Permalink
Fix mouse cursor being invisible in VGUI1 menus when raw input is ena…
Browse files Browse the repository at this point in the history
…bled

Resolves #211
  • Loading branch information
SamVanheer committed Aug 15, 2023
1 parent a1cf2d3 commit 2d35ca7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

* Fixed hand grenade animations not playing correctly [#209](https://github.com/SamVanheer/halflife-updated/pull/209) (Thanks Toodles2You)
* Fixed out of bounds access in studiomodel renderer bone setup code (halflife issue [#3360](https://github.com/ValveSoftware/halflife/issues/3360))
* Fixed mouse cursor being invisible in VGUI1 menus when raw input is enabled [#211](https://github.com/SamVanheer/halflife-updated/issues/211) (Thanks RykahKnight)

### Features

Expand Down
48 changes: 22 additions & 26 deletions cl_dll/inputw32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ static bool IN_UseRawInput()
return m_rawinput->value != 0;
}

static SDL_bool mouseRelative = SDL_TRUE;

static void IN_SetMouseRelative(bool enable)
{
const SDL_bool value = enable ? SDL_TRUE : SDL_FALSE;

SDL_SetRelativeMouseMode(value);
mouseRelative = value;
}

static bool m_bMouseThread = false;

// mouse variables
Expand Down Expand Up @@ -192,8 +202,6 @@ struct MouseThread

MouseThread s_MouseThread;

SDL_bool mouseRelative = SDL_TRUE;

std::atomic<Point> s_mouseDelta;
std::atomic<Point> current_pos;
std::atomic<Point> old_mouse_pos;
Expand Down Expand Up @@ -261,20 +269,18 @@ void DLLEXPORT IN_ActivateMouse()
mouseactive = true;
}

if (g_iVisibleMouse
#ifdef WIN32
if (!IN_UseRawInput())
|| !IN_UseRawInput()
#endif
)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
mouseRelative = SDL_FALSE;
IN_SetMouseRelative(false);
}
else
{
mouseRelative = SDL_TRUE;
SDL_SetRelativeMouseMode(SDL_TRUE);
IN_SetMouseRelative(true);
}
#else
SDL_SetRelativeMouseMode(SDL_TRUE);
#endif
}


Expand All @@ -296,14 +302,7 @@ void DLLEXPORT IN_DeactivateMouse()
mouseactive = false;
}

#ifdef WIN32
if (IN_UseRawInput())
{
mouseRelative = SDL_FALSE;
}

#endif
SDL_SetRelativeMouseMode(SDL_FALSE);
IN_SetMouseRelative(false);
}

/*
Expand Down Expand Up @@ -390,10 +389,9 @@ void IN_ResetMouse()
{
// no work to do in SDL
#ifdef WIN32
if (IN_UseRawInput())
if (IN_UseRawInput() && !g_iVisibleMouse)
{
mouseRelative = SDL_TRUE;
SDL_SetRelativeMouseMode(SDL_TRUE);
IN_SetMouseRelative(true);
}

if (!IN_UseRawInput() && mouseactive && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY)
Expand Down Expand Up @@ -604,15 +602,13 @@ void IN_MouseMove(float frametime, usercmd_t* cmd)
gEngfuncs.SetViewAngles((float*)viewangles);

#ifdef WIN32
if (!IN_UseRawInput() && SDL_FALSE != mouseRelative)
if ((!IN_UseRawInput() && SDL_FALSE != mouseRelative) || g_iVisibleMouse)
{
SDL_SetRelativeMouseMode(SDL_FALSE);
mouseRelative = SDL_FALSE;
IN_SetMouseRelative(false);
}
else if (IN_UseRawInput() && SDL_FALSE == mouseRelative)
{
SDL_SetRelativeMouseMode(SDL_TRUE);
mouseRelative = SDL_TRUE;
IN_SetMouseRelative(true);
}
#endif

Expand Down

0 comments on commit 2d35ca7

Please sign in to comment.