From b9836e49253da502ed6930ba30b95c56e1ace20a Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sun, 18 May 2025 14:05:31 -0400 Subject: [PATCH] Add toggle for deadzone style The game now defaults to Kart style deadzone to remove that stiffness felt on shallower angles --- src/d_netcmd.c | 1 + src/g_game.c | 28 +++++++++++++++++++++++++++- src/g_game.h | 1 + src/r_main.cpp | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 20eadd721..a5e1995a7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1114,6 +1114,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_kickstartaccel[i]); CV_RegisterVar(&cv_shrinkme[i]); CV_RegisterVar(&cv_deadzone[i]); + CV_RegisterVar(&cv_deadzonestyle[i]); } // filesrch.c diff --git a/src/g_game.c b/src/g_game.c index 65c55b542..65e4c2a0f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -447,6 +447,14 @@ consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = { CVAR_INIT ("deadzone4", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL) }; +static CV_PossibleValue_t deadzonestyle_cons_t[] = {{0, "Kart"}, {1, "RR"}, {0, NULL}}; +consvar_t cv_deadzonestyle[MAXSPLITSCREENPLAYERS] = { + CVAR_INIT ("deadzonestyle", "Kart", CV_SAVE, deadzonestyle_cons_t, NULL), + CVAR_INIT ("deadzonestyle2", "Kart", CV_SAVE, deadzonestyle_cons_t, NULL), + CVAR_INIT ("deadzonestyle3", "Kart", CV_SAVE, deadzonestyle_cons_t, NULL), + CVAR_INIT ("deadzonestyle4", "Kart", CV_SAVE, deadzonestyle_cons_t, NULL) +}; + // now automatically allocated in D_RegisterClientCommands // so that it doesn't have to be updated depending on the value of MAXPLAYERS char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; @@ -950,9 +958,27 @@ static void G_HandleAxisDeadZone(UINT8 splitnum, joystickvector2_t *joystickvect { INT32 gamepadStyle = Joystick[splitnum].bGamepadStyle; fixed_t deadZone = cv_deadzone[splitnum].value; + boolean deadZoneStyle = cv_deadzonestyle[splitnum].value; // When gamepadstyle is "true" the values are just -1, 0, or 1. This is done in the interface code. - if (!gamepadStyle) + + // v1 style deadzone + // Deadzone doesn't scale so shallower angles are easier to hit. + if (!gamepadStyle && (deadZoneStyle == 0)) + { + joystickvector->xaxis = min(joystickvector->xaxis, JOYAXISRANGE); + joystickvector->xaxis = max(joystickvector->xaxis, -JOYAXISRANGE); + joystickvector->yaxis = min(joystickvector->yaxis, JOYAXISRANGE); + joystickvector->yaxis = max(joystickvector->yaxis, -JOYAXISRANGE); + + if (joystickvector->xaxis >= deadZone) + joystickvector->xaxis = 0; + if (joystickvector->yaxis <= deadZone) + joystickvector->yaxis = 0; + } + // RR style deadzone + // Dead zone scales so shallower angles are harder to hit but you have more range. + else if (!gamepadStyle && (deadZoneStyle == 1)) { // Get the total magnitude of the 2 axes INT32 magnitude = (joystickvector->xaxis * joystickvector->xaxis) + (joystickvector->yaxis * joystickvector->yaxis); diff --git a/src/g_game.h b/src/g_game.h index 16bab824a..8886f0984 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -79,6 +79,7 @@ extern consvar_t cv_invertmouse; extern consvar_t cv_kickstartaccel[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_shrinkme[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_deadzonestyle[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; diff --git a/src/r_main.cpp b/src/r_main.cpp index 89f1a2276..77191978b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -170,7 +170,7 @@ consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = { CVAR_INIT ("flipcam4", "Off", CV_CALL|CV_SAVE, CV_OnOff, weaponPrefChange4) }; -consvar_t cv_shadow = CVAR_INIT ("shadow", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_shadow = CVAR_INIT ("dropshadow", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_skybox = CVAR_INIT ("skybox", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_ffloorclip = CVAR_INIT ("ffloorclip", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_allowmlook = CVAR_INIT ("allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL);