commit 9c636905520069d0015ac877cb3a703a5f777a69
Author: Michael Day <contact@michaelcday.com>
AuthorDate: Sun Dec 10 22:14:04 2023 -0500
Commit: Michael Day <contact@michaelcday.com>
CommitDate: Sun Dec 10 22:14:04 2023 -0500
strife: Gamepad dpad or stick can navigate menu
---
src/strife/m_menu.c | 53 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c
index 6ba9ab83..d24536b9 100644
--- a/src/strife/m_menu.c
+++ b/src/strife/m_menu.c
@@ -30,6 +30,7 @@
#include "deh_main.h"
#include "i_input.h"
+#include "i_joystick.h"
#include "i_swap.h"
#include "i_system.h"
#include "i_timer.h"
@@ -1697,6 +1698,7 @@ boolean M_Responder (event_t* ev)
static int lasty = 0;
static int mousex = 0;
static int lastx = 0;
+ int dir;
// In testcontrols mode, none of the function keys should do anything
// - the only key is escape to quit.
@@ -1740,39 +1742,70 @@ boolean M_Responder (event_t* ev)
if (ev->type == ev_joystick && joywait < I_GetTime())
{
- if (ev->data3 < 0)
+ if (JOY_GET_DPAD(ev->data6) != JOY_DIR_NONE)
+ {
+ dir = JOY_GET_DPAD(ev->data6);
+ }
+ else if (JOY_GET_LSTICK(ev->data6) != JOY_DIR_NONE)
+ {
+ dir = JOY_GET_LSTICK(ev->data6);
+ }
+ else
+ {
+ dir = JOY_GET_RSTICK(ev->data6);
+ }
+
+ if (dir & JOY_DIR_UP)
{
key = key_menu_up;
joywait = I_GetTime() + 5;
}
- else if (ev->data3 > 0)
+ else if (dir & JOY_DIR_DOWN)
{
key = key_menu_down;
joywait = I_GetTime() + 5;
}
-
- if (ev->data2 < 0)
+ if (dir & JOY_DIR_LEFT)
{
key = key_menu_left;
joywait = I_GetTime() + 2;
}
- else if (ev->data2 > 0)
+ else if (dir & JOY_DIR_RIGHT)
{
key = key_menu_right;
joywait = I_GetTime() + 2;
}
- if (ev->data1&1)
+#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_menu_forward;
+ // Simulate a 'Y' keypress when Doom show a Y/N dialog with Fire button.
+ if (messageToPrint && messageNeedsInput)
+ {
+ key = key_menu_confirm;
+ }
+ else
+ {
+ key = key_menu_forward;
+ }
joywait = I_GetTime() + 5;
}
- if (ev->data1&2)
+ 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;
+ }
+ else
+ {
+ key = key_menu_back;
+ }
joywait = I_GetTime() + 5;
}
- if (joybmenu >= 0 && (ev->data1 & (1 << joybmenu)) != 0)
+ if (JOY_BUTTON_PRESSED(joybmenu))
{
key = key_menu_activate;
joywait = I_GetTime() + 5;