shithub: choc

Download patch

ref: 782e0301c39d25e72a83377f9abd215cfe91f43d
parent: 439d4f5ea9417cf6a4ef8eb10c9133778d10c4a8
parent: 3213faa4e68c749a7660661fd4fcc204b13ee5a8
author: Jonathan Dowland <jon+github@alcopop.org>
date: Mon Mar 20 12:17:46 EDT 2017

Merge pull request #890 from Wintermute0110/joystick-allow-quit-game

Simulate Y and N key presses with joypad when showing yes/no menus.

--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -1396,6 +1396,8 @@
 	
     if (ev->type == ev_joystick && joywait < I_GetTime())
     {
+        // Simulate key presses from joyticks events to interact with the menu.
+
 	if (ev->data3 < 0)
 	{
 	    key = key_menu_up;
@@ -1432,6 +1434,20 @@
         {
             key = key_menu_activate;
 	    joywait = I_GetTime() + 5;
+        }
+
+        // Simulate a 'Y' keypress when Doom show a Y/N dialog with Fire button.
+        if (messageToPrint && messageNeedsInput && joybmenu >= 0 && ev->data1&1)
+        {
+            key = key_menu_confirm;
+            joywait = I_GetTime() + 5;
+        }
+
+        // Simulate a 'N' keypress when Doom show a Y/N dialog with Use button.
+        if (messageToPrint && messageNeedsInput && joybmenu >= 0 && ev->data1&2)
+        {
+            key = key_menu_abort;
+            joywait = I_GetTime() + 5;
         }
     }
     else