diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 6d90e4d4e..ed94e66f0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -997,6 +997,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_usejoystick[i]); CV_RegisterVar(&cv_joyscale[i]); CV_RegisterVar(&cv_rumble[i]); + CV_RegisterVar(&cv_rumblestrength[i]); CV_RegisterVar(&cv_gamepadled[i]); } diff --git a/src/g_input.c b/src/g_input.c index 596b3cdaa..08f3e2298 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -58,12 +58,21 @@ static void led_off_handle3(void); static void led_off_handle4(void); consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = { - {"rumble", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle, 0, NULL, NULL, 0, 0, NULL}, + {"rumble", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle, 0, NULL, NULL, 0, 0, NULL}, {"rumble2", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle2, 0, NULL, NULL, 0, 0, NULL}, {"rumble3", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle3, 0, NULL, NULL, 0, 0, NULL}, {"rumble4", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, rumble_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; +static CV_PossibleValue_t rumblestrength_cons_t[] = {{FRACUNIT/4, "MIN"}, {FRACUNIT*4, "MAX"}, {0, NULL}}; + +consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS] = { + {"rumblestrength", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"rumblestrength2", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"rumblestrength3", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"rumblestrength4", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + static CV_PossibleValue_t gamepadled_cons_t[] = {{0, "Off"}, {1, "Skincolor"}, {2, "Mobjcolor"}, {0, NULL}}; consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { {"gamepadled", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle, 0, NULL, NULL, 0, 0, NULL}, @@ -1004,6 +1013,12 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre return; } + // doesent need to be super precise + // but ensure this is within range (0-65535) + // placed here so it applies to lua aswell + low_strength = (UINT16)min(FixedMul(low_strength, cv_rumblestrength[playernum].value), UINT16_MAX); + high_strength = (UINT16)min(FixedMul(high_strength, cv_rumblestrength[playernum].value), UINT16_MAX); + I_GamepadRumble(playernum, low_strength, high_strength, duration); } @@ -1016,8 +1031,6 @@ enum RUMBLE_WEAK = FRACUNIT / 128, // 512 RUMBLE_VERYWEAK = FRACUNIT / 256, // 256 }; -// TODO: multiplier to make them user changable -// due to some controllers being more/less sensitive than others // Controller rumble! // this keeps track of a bunch of things diff --git a/src/g_input.h b/src/g_input.h index 10a6e6632..7e3258360 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -113,6 +113,7 @@ extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_controlperkey; extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; extern INT32 mousex, mousey; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index fc1d7679d..4a539f139 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -735,26 +735,27 @@ static menuitem_t OP_AllControlsMenu[] = #define OP_JOYMENU(pnum) \ {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ {IT_HEADER, NULL, "Camera Controls", NULL, 67}, \ - {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ - {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ {IT_HEADER, NULL, "Deadzones", NULL, 92}, \ - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ - {IT_STRING | IT_CVAR, NULL, "Set LED to Player color", &cv_gamepadled[pnum] , 125}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ + {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, static menuitem_t OP_Joystick1Menu[] = {