From 837ee9e99b31a4c84619c27ba2dffc08d9143063 Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Fri, 7 Nov 2025 22:18:07 -0500 Subject: [PATCH 1/9] basic sar_sensitivity --- src/Features/Sensitivity.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Features/Sensitivity.cpp diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp new file mode 100644 index 00000000..6e2fd3c3 --- /dev/null +++ b/src/Features/Sensitivity.cpp @@ -0,0 +1,19 @@ +#include "Command.hpp" +#include "Modules/Engine.hpp" +#include "Variable.hpp" + + +auto sensitivity = Variable("sensitivity"); +auto m_yaw = Variable("m_yaw"); + +CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitivity to the specified cm/360 value based on the supplied dpi value\n") { + if (args.ArgC() != 3) { + return console->Print(sar_sensitivity.ThisPtr()->m_pszHelpString); + } + + double cm_per_three_sixty = std::atof(args[1]); + double dpi = std::atof(args[2]); + double new_sens = 914.4 / (cm_per_three_sixty * (dpi * m_yaw.GetFloat())); + + sensitivity.SetValue((float)new_sens); +} From 43015b851c2c86d5674fadad42b9bb80bfb0bbca Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 02:31:27 -0500 Subject: [PATCH 2/9] added m_rawinput 0 support for windows --- src/Features/Sensitivity.cpp | 38 ++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 6e2fd3c3..1705d89a 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -3,17 +3,47 @@ #include "Variable.hpp" -auto sensitivity = Variable("sensitivity"); -auto m_yaw = Variable("m_yaw"); +#ifdef _WIN32 +# include +#endif + +// Liquipedia Counterstrike https://liquipedia.net/counterstrike/Mouse_Settings#Windows_Sensitivity +const float multiplierEnhancedOff[] = {0.03125, 0.0625, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5}; CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitivity to the specified cm/360 value based on the supplied dpi value\n") { + auto sensitivity = Variable("sensitivity"); + auto m_yaw = Variable("m_yaw"); + auto m_rawinput = Variable("m_rawinput"); if (args.ArgC() != 3) { return console->Print(sar_sensitivity.ThisPtr()->m_pszHelpString); } - double cm_per_three_sixty = std::atof(args[1]); + double cmPerThreeSixty = std::atof(args[1]); double dpi = std::atof(args[2]); - double new_sens = 914.4 / (cm_per_three_sixty * (dpi * m_yaw.GetFloat())); +#ifdef _WIN32 + if (!m_rawinput.GetBool()){ + // whole thing relies on the m_rawinput if that shit is on then it do not matter + // first two values of this area are lowkey not useful in this situation i think we just need the last one + int getMouseInfo[3]; + int winMouseSens; + SystemParametersInfo(SPI_GETMOUSE, 0, &getMouseInfo, 0); + SystemParametersInfo(SPI_GETMOUSESPEED, 0, &winMouseSens, 0); + if (getMouseInfo[2]){ + /* if true then Enhanced Pointer Performance is on. + * conveniently the multiplier when this is the case is just 1/10th the setting + * AS FAR AS I AM AWARE: this is how it essentially works, because at default setting (10, or 1.0) + * every dot the cursor is moved 1 pixel + * and such at non default values it is getting scaled + */ + dpi = dpi * (winMouseSens / 10); + } else { + // otherwise its easier to just look it up in this array + dpi = dpi * multiplierEnhancedOff[winMouseSens - 1]; + } + } +#endif + + double new_sens = 914.4 / (cmPerThreeSixty * (dpi * m_yaw.GetFloat())); sensitivity.SetValue((float)new_sens); } From e16e696ab27bfe0897584c62d4f911d3dcbeb5b8 Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 02:48:11 -0500 Subject: [PATCH 3/9] static variables --- src/Features/Sensitivity.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 1705d89a..3677cd61 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -11,9 +11,9 @@ const float multiplierEnhancedOff[] = {0.03125, 0.0625, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5}; CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitivity to the specified cm/360 value based on the supplied dpi value\n") { - auto sensitivity = Variable("sensitivity"); - auto m_yaw = Variable("m_yaw"); - auto m_rawinput = Variable("m_rawinput"); + static auto sensitivity = Variable("sensitivity"); + static auto m_yaw = Variable("m_yaw"); + static auto m_rawinput = Variable("m_rawinput"); if (args.ArgC() != 3) { return console->Print(sar_sensitivity.ThisPtr()->m_pszHelpString); } From 588028fded3e2f307a3b745390273c4a9ef064cc Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 12:36:51 -0500 Subject: [PATCH 4/9] check to make sure SystemParametersInfo actually returns --- src/Features/Sensitivity.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 3677cd61..0fd3734f 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -27,20 +27,25 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitiv // first two values of this area are lowkey not useful in this situation i think we just need the last one int getMouseInfo[3]; int winMouseSens; - SystemParametersInfo(SPI_GETMOUSE, 0, &getMouseInfo, 0); - SystemParametersInfo(SPI_GETMOUSESPEED, 0, &winMouseSens, 0); - if (getMouseInfo[2]){ - /* if true then Enhanced Pointer Performance is on. - * conveniently the multiplier when this is the case is just 1/10th the setting - * AS FAR AS I AM AWARE: this is how it essentially works, because at default setting (10, or 1.0) - * every dot the cursor is moved 1 pixel - * and such at non default values it is getting scaled - */ - dpi = dpi * (winMouseSens / 10); + bool mouseAccel = SystemParametersInfo(SPI_GETMOUSE, 0, &getMouseInfo, 0); + bool mouseSpeed = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &winMouseSens, 0); + if (mouseAccel && mouseSpeed){ + if (getMouseInfo[2]){ + /* if true then Enhanced Pointer Performance is on. + * conveniently the multiplier when this is the case is just 1/10th the setting + * AS FAR AS I AM AWARE: this is how it essentially works, because at default setting (10, or 1.0) + * every dot the cursor is moved 1 pixel + * and such at non default values it is getting scaled + */ + dpi = dpi * (winMouseSens / 10); + } else { + // otherwise its easier to just look it up in this array + dpi = dpi * multiplierEnhancedOff[winMouseSens - 1]; + } } else { - // otherwise its easier to just look it up in this array - dpi = dpi * multiplierEnhancedOff[winMouseSens - 1]; + console->Print("Could not retrieve windows mouse settings, sens may not be calculated correctly\n"); } + } #endif From 1fd516756b0f31891bd58853113b04aff742e96d Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 13:31:25 -0500 Subject: [PATCH 5/9] added inches support and choosing whether to use cm or inches --- src/Features/Sensitivity.cpp | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 0fd3734f..6f75e1c7 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -7,36 +7,47 @@ # include #endif -// Liquipedia Counterstrike https://liquipedia.net/counterstrike/Mouse_Settings#Windows_Sensitivity +// Liquipedia Counterstrike https://liquipedia.net/counterstrike/Mouse_Settings#Windows_Sensitivity const float multiplierEnhancedOff[] = {0.03125, 0.0625, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5}; -CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitivity to the specified cm/360 value based on the supplied dpi value\n") { - static auto sensitivity = Variable("sensitivity"); - static auto m_yaw = Variable("m_yaw"); - static auto m_rawinput = Variable("m_rawinput"); - if (args.ArgC() != 3) { +CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes the sensitivity to match the amount of distance the mouse needs to travel to turn one whole 360.\n") { + double distanceConstant; + if (args.ArgC() == 4) { + if (!strcmp(args[1], "cm")) { + distanceConstant = 914.4; + } else if (!strcmp(args[1], "in")) { + distanceConstant = 360; + } else { + return console->Print("Cannot parse unit entered, options are cm or in\n"); + } + } else { return console->Print(sar_sensitivity.ThisPtr()->m_pszHelpString); } - double cmPerThreeSixty = std::atof(args[1]); - double dpi = std::atof(args[2]); + static auto sensitivity = Variable("sensitivity"); + static auto m_yaw = Variable("m_yaw"); + static auto m_rawinput = Variable("m_rawinput"); + double distance = std::atof(args[2]); + double dpi = std::atof(args[3]); + #ifdef _WIN32 - if (!m_rawinput.GetBool()){ + if (!m_rawinput.GetBool()) { // whole thing relies on the m_rawinput if that shit is on then it do not matter // first two values of this area are lowkey not useful in this situation i think we just need the last one int getMouseInfo[3]; int winMouseSens; bool mouseAccel = SystemParametersInfo(SPI_GETMOUSE, 0, &getMouseInfo, 0); bool mouseSpeed = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &winMouseSens, 0); - if (mouseAccel && mouseSpeed){ - if (getMouseInfo[2]){ + + if (mouseAccel && mouseSpeed) { + if (getMouseInfo[2]) { /* if true then Enhanced Pointer Performance is on. - * conveniently the multiplier when this is the case is just 1/10th the setting - * AS FAR AS I AM AWARE: this is how it essentially works, because at default setting (10, or 1.0) - * every dot the cursor is moved 1 pixel - * and such at non default values it is getting scaled - */ + * conveniently the multiplier when this is the case is just 1/10th the setting + * AS FAR AS I AM AWARE: this is how it essentially works, because at default setting (10, or 1.0) + * every dot the cursor is moved 1 pixel + * and such at non default values it is getting scaled + */ dpi = dpi * (winMouseSens / 10); } else { // otherwise its easier to just look it up in this array @@ -45,10 +56,9 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - sets the sensitiv } else { console->Print("Could not retrieve windows mouse settings, sens may not be calculated correctly\n"); } - } #endif - double new_sens = 914.4 / (cmPerThreeSixty * (dpi * m_yaw.GetFloat())); + double new_sens = distanceConstant / (distance * (dpi * m_yaw.GetFloat())); sensitivity.SetValue((float)new_sens); } From 5eaa239c4fc24a7b2aa68a38eac0216f00f4fed2 Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 22:58:49 -0500 Subject: [PATCH 6/9] add linux m_rawinput 0 disclaimer --- src/Features/Sensitivity.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 6f75e1c7..57e0012c 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -31,8 +31,9 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes double distance = std::atof(args[2]); double dpi = std::atof(args[3]); -#ifdef _WIN32 + if (!m_rawinput.GetBool()) { +#ifdef _WIN32 // whole thing relies on the m_rawinput if that shit is on then it do not matter // first two values of this area are lowkey not useful in this situation i think we just need the last one int getMouseInfo[3]; @@ -56,9 +57,11 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes } else { console->Print("Could not retrieve windows mouse settings, sens may not be calculated correctly\n"); } - } + +#else + console->Print("m_rawinput 0 may be inaccurate on linux\n"); #endif - + } double new_sens = distanceConstant / (distance * (dpi * m_yaw.GetFloat())); sensitivity.SetValue((float)new_sens); } From 7dd20135b6b2477583ad509b0fff43fd07bac208 Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sat, 8 Nov 2025 23:02:26 -0500 Subject: [PATCH 7/9] slightly better message --- src/Features/Sensitivity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 57e0012c..0a6a0537 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -59,7 +59,7 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes } #else - console->Print("m_rawinput 0 may be inaccurate on linux\n"); + console->Print("m_rawinput 0 may make sar_sensitivity inaccurate on linux\n"); #endif } double new_sens = distanceConstant / (distance * (dpi * m_yaw.GetFloat())); From 0ae59b9766d74a4de4bb0901cab4be7763791cce Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Sun, 9 Nov 2025 00:24:19 -0500 Subject: [PATCH 8/9] fix: winmousesens division --- src/Features/Sensitivity.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Features/Sensitivity.cpp b/src/Features/Sensitivity.cpp index 0a6a0537..38876c7d 100644 --- a/src/Features/Sensitivity.cpp +++ b/src/Features/Sensitivity.cpp @@ -30,7 +30,7 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes double distance = std::atof(args[2]); double dpi = std::atof(args[3]); - + if (!m_rawinput.GetBool()) { #ifdef _WIN32 @@ -49,15 +49,15 @@ CON_COMMAND(sar_sensitivity, "sar_sensitivity - changes * every dot the cursor is moved 1 pixel * and such at non default values it is getting scaled */ - dpi = dpi * (winMouseSens / 10); + dpi *= winMouseSens / 10.0f; } else { // otherwise its easier to just look it up in this array - dpi = dpi * multiplierEnhancedOff[winMouseSens - 1]; + dpi *= multiplierEnhancedOff[winMouseSens - 1]; } } else { console->Print("Could not retrieve windows mouse settings, sens may not be calculated correctly\n"); } - + #else console->Print("m_rawinput 0 may make sar_sensitivity inaccurate on linux\n"); #endif From a04d449435e617870cb479a16625ca2a33873bc4 Mon Sep 17 00:00:00 2001 From: Ellie <19760814+ellzie@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:26:37 -0500 Subject: [PATCH 9/9] docs: cvars --- docs/cvars.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/cvars.md b/docs/cvars.md index 59291ac0..9c750da6 100644 --- a/docs/cvars.md +++ b/docs/cvars.md @@ -501,6 +501,7 @@ |sar_scrollspeed_x|0|Scroll speed HUD x offset.| |sar_scrollspeed_y|210|Scroll speed HUD y offset.| |sar_seamshot_finder|0|Enables or disables seamshot finder overlay.| +|sar_sensitivity|cmd|sar_sensitivity \ \ \ - changes the sensitivity to match the amount of distance the mouse needs to travel to turn one whole 360.| |sar_session|cmd|sar_session - prints the current tick of the server since it has loaded| |sar_show_entinp|0|Print all entity inputs to console.| |sar_skiptodemo|cmd|sar_skiptodemo \ - skip demos in demo queue to this demo|