mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Rumble toggle attached to profile
- Will silently merge conflict with !1093, make sure to adjust PROFILEVER handling - (profile_t *)->rumble - cv_rumble[MAXSPLITSCREENPLAYERS] - cv_dummyprofilerumble - Disables all current rumbles when toggling off - Prevents new rumbles from being set while turned off
This commit is contained in:
parent
7a9779d242
commit
89fc9a618e
10 changed files with 88 additions and 1 deletions
|
|
@ -1024,6 +1024,7 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_kickstartaccel[i]);
|
CV_RegisterVar(&cv_kickstartaccel[i]);
|
||||||
CV_RegisterVar(&cv_shrinkme[i]);
|
CV_RegisterVar(&cv_shrinkme[i]);
|
||||||
CV_RegisterVar(&cv_deadzone[i]);
|
CV_RegisterVar(&cv_deadzone[i]);
|
||||||
|
CV_RegisterVar(&cv_rumble[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filesrch.c
|
// filesrch.c
|
||||||
|
|
|
||||||
36
src/g_game.c
36
src/g_game.c
|
|
@ -353,6 +353,11 @@ static void weaponPrefChange2(void);
|
||||||
static void weaponPrefChange3(void);
|
static void weaponPrefChange3(void);
|
||||||
static void weaponPrefChange4(void);
|
static void weaponPrefChange4(void);
|
||||||
|
|
||||||
|
static void rumble_off_handle(void);
|
||||||
|
static void rumble_off_handle2(void);
|
||||||
|
static void rumble_off_handle3(void);
|
||||||
|
static void rumble_off_handle4(void);
|
||||||
|
|
||||||
// don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler.
|
// don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler.
|
||||||
|
|
||||||
// chat timer thingy
|
// chat timer thingy
|
||||||
|
|
@ -445,6 +450,13 @@ consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS] = {
|
||||||
CVAR_INIT ("deadzone4", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL)
|
CVAR_INIT ("deadzone4", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = {
|
||||||
|
CVAR_INIT ("rumble", "On", CV_SAVE|CV_CALL, CV_OnOff, rumble_off_handle),
|
||||||
|
CVAR_INIT ("rumble", "On", CV_SAVE|CV_CALL, CV_OnOff, rumble_off_handle2),
|
||||||
|
CVAR_INIT ("rumble", "On", CV_SAVE|CV_CALL, CV_OnOff, rumble_off_handle3),
|
||||||
|
CVAR_INIT ("rumble", "On", CV_SAVE|CV_CALL, CV_OnOff, rumble_off_handle4)
|
||||||
|
};
|
||||||
|
|
||||||
// now automatically allocated in D_RegisterClientCommands
|
// now automatically allocated in D_RegisterClientCommands
|
||||||
// so that it doesn't have to be updated depending on the value of MAXPLAYERS
|
// so that it doesn't have to be updated depending on the value of MAXPLAYERS
|
||||||
char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
char player_names[MAXPLAYERS][MAXPLAYERNAME+1];
|
||||||
|
|
@ -1474,6 +1486,30 @@ static void weaponPrefChange4(void)
|
||||||
WeaponPref_Send(3);
|
WeaponPref_Send(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rumble_off_handle(void)
|
||||||
|
{
|
||||||
|
if (cv_rumble[0].value == 0)
|
||||||
|
G_ResetPlayerDeviceRumble(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rumble_off_handle2(void)
|
||||||
|
{
|
||||||
|
if (cv_rumble[1].value == 0)
|
||||||
|
G_ResetPlayerDeviceRumble(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rumble_off_handle3(void)
|
||||||
|
{
|
||||||
|
if (cv_rumble[2].value == 0)
|
||||||
|
G_ResetPlayerDeviceRumble(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rumble_off_handle4(void)
|
||||||
|
{
|
||||||
|
if (cv_rumble[3].value == 0)
|
||||||
|
G_ResetPlayerDeviceRumble(3);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_DoLoadLevelEx
|
// G_DoLoadLevelEx
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,11 @@ void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strengt
|
||||||
{
|
{
|
||||||
INT32 device_id;
|
INT32 device_id;
|
||||||
|
|
||||||
|
if (cv_rumble[player].value == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
device_id = G_GetDeviceForPlayer(player);
|
device_id = G_GetDeviceForPlayer(player);
|
||||||
|
|
||||||
if (device_id < 1)
|
if (device_id < 1)
|
||||||
|
|
@ -338,6 +343,11 @@ void G_PlayerDeviceRumbleTriggers(INT32 player, UINT16 left_strength, UINT16 rig
|
||||||
{
|
{
|
||||||
INT32 device_id;
|
INT32 device_id;
|
||||||
|
|
||||||
|
if (cv_rumble[player].value == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
device_id = G_GetDeviceForPlayer(player);
|
device_id = G_GetDeviceForPlayer(player);
|
||||||
|
|
||||||
if (device_id < 1)
|
if (device_id < 1)
|
||||||
|
|
@ -348,6 +358,21 @@ void G_PlayerDeviceRumbleTriggers(INT32 player, UINT16 left_strength, UINT16 rig
|
||||||
I_GamepadRumbleTriggers(device_id, left_strength, right_strength);
|
I_GamepadRumbleTriggers(device_id, left_strength, right_strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void G_ResetPlayerDeviceRumble(INT32 player)
|
||||||
|
{
|
||||||
|
INT32 device_id;
|
||||||
|
|
||||||
|
device_id = G_GetDeviceForPlayer(player);
|
||||||
|
|
||||||
|
if (device_id < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
I_GamepadRumble(device_id, 0, 0);
|
||||||
|
I_GamepadRumbleTriggers(device_id, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void G_ResetAllDeviceRumbles(void)
|
void G_ResetAllDeviceRumbles(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,11 @@ void G_SetDeviceForPlayer(INT32 player, INT32 device);
|
||||||
|
|
||||||
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player);
|
void G_SetPlayerGamepadIndicatorToPlayerColor(INT32 player);
|
||||||
|
|
||||||
|
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
||||||
|
|
||||||
void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength);
|
void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength);
|
||||||
void G_PlayerDeviceRumbleTriggers(INT32 player, UINT16 left_strength, UINT16 right_strength);
|
void G_PlayerDeviceRumbleTriggers(INT32 player, UINT16 left_strength, UINT16 right_strength);
|
||||||
|
void G_ResetPlayerDeviceRumble(INT32 player);
|
||||||
void G_ResetAllDeviceRumbles(void);
|
void G_ResetAllDeviceRumbles(void);
|
||||||
|
|
||||||
/// Get the gamekeydown array (NUMINPUTS values) for the given device, or NULL if the device id is invalid.
|
/// Get the gamekeydown array (NUMINPUTS values) for the given device, or NULL if the device id is invalid.
|
||||||
|
|
|
||||||
|
|
@ -945,6 +945,7 @@ extern INT16 controlleroffsets[][2];
|
||||||
extern consvar_t cv_dummyprofilename;
|
extern consvar_t cv_dummyprofilename;
|
||||||
extern consvar_t cv_dummyprofileplayername;
|
extern consvar_t cv_dummyprofileplayername;
|
||||||
extern consvar_t cv_dummyprofilekickstart;
|
extern consvar_t cv_dummyprofilekickstart;
|
||||||
|
extern consvar_t cv_dummyprofilerumble;
|
||||||
|
|
||||||
void M_ResetOptions(void);
|
void M_ResetOptions(void);
|
||||||
void M_InitOptions(INT32 choice); // necessary for multiplayer since there's some options we won't want to access
|
void M_InitOptions(INT32 choice); // necessary for multiplayer since there's some options we won't want to access
|
||||||
|
|
|
||||||
|
|
@ -1171,6 +1171,7 @@ void M_Init(void)
|
||||||
CV_RegisterVar(&cv_dummyprofilename);
|
CV_RegisterVar(&cv_dummyprofilename);
|
||||||
CV_RegisterVar(&cv_dummyprofileplayername);
|
CV_RegisterVar(&cv_dummyprofileplayername);
|
||||||
CV_RegisterVar(&cv_dummyprofilekickstart);
|
CV_RegisterVar(&cv_dummyprofilekickstart);
|
||||||
|
CV_RegisterVar(&cv_dummyprofilerumble);
|
||||||
|
|
||||||
CV_RegisterVar(&cv_dummygpdifficulty);
|
CV_RegisterVar(&cv_dummygpdifficulty);
|
||||||
CV_RegisterVar(&cv_dummykartspeed);
|
CV_RegisterVar(&cv_dummykartspeed);
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ profile_t* PR_MakeProfileFromPlayer(const char *prname, const char *pname, const
|
||||||
|
|
||||||
// Player bound cvars:
|
// Player bound cvars:
|
||||||
new->kickstartaccel = cv_kickstartaccel[pnum].value;
|
new->kickstartaccel = cv_kickstartaccel[pnum].value;
|
||||||
|
new->rumble = cv_rumble[pnum].value;
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +278,7 @@ void PR_SaveProfiles(void)
|
||||||
|
|
||||||
// Consvars.
|
// Consvars.
|
||||||
WRITEUINT8(save.p, profilesList[i]->kickstartaccel);
|
WRITEUINT8(save.p, profilesList[i]->kickstartaccel);
|
||||||
|
WRITEUINT8(save.p, profilesList[i]->rumble);
|
||||||
|
|
||||||
// Controls.
|
// Controls.
|
||||||
for (j = 0; j < num_gamecontrols; j++)
|
for (j = 0; j < num_gamecontrols; j++)
|
||||||
|
|
@ -409,6 +411,14 @@ void PR_LoadProfiles(void)
|
||||||
|
|
||||||
// Consvars.
|
// Consvars.
|
||||||
profilesList[i]->kickstartaccel = (boolean)READUINT8(save.p);
|
profilesList[i]->kickstartaccel = (boolean)READUINT8(save.p);
|
||||||
|
if (version < 4)
|
||||||
|
{
|
||||||
|
profilesList[i]->rumble = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profilesList[i]->rumble = (boolean)READUINT8(save.p);
|
||||||
|
}
|
||||||
|
|
||||||
// Controls.
|
// Controls.
|
||||||
for (j = 0; j < num_gamecontrols; j++)
|
for (j = 0; j < num_gamecontrols; j++)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ extern "C" {
|
||||||
#define SKINNAMESIZE 16
|
#define SKINNAMESIZE 16
|
||||||
|
|
||||||
#define PROFILENAMELEN 6
|
#define PROFILENAMELEN 6
|
||||||
#define PROFILEVER 3
|
#define PROFILEVER 4
|
||||||
#define MAXPROFILES 16
|
#define MAXPROFILES 16
|
||||||
#define PROFILESFILE "ringprofiles.prf"
|
#define PROFILESFILE "ringprofiles.prf"
|
||||||
#define PROFILE_GUEST 0
|
#define PROFILE_GUEST 0
|
||||||
|
|
@ -74,6 +74,7 @@ struct profile_t
|
||||||
// Player-specific consvars.
|
// Player-specific consvars.
|
||||||
// @TODO: List all of those
|
// @TODO: List all of those
|
||||||
boolean kickstartaccel; // cv_kickstartaccel
|
boolean kickstartaccel; // cv_kickstartaccel
|
||||||
|
boolean rumble; // cv_rumble
|
||||||
|
|
||||||
// Finally, control data itself
|
// Finally, control data itself
|
||||||
INT32 controls[num_gamecontrols][MAXINPUTMAPPING]; // Lists of all the controls, defined the same way as default inputs in g_input.c
|
INT32 controls[num_gamecontrols][MAXINPUTMAPPING]; // Lists of all the controls, defined the same way as default inputs in g_input.c
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ menu_t OPTIONS_ProfilesDef = {
|
||||||
consvar_t cv_dummyprofilename = CVAR_INIT ("dummyprofilename", "", CV_HIDDEN, NULL, NULL);
|
consvar_t cv_dummyprofilename = CVAR_INIT ("dummyprofilename", "", CV_HIDDEN, NULL, NULL);
|
||||||
consvar_t cv_dummyprofileplayername = CVAR_INIT ("dummyprofileplayername", "", CV_HIDDEN, NULL, NULL);
|
consvar_t cv_dummyprofileplayername = CVAR_INIT ("dummyprofileplayername", "", CV_HIDDEN, NULL, NULL);
|
||||||
consvar_t cv_dummyprofilekickstart = CVAR_INIT ("dummyprofilekickstart", "Off", CV_HIDDEN, CV_OnOff, NULL);
|
consvar_t cv_dummyprofilekickstart = CVAR_INIT ("dummyprofilekickstart", "Off", CV_HIDDEN, CV_OnOff, NULL);
|
||||||
|
consvar_t cv_dummyprofilerumble = CVAR_INIT ("dummyprofilerumble", "On", CV_HIDDEN, CV_OnOff, NULL);
|
||||||
|
|
||||||
void M_ProfileSelectInit(INT32 choice)
|
void M_ProfileSelectInit(INT32 choice)
|
||||||
{
|
{
|
||||||
|
|
@ -92,12 +93,14 @@ static void M_StartEditProfile(INT32 c)
|
||||||
CV_StealthSet(&cv_dummyprofilename, optionsmenu.profile->profilename);
|
CV_StealthSet(&cv_dummyprofilename, optionsmenu.profile->profilename);
|
||||||
CV_StealthSet(&cv_dummyprofileplayername, optionsmenu.profile->playername);
|
CV_StealthSet(&cv_dummyprofileplayername, optionsmenu.profile->playername);
|
||||||
CV_StealthSetValue(&cv_dummyprofilekickstart, optionsmenu.profile->kickstartaccel);
|
CV_StealthSetValue(&cv_dummyprofilekickstart, optionsmenu.profile->kickstartaccel);
|
||||||
|
CV_StealthSetValue(&cv_dummyprofilerumble, optionsmenu.profile->rumble);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_StealthSet(&cv_dummyprofilename, "");
|
CV_StealthSet(&cv_dummyprofilename, "");
|
||||||
CV_StealthSet(&cv_dummyprofileplayername, "");
|
CV_StealthSet(&cv_dummyprofileplayername, "");
|
||||||
CV_StealthSetValue(&cv_dummyprofilekickstart, 0); // off
|
CV_StealthSetValue(&cv_dummyprofilekickstart, 0); // off
|
||||||
|
CV_StealthSetValue(&cv_dummyprofilerumble, 1); // on
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup greyout and stuff.
|
// Setup greyout and stuff.
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@ menuitem_t OPTIONS_ProfileControls[] = {
|
||||||
{IT_HEADER, "TOGGLES", "For per-player commands",
|
{IT_HEADER, "TOGGLES", "For per-player commands",
|
||||||
NULL, {NULL}, 0, 0},
|
NULL, {NULL}, 0, 0},
|
||||||
|
|
||||||
|
{IT_CONTROL | IT_CVAR, "RUMBLE", "For gamepad users - should your device rumble?",
|
||||||
|
NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0},
|
||||||
|
|
||||||
{IT_CONTROL | IT_CVAR, "KICKSTART ACCEL", "Hold A to auto-accel. Tap it to cancel.",
|
{IT_CONTROL | IT_CVAR, "KICKSTART ACCEL", "Hold A to auto-accel. Tap it to cancel.",
|
||||||
NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0},
|
NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0},
|
||||||
|
|
||||||
|
|
@ -182,6 +185,7 @@ static void M_ProfileControlSaveResponse(INT32 choice)
|
||||||
SINT8 belongsto = PR_ProfileUsedBy(optionsmenu.profile);
|
SINT8 belongsto = PR_ProfileUsedBy(optionsmenu.profile);
|
||||||
// Save the profile
|
// Save the profile
|
||||||
optionsmenu.profile->kickstartaccel = cv_dummyprofilekickstart.value;
|
optionsmenu.profile->kickstartaccel = cv_dummyprofilekickstart.value;
|
||||||
|
optionsmenu.profile->rumble = cv_dummyprofilerumble.value;
|
||||||
memcpy(&optionsmenu.profile->controls, optionsmenu.tempcontrols, sizeof(gamecontroldefault));
|
memcpy(&optionsmenu.profile->controls, optionsmenu.tempcontrols, sizeof(gamecontroldefault));
|
||||||
|
|
||||||
// If this profile is in-use by anyone, apply the changes immediately upon exiting.
|
// If this profile is in-use by anyone, apply the changes immediately upon exiting.
|
||||||
|
|
@ -190,6 +194,7 @@ static void M_ProfileControlSaveResponse(INT32 choice)
|
||||||
{
|
{
|
||||||
memcpy(&gamecontrol[belongsto], optionsmenu.tempcontrols, sizeof(gamecontroldefault));
|
memcpy(&gamecontrol[belongsto], optionsmenu.tempcontrols, sizeof(gamecontroldefault));
|
||||||
CV_SetValue(&cv_kickstartaccel[belongsto], cv_dummyprofilekickstart.value);
|
CV_SetValue(&cv_kickstartaccel[belongsto], cv_dummyprofilekickstart.value);
|
||||||
|
CV_SetValue(&cv_rumble[belongsto], cv_dummyprofilerumble.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
M_GoBack(0);
|
M_GoBack(0);
|
||||||
|
|
@ -206,6 +211,7 @@ void M_ProfileControlsConfirm(INT32 choice)
|
||||||
M_ProfileControlSaveResponse(MA_YES);
|
M_ProfileControlSaveResponse(MA_YES);
|
||||||
|
|
||||||
optionsmenu.profile->kickstartaccel = cv_dummyprofilekickstart.value; // Make sure to save kickstart accel.
|
optionsmenu.profile->kickstartaccel = cv_dummyprofilekickstart.value; // Make sure to save kickstart accel.
|
||||||
|
optionsmenu.profile->rumble = cv_dummyprofilerumble.value; // And rumble too!
|
||||||
|
|
||||||
// Reapply player 1's real profile.
|
// Reapply player 1's real profile.
|
||||||
if (cv_currprofile.value > -1)
|
if (cv_currprofile.value > -1)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue