Add separate x/y deadzones

This commit is contained in:
Lonsfor 2021-08-30 11:38:52 -04:00 committed by Lonsfor
parent 2f17fdca6c
commit 2dd21de302
No known key found for this signature in database
GPG key ID: A4B7179A9CA2B527
4 changed files with 33 additions and 18 deletions

View file

@ -912,7 +912,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_driftaxis2); CV_RegisterVar(&cv_driftaxis2);
CV_RegisterVar(&cv_driftaxis3); CV_RegisterVar(&cv_driftaxis3);
CV_RegisterVar(&cv_driftaxis4); CV_RegisterVar(&cv_driftaxis4);
CV_RegisterVar(&cv_deadzone); CV_RegisterVar(&cv_xdeadzone);
CV_RegisterVar(&cv_ydeadzone);
CV_RegisterVar(&cv_deadzone2); CV_RegisterVar(&cv_deadzone2);
CV_RegisterVar(&cv_deadzone3); CV_RegisterVar(&cv_deadzone3);
CV_RegisterVar(&cv_deadzone4); CV_RegisterVar(&cv_deadzone4);

View file

@ -493,7 +493,8 @@ consvar_t cv_aimaxis = {"joyaxis_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL,
consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fireaxis = {"joyaxis_fire", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis = {"joyaxis_fire", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_driftaxis = {"joyaxis_drift", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftaxis = {"joyaxis_drift", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone = {"joy_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_xdeadzone = {"joy_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ydeadzone = {"joy_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_moveaxis2 = {"joyaxis2_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis2 = {"joyaxis2_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -930,17 +931,6 @@ static INT32 Joy1Axis(axis_input_e axissel)
{ {
axisval /= 2; axisval /= 2;
retaxis = joyxmove[axisval]; retaxis = joyxmove[axisval];
}
else
{
axisval--;
axisval /= 2;
retaxis = joyymove[axisval];
}
#ifdef _arch_dreamcast
skipDC:
#endif
if (retaxis < (-JOYAXISRANGE)) if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE; retaxis = -JOYAXISRANGE;
@ -948,13 +938,37 @@ static INT32 Joy1Axis(axis_input_e axissel)
retaxis = +JOYAXISRANGE; retaxis = +JOYAXISRANGE;
if (!Joystick.bGamepadStyle && axissel < AXISDEAD) if (!Joystick.bGamepadStyle && axissel < AXISDEAD)
{ {
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone.value) >> FRACBITS; const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_xdeadzone.value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone) if (abs(retaxis) <= jdeadzone)
return 0; return 0;
} }
if (flp) retaxis = -retaxis; //flip it around if (flp) retaxis = -retaxis; //flip it around
return retaxis; return retaxis;
} }
else
{
axisval--;
axisval /= 2;
retaxis = joyymove[axisval];
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick.bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone.value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp) retaxis = -retaxis; //flip it around
return retaxis;
}
}
#ifdef _arch_dreamcast
skipDC:
#endif
static INT32 Joy2Axis(axis_input_e axissel) static INT32 Joy2Axis(axis_input_e axissel)
{ {

View file

@ -118,7 +118,7 @@ extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mouse
extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/;
extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4; extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4;
extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4; extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4;
extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_deadzone; extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_xdeadzone,cv_ydeadzone;
extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_deadzone2; extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_deadzone2;
extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_deadzone3; extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_deadzone3;
extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_deadzone4; extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_deadzone4;

View file

@ -2563,7 +2563,7 @@ boolean M_Responder(event_t *ev)
{ {
if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime()) if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
{ {
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone.value) >> FRACBITS; const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone.value) >> FRACBITS;
if (ev->data3 != INT32_MAX) if (ev->data3 != INT32_MAX)
{ {
if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone) if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone)