From 2cacad2c2ff9a6cf0fd718fbbea03f7afe2ec2a4 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sun, 30 Jun 2024 20:33:58 -0700 Subject: [PATCH 1/3] CLIENT: Add cvar for toggling rumble --- source/client/main.qc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/client/main.qc b/source/client/main.qc index 738b348..3e5af8f 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -81,6 +81,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = cvar_set("r_fb_models", ftos(0)); autocvar(r_viewmodel_default_fov, 70); autocvar(cl_controllerglyphs, "xbox"); + autocvar(in_rumbleenabled, 1); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") @@ -1166,7 +1167,11 @@ noref void() CSQC_Parse_Event = screenflash_starttime = time; break; case CSQC_EVENT_RUMBLE: - gp_rumble(last_input_deviceid, readshort(), readshort(), readshort()); + float low_frequency = readshort(); + float high_frequency = readshort(); + float duration = readshort(); + if (cvar("in_rumbleenabled")) + gp_rumble(last_input_deviceid, low_frequency, high_frequency, duration); break; case EVENT_WEAPONRECOIL: local vector rec; From 9f822f034e32ab9dde5fa975fce678147c84eb01 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sun, 30 Jun 2024 20:58:22 -0700 Subject: [PATCH 2/3] CLIENT: Add menu option for toggling rumble --- source/client/menu.qc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/client/menu.qc b/source/client/menu.qc index 1843381..e86467a 100644 --- a/source/client/menu.qc +++ b/source/client/menu.qc @@ -793,6 +793,12 @@ void() settings_adsmode = localcmd("bind MOUSE2 \"+button8\"\n"); } +void() settings_rumble = +{ + float rumble = cvar("in_rumbleenabled"); + cvar_set("in_rumbleenabled", ftos(!rumble)); +} + void() setting_mastervol = { float vol = cvar("volume"); @@ -1005,6 +1011,7 @@ var struct // Control Settings (cont.) {[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 // Main menu (cont.) {[6, 145], "Achievements (Not on Web)", -1, null, null, MENU_MAIN, 1, OPTION_WEB_ONLY}, // 3 @@ -1495,6 +1502,12 @@ void() Draw_Extra_CSettings = else drawstring([320, 115], S_ENABLED, [14, 14], [1, 1, 1], 1, 0); + // Rumble + if (cvar("in_rumbleenabled") == 0) + drawstring([320, 155], S_DISABLED, [14, 14], [1, 1, 1], 1, 0); + else + drawstring([320, 155], S_ENABLED, [14, 14], [1, 1, 1], 1, 0); + // Controller Glyphs string controller_glyph_brand = "Unknown"; switch(cvar_string("cl_controllerglyphs")) { @@ -1531,6 +1544,9 @@ void() Draw_Extra_CSettings = case 67: cset_desc = "Glyph Branding type to display for Controllers."; break; + case 68: + cset_desc = "Toggle Rumble support for Controllers."; + break; default: cset_desc = ""; break; From 7da360723eee0ddf0ee0fc25596286708117ace7 Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Sun, 30 Jun 2024 21:54:52 -0700 Subject: [PATCH 3/3] CLIENT: Remove device id debug print --- source/client/main.qc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/client/main.qc b/source/client/main.qc index 3e5af8f..8148956 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -924,10 +924,6 @@ void(float button, string key) setToBind = noref float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent = { - - if (last_input_deviceid != devid) - print(sprintf("device id swapped to %d\n", last_input_deviceid)); - last_input_deviceid = devid; if (evtype == IE_KEYDOWN) {