add deadzone + storing of previous joyx/y values etc to attempt to make joysticks less sensitive in menus

This commit is contained in:
Monster Iestyn 2018-12-02 21:52:30 +00:00
parent 13b0e9c3c5
commit 978a28004d

View file

@ -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"
@ -2065,6 +2067,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
@ -2117,32 +2120,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())