Skip to content

Commit 83cc4b3

Browse files
committed
Migrate mouse acceleration cvars cl_mouseAccel*
1 parent 49559a3 commit 83cc4b3

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

src/engine/client/cl_input.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ Maryland 20850 USA.
4040
#include "engine/qcommon/sys.h"
4141
#include "framework/CommandSystem.h"
4242

43+
static Cvar::Cvar<float> cl_mouseAccel(
44+
"cl_mouseAccel", "mouse acceleration strength", Cvar::NONE, 0);
45+
static Cvar::Range<Cvar::Cvar<int>> cl_mouseAccelStyle(
46+
"cl_mouseAccelStyle", "mouse acceleration - 0: 'legacy' quadratic, 1: 'new' exponential",
47+
Cvar::NONE, 0, 0, 1);
48+
static Cvar::Range<Cvar::Cvar<float>> cl_mouseAccelOffset(
49+
"cl_mouseAccelOffset", "accel style 1 characteristic mouse speed (higher = less accel)",
50+
Cvar::NONE, 5, 0.001, 999);
51+
4352
static Cvar::Cvar<bool> in_gameControllerAvailable(
4453
"in_gameControllerAvailable", "whether controller is a gamepad (as opposed to joystick)",
4554
Cvar::ROM, false);
@@ -536,16 +545,16 @@ void CL_MouseMove( usercmd_t *cmd )
536545
return;
537546
}
538547

539-
if ( cl_mouseAccel->value != 0.0f )
548+
if ( cl_mouseAccel.Get() != 0.0f )
540549
{
541-
if ( cl_mouseAccelStyle->integer == 0 )
550+
if ( cl_mouseAccelStyle.Get() == 0 )
542551
{
543552
float accelSensitivity;
544553
float rate;
545554

546555
rate = sqrt( mx * mx + my * my ) / ( float ) frame_msec;
547556

548-
accelSensitivity = cvar_sensitivity.Get() + rate * cl_mouseAccel->value;
557+
accelSensitivity = cvar_sensitivity.Get() + rate * cl_mouseAccel.Get();
549558
mx *= accelSensitivity;
550559
my *= accelSensitivity;
551560
}
@@ -557,15 +566,16 @@ void CL_MouseMove( usercmd_t *cmd )
557566
// sensitivity remains pretty much unchanged at low speeds
558567
// cl_mouseAccel is a power value to how the acceleration is shaped
559568
// cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplification
569+
// cl_mouseAccelOffset should be set to the max rate value
560570
// NOTE: decouple the config cvars for independent acceleration setup along X and Y?
561571

562572
rate[ 0 ] = fabsf( mx ) / ( float ) frame_msec;
563573
rate[ 1 ] = fabsf( my ) / ( float ) frame_msec;
564-
power[ 0 ] = powf( rate[ 0 ] / cl_mouseAccelOffset->value, cl_mouseAccel->value );
565-
power[ 1 ] = powf( rate[ 1 ] / cl_mouseAccelOffset->value, cl_mouseAccel->value );
574+
power[ 0 ] = powf( rate[ 0 ] / cl_mouseAccelOffset.Get(), cl_mouseAccel.Get() );
575+
power[ 1 ] = powf( rate[ 1 ] / cl_mouseAccelOffset.Get(), cl_mouseAccel.Get());
566576

567-
mx = cvar_sensitivity.Get() * ( mx + ( ( mx < 0 ) ? -power[ 0 ] : power[ 0 ] ) * cl_mouseAccelOffset->value );
568-
my = cvar_sensitivity.Get() * ( my + ( ( my < 0 ) ? -power[ 1 ] : power[ 1 ] ) * cl_mouseAccelOffset->value );
577+
mx = cvar_sensitivity.Get() * ( mx + ( ( mx < 0 ) ? -power[ 0 ] : power[ 0 ] ) * cl_mouseAccelOffset.Get() );
578+
my = cvar_sensitivity.Get() * ( my + ( ( my < 0 ) ? -power[ 1 ] : power[ 1 ] ) * cl_mouseAccelOffset.Get() );
569579
}
570580
}
571581
else

src/engine/client/cl_main.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,16 +2322,6 @@ void CL_Init()
23222322
cl_maxpackets = Cvar_Get( "cl_maxpackets", "125", 0 );
23232323
cl_packetdup = Cvar_Get( "cl_packetdup", "1", 0 );
23242324

2325-
cl_mouseAccel = Cvar_Get( "cl_mouseAccel", "0", 0 );
2326-
2327-
// 0: legacy mouse acceleration
2328-
// 1: new implementation
2329-
2330-
cl_mouseAccelStyle = Cvar_Get( "cl_mouseAccelStyle", "0", 0 );
2331-
// offset for the power function (for style 1, ignored otherwise)
2332-
// this should be set to the max rate value
2333-
cl_mouseAccelOffset = Cvar_Get( "cl_mouseAccelOffset", "5", 0 );
2334-
23352325
cl_allowDownload = Cvar_Get( "cl_allowDownload", "1", 0 );
23362326

23372327
cl_consoleFontKerning = Cvar_Get( "cl_consoleFontKerning", "0", 0 );

src/engine/client/client.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,6 @@ extern Cvar::Range<Cvar::Cvar<int>> cl_doubletapdelay;
399399
extern cvar_t *cl_sensitivity;
400400
extern Cvar::Cvar<bool> cl_freelook;
401401

402-
extern cvar_t *cl_mouseAccel;
403-
extern cvar_t *cl_mouseAccelOffset;
404-
extern cvar_t *cl_mouseAccelStyle;
405-
406402
extern Cvar::Cvar<float> m_pitch;
407403
extern Cvar::Cvar<float> m_yaw;
408404
extern Cvar::Cvar<float> m_forward;

0 commit comments

Comments
 (0)