CLIENT: Enable Gamepad through menu; add sensitivity Gamepad aim assist

This commit is contained in:
cypress 2024-09-08 10:39:56 -07:00
parent 293ef500a9
commit bbb4d53f51
3 changed files with 71 additions and 2 deletions

View File

@ -56,6 +56,18 @@ void() ToggleMenu =
}
}
//
// SetGamepadBindings()
// Since our menu architecture currently sucks,
// we don't yet support a good binds menu that
// let's you get good gamepad control.. so
// force these binds (sorry!)
//
void() SetGamepadBindings =
{
localcmd("unbindall; bind ~ \"toggleconsole\"; bind ` \"toggleconsole\"; bind ESCAPE \"togglemenu\"; joyadvaxisr 4; joyadvaxisu 2; joyadvaxisx 3; joyadvaxisy -1; bind JOY1 \"+button5\"; bindlevel JOY2 30 \"null\"; bind JOY3 \"+button4\"; bind GP_LSHOULDER \"impulse 33\"; bind AUX1 \"+moveup\"; bind AUX2 \"+button3\"; bindlevel AUX3 30 \"null\"; bindlevel AUX4 30 \"null\"; bind AUX5 \"togglemenu\"; bind AUX10 \"+attack\"; bind GP_Y \"+button4\"; bindlevel GP_A 30 \"impulse 10\"; bindlevel GP_B 30 \"impulse 30\"; bindlevel GP_X 30 \"+button5\"; bindlevel GP_LTHUMB 30 \"impulse 23\"; bindlevel GP_RTHUMB 30 \"+button6\"; bind GP_LTRIGGER \"+button8\"; bindlevel GP_DPAD_DOWN 30 \"+button7\"; bindlevel GP_RSHOULDER 30 \"+button3\"; bindlevel GP_DPAD_RIGHT 30 \"impulse 33\"; bindlevel GP_DPAD_UP 30 \"+button7\"; bind GP_VIEW \"showscores\"; joysidesensitivity 0.8; joyyawsensitivity 0.6; joypitchsensitivity 0.55\n");
}
float(float isnew) SetZombieSkinning =
{
self.drawmask = MASK_ENGINE;
@ -82,6 +94,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init =
autocvar(r_viewmodel_default_fov, 70);
autocvar(cl_controllerglyphs, "xbox");
autocvar(in_rumbleenabled, 1);
autocvar(in_aimassist, 0);
// Runtime check if we're running this in WebASM/WebGL.
if (cvar_string("sys_platform") == "Web")
@ -743,6 +756,7 @@ void() Camera_SniperSway =
sniper_sway[0] = angledelta(delta_pitch);
sniper_sway[1] = angledelta(delta_yaw);
};
float gamepad_enabled;
// CALLED EVERY CLIENT RENDER FRAME
float pap_flash_alternate;
@ -760,10 +774,16 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
setviewprop(VF_DRAWENGINESBAR, 0);
setviewprop(VF_DRAWCROSSHAIR, 0);
float sensitivity_factor;
if (in_menu == MENU_PAUSE)
setsensitivityscaler(0);
sensitivity_factor = 0;
else
setsensitivityscaler((1 + SCALE_CONSTANT * getstatf(STAT_VIEWZOOM)) / (1 + SCALE_CONSTANT));
sensitivity_factor = (1 + SCALE_CONSTANT * getstatf(STAT_VIEWZOOM)) / (1 + SCALE_CONSTANT);
if (gamepad_enabled && getstatf(STAT_FACINGENEMY) && cvar("in_aimassist") == 1)
sensitivity_factor *= 0.5;
setsensitivityscaler(sensitivity_factor);
setviewprop(VF_AFOV, autocvar(fov,90)*getstatf(STAT_VIEWZOOM));
@ -835,6 +855,11 @@ noref void(float width, float height, float menushown) CSQC_UpdateView =
Draw_Menu();
setlocaluserinfo(0, "in_menu", "1");
if (gamepad_enabled)
buttons[20].gray_out = true;
else
buttons[20].gray_out = false;
}
else
{

View File

@ -803,6 +803,25 @@ void() settings_rumble =
cvar_set("in_rumbleenabled", ftos(!rumble));
}
void() settings_aimassist =
{
float aimassist = cvar("in_aimassist");
cvar_set("in_aimassist", ftos(!aimassist));
}
float gamepad_enabled;
void() SetGamepadBindings;
void() settings_gamepad =
{
gamepad_enabled = !gamepad_enabled;
if (gamepad_enabled) {
SetGamepadBindings();
} else {
localcmd("unbindall; exec default.cfg; exec user_settings.cfg\n");
}
}
void() setting_mastervol =
{
float vol = cvar("volume");
@ -1016,6 +1035,8 @@ var struct
{[6, 115], "Invert Mouse", -1, setting_invert, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 66
{[6, 135], "Controller Glyphs", -1, setting_glyph, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 67
{[6, 155], "Rumble", -1, settings_rumble, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 68
{[6, 175], "Gamepad", -1, settings_gamepad, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 69
{[6, 195], "Aim Assist", -1, settings_aimassist, null, MENU_CONSETTINGS, 0, OPTION_WEB_AND_EXE}, // 70
// Main menu (cont.)
{[6, 145], "Achievements (Not on Web)", -1, null, null, MENU_MAIN, 1, OPTION_WEB_ONLY}, // 3
@ -1534,6 +1555,18 @@ void() Draw_Extra_CSettings =
drawstring([320, 135], controller_glyph_brand, [14, 14], [1, 1, 1], 1, 0);
drawsubpic([325 + strlen(controller_glyph_brand)*14, 132], [80, 20], sprintf("gfx/controller_glyphs/%s.tga", cvar_string("cl_controllerglyphs")), [0, 0], [0.5, 0.125], [1, 1, 1], 1);
// Gamepad
if (gamepad_enabled == 0)
drawstring([320, 175], S_DISABLED, [14, 14], [1, 1, 1], 1, 0);
else
drawstring([320, 175], S_ENABLED, [14, 14], [1, 1, 1], 1, 0);
// Aim Assist
if (cvar("in_aimassist") == 0)
drawstring([320, 195], S_DISABLED, [14, 14], [1, 1, 1], 1, 0);
else
drawstring([320, 195], S_ENABLED, [14, 14], [1, 1, 1], 1, 0);
// Descriptions
switch(lastActive) {
case 54:
@ -1551,6 +1584,12 @@ void() Draw_Extra_CSettings =
case 68:
cset_desc = "Toggle Rumble support for Controllers.";
break;
case 69:
cset_desc = "Enable Gamepad support with preset bindings.";
break;
case 70:
cset_desc = "Lower Gamepad sensitivity when looking at enemies.";
break;
default:
cset_desc = "";
break;

View File

@ -790,8 +790,13 @@ void() PlayerPostThink =
else
self.facingenemy = false;
#ifndef FTE
// 1/4 of a second is enough of a delay to not kill the effect.
player_trace_time = time + 0.25;
#else
// FTE's server rate is already slower, no real need to delay this.
player_trace_time = time + 0.05;
#endif // FTE
}
};