From fcadd03607bd4eea0168229ca6fd0cabf793a59e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Sep 2025 18:51:44 +0200 Subject: [PATCH] add back toggle for mouse cursor visability behaviour --- src/d_netcmd.c | 4 +++- src/d_netcmd.h | 1 + src/m_menudefs.c | 3 +++ src/sdl/i_video.c | 9 +++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4c189a1cc..5ac858fb5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -277,7 +277,8 @@ consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, INT32 cv_debug; static void UseMouse_OnChange(void); -consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL, usemouse_cons_t, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mousevisible = {"mousevisible", "Off", CV_SAVE|CV_CALL, CV_OnOff, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; static void UseMouse_OnChange(void) { @@ -1004,6 +1005,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invertmouse); CV_RegisterVar(&cv_mousesens); CV_RegisterVar(&cv_mouseysens); + CV_RegisterVar(&cv_mousevisible); // s_sound.c CV_RegisterVar(&cv_soundvolume); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 1078de5d2..098de925e 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -50,6 +50,7 @@ extern consvar_t cv_splitplayers; extern consvar_t cv_seenames, cv_allowseenames; #endif extern consvar_t cv_usemouse; +extern consvar_t cv_mousevisible; //WTF extern consvar_t cv_mouseturn; extern consvar_t cv_usejoystick[4]; //MAXSPLITSCREENPLAYERS diff --git a/src/m_menudefs.c b/src/m_menudefs.c index bbed87c90..d3d95a296 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1180,6 +1180,8 @@ static menuitem_t OP_FocusOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Background FPS Cap", &cv_fpscapbg, 80}, {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100}, + + {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120}, }; static const char* OP_FocusOptionsTooltips[] = @@ -1190,6 +1192,7 @@ static const char* OP_FocusOptionsTooltips[] = "Should the game pause while the game is unfocused?", "Set manual framerate cap while the game is unfocused.", "Should the FOCUS LOST window appear\n while the game is unfocused?", + "Displays the mouse cursor while the game is in focus.", }; static menuitem_t OP_DataOptionsMenu[] = diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 159b49d7a..7a6cb1743 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -613,7 +613,8 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) case SDL_WINDOWEVENT_FOCUS_GAINED: kbfocus = SDL_TRUE; mousefocus = SDL_TRUE; - SDL_ShowCursor(SDL_FALSE); + if (!cv_mousevisible.value) + SDL_ShowCursor(SDL_FALSE); break; case SDL_WINDOWEVENT_FOCUS_LOST: kbfocus = SDL_FALSE; @@ -1195,7 +1196,11 @@ void I_StartupMouse(void) if (disable_mouse) return; - SDL_ShowCursor(SDL_FALSE); + if (!cv_mousevisible.value) + SDL_ShowCursor(SDL_FALSE); + else + SDL_ShowCursor(SDL_TRUE); + SDL_SetWindowGrab(window, SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE); }