shithub: choc

Download patch

ref: 078673f73060130fdebe54bb928973097f5923a6
parent: dd78c0873ec4756cc1bc430cf22ebe542ac3a23b
author: Toni Spets <toni.spets@iki.fi>
date: Sun Aug 12 07:56:53 EDT 2018

doom: Don't skip joy events when menu is closed

Fixes #1015.

--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -1385,71 +1385,73 @@
     {
         // Simulate key presses from joystick events to interact with the menu.
 
-	if (ev->data3 < 0)
-	{
-	    key = key_menu_up;
-	    joywait = I_GetTime() + 5;
-	}
-	else if (ev->data3 > 0)
-	{
-	    key = key_menu_down;
-	    joywait = I_GetTime() + 5;
-	}
-		
-	if (ev->data2 < 0)
-	{
-	    key = key_menu_left;
-	    joywait = I_GetTime() + 2;
-	}
-	else if (ev->data2 > 0)
-	{
-	    key = key_menu_right;
-	    joywait = I_GetTime() + 2;
-	}
-
-#define JOY_BUTTON_MAPPED(x) ((x) >= 0)
-#define JOY_BUTTON_PRESSED(x) (JOY_BUTTON_MAPPED(x) && (ev->data1 & (1 << (x))) != 0)
-
-        if (JOY_BUTTON_PRESSED(joybfire))
+        if (menuactive)
         {
-            // Simulate a 'Y' keypress when Doom show a Y/N dialog with Fire button.
-            if (messageToPrint && messageNeedsInput)
+            if (ev->data3 < 0)
             {
-                key = key_menu_confirm;
+                key = key_menu_up;
+                joywait = I_GetTime() + 5;
             }
-            // Simulate pressing "Enter" when we are supplying a save slot name
-            else if (saveStringEnter)
+            else if (ev->data3 > 0)
             {
-                key = KEY_ENTER;
+                key = key_menu_down;
+                joywait = I_GetTime() + 5;
             }
-            else
+            if (ev->data2 < 0)
             {
-                // if selecting a save slot via joypad, set a flag
-                if (currentMenu == &SaveDef)
-                {
-                    joypadSave = true;
-                }
-                key = key_menu_forward;
+                key = key_menu_left;
+                joywait = I_GetTime() + 2;
             }
-            joywait = I_GetTime() + 5;
-        }
-        if (JOY_BUTTON_PRESSED(joybuse))
-        {
-            // Simulate a 'N' keypress when Doom show a Y/N dialog with Use button.
-            if (messageToPrint && messageNeedsInput)
+            else if (ev->data2 > 0)
             {
-                key = key_menu_abort;
+                key = key_menu_right;
+                joywait = I_GetTime() + 2;
             }
-            // If user was entering a save name, back out
-            else if (saveStringEnter)
+
+#define JOY_BUTTON_MAPPED(x) ((x) >= 0)
+#define JOY_BUTTON_PRESSED(x) (JOY_BUTTON_MAPPED(x) && (ev->data1 & (1 << (x))) != 0)
+
+            if (JOY_BUTTON_PRESSED(joybfire))
             {
-                key = KEY_ESCAPE;
+                // Simulate a 'Y' keypress when Doom show a Y/N dialog with Fire button.
+                if (messageToPrint && messageNeedsInput)
+                {
+                    key = key_menu_confirm;
+                }
+                // Simulate pressing "Enter" when we are supplying a save slot name
+                else if (saveStringEnter)
+                {
+                    key = KEY_ENTER;
+                }
+                else
+                {
+                    // if selecting a save slot via joypad, set a flag
+                    if (currentMenu == &SaveDef)
+                    {
+                        joypadSave = true;
+                    }
+                    key = key_menu_forward;
+                }
+                joywait = I_GetTime() + 5;
             }
-            else
+            if (JOY_BUTTON_PRESSED(joybuse))
             {
-                key = key_menu_back;
+                // Simulate a 'N' keypress when Doom show a Y/N dialog with Use button.
+                if (messageToPrint && messageNeedsInput)
+                {
+                    key = key_menu_abort;
+                }
+                // If user was entering a save name, back out
+                else if (saveStringEnter)
+                {
+                    key = KEY_ESCAPE;
+                }
+                else
+                {
+                    key = key_menu_back;
+                }
+                joywait = I_GetTime() + 5;
             }
-            joywait = I_GetTime() + 5;
         }
         if (JOY_BUTTON_PRESSED(joybmenu))
         {