Skip to content

Commit

Permalink
Handle UI mouse option changes in full-screen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Jan 15, 2023
1 parent 7bde2bf commit b014af0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Quake/in_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ void IN_Deactivate (qboolean free_cursor)

if (free_cursor)
IN_ShowCursor();
else
IN_HideCursor();

/* discard all mouse events when input is deactivated */
IN_BeginIgnoringMouseEvents();
Expand Down
33 changes: 33 additions & 0 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern qboolean quake64;
enum m_state_e m_state;
extern qboolean keydown[256];
int m_mousex, m_mousey;
qboolean m_ignoremouseframe;
static int m_left, m_top, m_width, m_height;

static void M_UpdateBounds (void);
Expand Down Expand Up @@ -5849,6 +5850,31 @@ void M_Menu_Credits_f (void)
//=============================================================================
/* Menu Subsystem */

static void UI_Mouse_f (cvar_t *cvar)
{
// Ignore first mouse move message after we re-enable the option.
// This makes it possible to cycle through the UI Mouse options
// in full-screen mode using the keyboard without having the
// selected item change due to the automatic mouse move message
// sent when the cursor is shown again.
m_ignoremouseframe = true;

switch (key_dest)
{
case key_menu:
IN_DeactivateForMenu ();
break;
case key_console:
IN_DeactivateForConsole ();
break;
case key_game:
case key_message:
IN_Activate ();
break;
default:
break;
}
}

void M_Init (void)
{
Expand All @@ -5870,6 +5896,7 @@ void M_Init (void)
Cmd_AddCommand ("menu_maps", M_Menu_Maps_f);

Cvar_RegisterVariable (&ui_mouse);
Cvar_SetCallback (&ui_mouse, UI_Mouse_f);
Cvar_RegisterVariable (&ui_mouse_sound);
Cvar_RegisterVariable (&ui_sound_throttle);
Cvar_RegisterVariable (&ui_search_timeout);
Expand Down Expand Up @@ -6129,6 +6156,12 @@ void M_Mousemove (int x, int y)
m_mousex = x = (int) (px + 0.5f);
m_mousey = y = (int) (py + 0.5f);

if (m_ignoremouseframe)
{
m_ignoremouseframe = false;
return;
}

switch (m_state)
{
default:
Expand Down

0 comments on commit b014af0

Please sign in to comment.