Port deadzone configuration from Kart

I don't feel like getting out my gamepad, so I'll trust
that this works.
This commit is contained in:
fickleheart 2019-12-09 20:39:05 -06:00
parent 3735134948
commit 834a3bf334
4 changed files with 10 additions and 4 deletions

View file

@ -774,6 +774,8 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_fireaxis2); CV_RegisterVar(&cv_fireaxis2);
CV_RegisterVar(&cv_firenaxis); CV_RegisterVar(&cv_firenaxis);
CV_RegisterVar(&cv_firenaxis2); CV_RegisterVar(&cv_firenaxis2);
CV_RegisterVar(&cv_deadzone);
CV_RegisterVar(&cv_deadzone2);
// filesrch.c // filesrch.c
CV_RegisterVar(&cv_addons_option); CV_RegisterVar(&cv_addons_option);

View file

@ -439,6 +439,7 @@ consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL,
consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone = {"joy_deadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -448,6 +449,7 @@ consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL
consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_deadzone2 = {"joy_deadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
#ifdef SEENAMES #ifdef SEENAMES
player_t *seenplayer; // player we're aiming at right now player_t *seenplayer; // player we're aiming at right now
@ -907,7 +909,7 @@ static INT32 JoyAxis(axis_input_e axissel)
retaxis = +JOYAXISRANGE; retaxis = +JOYAXISRANGE;
if (!Joystick.bGamepadStyle && axissel < AXISDEAD) if (!Joystick.bGamepadStyle && axissel < AXISDEAD)
{ {
const INT32 jdeadzone = JOYAXISRANGE/4; const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone.value) >> FRACBITS;
if (-jdeadzone < retaxis && retaxis < jdeadzone) if (-jdeadzone < retaxis && retaxis < jdeadzone)
return 0; return 0;
} }
@ -980,7 +982,7 @@ static INT32 Joy2Axis(axis_input_e axissel)
retaxis = +JOYAXISRANGE; retaxis = +JOYAXISRANGE;
if (!Joystick2.bGamepadStyle && axissel < AXISDEAD) if (!Joystick2.bGamepadStyle && axissel < AXISDEAD)
{ {
const INT32 jdeadzone = JOYAXISRANGE/4; const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone2.value) >> FRACBITS;
if (-jdeadzone < retaxis && retaxis < jdeadzone) if (-jdeadzone < retaxis && retaxis < jdeadzone)
return 0; return 0;
} }

View file

@ -72,8 +72,8 @@ extern consvar_t cv_useranalog, cv_useranalog2;
extern consvar_t cv_analog, cv_analog2; extern consvar_t cv_analog, cv_analog2;
extern consvar_t cv_directionchar, cv_directionchar2; extern consvar_t cv_directionchar, cv_directionchar2;
extern consvar_t cv_autobrake, cv_autobrake2; extern consvar_t cv_autobrake, cv_autobrake2;
extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis; extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone;
extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2; extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2;
extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest;
// hi here's some new controls // hi here's some new controls

View file

@ -1121,6 +1121,7 @@ static menuitem_t OP_Joystick1Menu[] =
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120}, {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120},
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130},
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone, 140},
}; };
static menuitem_t OP_Joystick2Menu[] = static menuitem_t OP_Joystick2Menu[] =
@ -1137,6 +1138,7 @@ static menuitem_t OP_Joystick2Menu[] =
{IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120}, {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120},
{IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130},
{IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone2,140},
}; };
static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS]; static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS];