diff --git a/src/m_menu.c b/src/m_menu.c index f99491999..93412e49f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -54,6 +54,8 @@ #include "st_stuff.h" #include "i_sound.h" +#include "i_joy.h" // for joystick menu controls + // Condition Sets #include "m_cond.h" @@ -2064,6 +2066,7 @@ boolean M_Responder(event_t *ev) INT32 ch = -1; // INT32 i; static tic_t joywait = 0, mousewait = 0; + static INT32 pjoyx = 0, pjoyy = 0; static INT32 pmousex = 0, pmousey = 0; static INT32 lastx = 0, lasty = 0; void (*routine)(INT32 choice); // for some casting problem @@ -2116,32 +2119,45 @@ boolean M_Responder(event_t *ev) { if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime()) { + const INT32 jdeadzone = JOYAXISRANGE/4; if (ev->data3 != INT32_MAX) { - if (ev->data3 < 0) + if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone) { - ch = KEY_UPARROW; - joywait = I_GetTime() + NEWTICRATE/7; - } - else if (ev->data3 > 0) - { - ch = KEY_DOWNARROW; - joywait = I_GetTime() + NEWTICRATE/7; + if (ev->data3 < 0 && pjoyy >= 0) + { + ch = KEY_UPARROW; + joywait = I_GetTime() + NEWTICRATE/7; + } + else if (ev->data3 > 0 && pjoyy <= 0) + { + ch = KEY_DOWNARROW; + joywait = I_GetTime() + NEWTICRATE/7; + } + pjoyy = ev->data3; } + else + pjoyy = 0; } if (ev->data2 != INT32_MAX) { - if (ev->data2 < 0) + if (Joystick.bGamepadStyle || abs(ev->data2) > jdeadzone) { - ch = KEY_LEFTARROW; - joywait = I_GetTime() + NEWTICRATE/17; - } - else if (ev->data2 > 0) - { - ch = KEY_RIGHTARROW; - joywait = I_GetTime() + NEWTICRATE/17; + if (ev->data2 < 0 && pjoyx >= 0) + { + ch = KEY_LEFTARROW; + joywait = I_GetTime() + NEWTICRATE/17; + } + else if (ev->data2 > 0 && pjoyx <= 0) + { + ch = KEY_RIGHTARROW; + joywait = I_GetTime() + NEWTICRATE/17; + } + pjoyx = ev->data2; } + else + pjoyx = 0; } } else if (ev->type == ev_mouse && mousewait < I_GetTime())