Skip to content
Snippets Groups Projects
Commit caadf6aa authored by LJ Sonic's avatar LJ Sonic
Browse files

Let the mouse move freely when a menu is open or game is paused

That means you can now easily move your mouse out of SRB2's window
and switch between several windows easily by just pressing escape!

Any phase of the game that isn't actual gameplay counts as a menu,
which means you can also move the mouse in cutscenes,
at the title screen, server connection screen,
and even when the chat or console are open.
parent 27285365
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@
#include "../s_sound.h"
#include "../i_joy.h"
#include "../st_stuff.h"
#include "../hu_stuff.h"
#include "../g_game.h"
#include "../i_video.h"
#include "../console.h"
......@@ -108,6 +109,7 @@ static SDL_bool disable_fullscreen = SDL_FALSE;
#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?0:cv_fullscreen.value
static SDL_bool disable_mouse = SDL_FALSE;
#define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && havefocus)
#define IGNORE_MOUSE (menuactive || paused || con_destlines || chat_on || gamestate != GS_LEVEL)
#define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN)
#define MOUSEBUTTONS_MAX MOUSEBUTTONS
......@@ -590,7 +592,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
}
//else firsttimeonmouse = SDL_FALSE;
if (USE_MOUSEINPUT)
if (USE_MOUSEINPUT && !IGNORE_MOUSE)
SDLdoGrabMouse();
}
else if (!mousefocus && !kbfocus)
......@@ -639,7 +641,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
{
if (USE_MOUSEINPUT)
{
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window))
if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || IGNORE_MOUSE)
{
SDLdoUngrabMouse();
return;
......@@ -687,7 +689,7 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
// this apparently makes a mouse button down event but not a mouse button up event,
// resulting in whatever key was pressed down getting "stuck" if we don't ignore it.
// -- Monster Iestyn (28/05/18)
if (SDL_GetMouseFocus() != window)
if (SDL_GetMouseFocus() != window || IGNORE_MOUSE)
return;
/// \todo inputEvent.button.which
......@@ -1069,7 +1071,7 @@ void I_StartupMouse(void)
}
else
firsttimeonmouse = SDL_FALSE;
if (cv_usemouse.value)
if (cv_usemouse.value && !IGNORE_MOUSE)
SDLdoGrabMouse();
else
SDLdoUngrabMouse();
......@@ -1702,12 +1704,7 @@ void I_StartupGraphics(void)
SDL_RaiseWindow(window);
if (mousegrabok && !disable_mouse)
{
SDL_ShowCursor(SDL_DISABLE);
SDL_SetRelativeMouseMode(SDL_TRUE);
wrapmouseok = SDL_TRUE;
SDL_SetWindowGrab(window, SDL_TRUE);
}
SDLdoGrabMouse();
graphics_started = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment