diff --git a/src/i_video.c b/src/i_video.c index f8a7d698..6fc4b742 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -200,33 +200,20 @@ static void UpdateGrab(void) if (!grab && currently_grabbed) { + int w, h; + SetShowCursor(true); + + SDL_GetWindowSize(screen, &w, &h); + SDL_WarpMouseInWindow(screen, 3 * w / 4, 4 * h / 5); } currently_grabbed = grab; } -void I_ShowMouseCursor(boolean on) +void I_ShowMouseCursor(boolean toggle) { - static boolean state = true; - - if (state == on) - { - return; - } - else - { - state = on; - } - - if (on) - { - int w, h; - SDL_GetWindowSize(screen, &w, &h); - SDL_WarpMouseInWindow(screen, w / 2, h / 2); - } - - SDL_ShowCursor(on); + SDL_ShowCursor(toggle); } void I_ResetRelativeMouseState(void) diff --git a/src/i_video.h b/src/i_video.h index 1daf216d..29ca37b5 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -109,7 +109,7 @@ void *I_GetSDLRenderer(void); void I_InitWindowIcon(void); -void I_ShowMouseCursor(boolean on); +void I_ShowMouseCursor(boolean toggle); void I_ResetRelativeMouseState(void); #endif diff --git a/src/mn_menu.c b/src/mn_menu.c index ca755001..370ea62d 100644 --- a/src/mn_menu.c +++ b/src/mn_menu.c @@ -2327,7 +2327,7 @@ static boolean ShortcutResponder(const event_t *ev) return false; } -menu_input_mode_t menu_input; +menu_input_mode_t menu_input, old_menu_input; static int mouse_state_x, mouse_state_y; @@ -2442,6 +2442,23 @@ static boolean SaveLoadResponder(menu_action_t action, int ch) return false; } +void MN_ResetMouseCursor(void) +{ + static boolean state; + + if (menu_input == mouse_mode && !state) + { + state = true; + I_ShowMouseCursor(true); + } + else if (menu_input != mouse_mode && state) + { + state = false; + ClearHighlightedItems(); + I_ShowMouseCursor(false); + } +} + static boolean MouseResponder(void) { if (!menuactive || messageToPrint) @@ -2449,7 +2466,7 @@ static boolean MouseResponder(void) return false; } - I_ShowMouseCursor(true); + MN_ResetMouseCursor(); if (setup_active) { @@ -2533,6 +2550,8 @@ boolean M_Responder(event_t *ev) static menu_action_t repeat = MENU_NULL; menu_action_t action = MENU_NULL; + old_menu_input = menu_input; + ch = 0; // will be changed to a legit char if we're going to use it here switch (ev->type) @@ -2581,10 +2600,6 @@ boolean M_Responder(event_t *ev) return false; case ev_keydown: - if (menu_input == mouse_mode && M_InputActivated(input_menu_escape)) - { - break; - } menu_input = key_mode; ch = ev->data1; break; @@ -2619,19 +2634,6 @@ boolean M_Responder(event_t *ev) return false; } - if (menuactive) - { - if (menu_input == mouse_mode) - { - I_ShowMouseCursor(true); - } - else - { - ClearHighlightedItems(); - I_ShowMouseCursor(false); - } - } - if (M_InputActivated(input_menu_up)) { action = MENU_UP; @@ -2791,6 +2793,11 @@ boolean M_Responder(event_t *ev) return true; } + if (menuactive) + { + MN_ResetMouseCursor(); + } + // From here on, these navigation keys are used on the BIG FONT menus // like the Main Menu. @@ -2885,6 +2892,8 @@ boolean M_Responder(event_t *ev) } MN_ClearMenus(); M_StartSound(sfx_swtchx); + menu_input = old_menu_input; + MN_ResetMouseCursor(); return true; } @@ -2925,6 +2934,8 @@ boolean M_Responder(event_t *ev) MN_ClearMenus(); M_StartSound(sfx_swtchx); } + menu_input = old_menu_input; + MN_ResetMouseCursor(); return true; } diff --git a/src/mn_setup.c b/src/mn_setup.c index 6eb1661f..5bfdd1fc 100644 --- a/src/mn_setup.c +++ b/src/mn_setup.c @@ -3058,6 +3058,8 @@ static boolean ChangeEntry(menu_action_t action, int ch) SelectDone(current_item); // phares 4/17/98 setup_gather = false; // finished gathering keys, if any + menu_input = old_menu_input; + MN_ResetMouseCursor(); return true; } @@ -3090,6 +3092,9 @@ static boolean ChangeEntry(menu_action_t action, int ch) // allow backspace, and return to original value if bad // value is entered). + menu_input = old_menu_input; + MN_ResetMouseCursor(); + if (action == MENU_ENTER) { if (gather_count) // Any input? @@ -3162,6 +3167,9 @@ static boolean BindInput(void) return false; } + menu_input = old_menu_input; + MN_ResetMouseCursor(); + setup_menu_t *current_item = current_menu + set_item_on; int input_id = @@ -3281,7 +3289,8 @@ boolean MN_SetupResponder(menu_action_t action, int ch) current_menu[highlight_item].m_flags &= ~S_HILITE; } - setup_menu_t *current_item = current_menu + set_item_on; + int index = (old_menu_input == mouse_mode ? highlight_item : set_item_on); + setup_menu_t *current_item = current_menu + index; // phares 4/19/98: // Catch the response to the 'reset to default?' verification @@ -3354,6 +3363,8 @@ boolean MN_SetupResponder(menu_action_t action, int ch) } SelectDone(current_item); // phares 4/17/98 + menu_input = old_menu_input; + MN_ResetMouseCursor(); return true; } diff --git a/src/mn_setup.h b/src/mn_setup.h index aab8e6ff..41af3a4f 100644 --- a/src/mn_setup.h +++ b/src/mn_setup.h @@ -45,7 +45,9 @@ typedef enum key_mode } menu_input_mode_t; -extern menu_input_mode_t menu_input; +extern menu_input_mode_t menu_input, old_menu_input; +void MN_ResetMouseCursor(void); + extern boolean setup_active; extern short whichSkull; // which skull to draw (he blinks) extern int saved_screenblocks;