diff options
Diffstat (limited to 'src/client/cl_input.c')
-rw-r--r-- | src/client/cl_input.c | 96 |
1 files changed, 66 insertions, 30 deletions
diff --git a/src/client/cl_input.c b/src/client/cl_input.c index 49551662..19bdb95a 100644 --- a/src/client/cl_input.c +++ b/src/client/cl_input.c @@ -436,52 +436,88 @@ void CL_JoystickMove( usercmd_t *cmd ) { CL_MouseMove ================= */ -void CL_MouseMove( usercmd_t *cmd ) { - float mx, my; - float accelSensitivity; - float rate; + +void CL_MouseMove(usercmd_t *cmd) +{ + float mx, my; // allow mouse smoothing - if ( m_filter->integer ) { - mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5; - my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5; - } else { + if (m_filter->integer) + { + mx = (cl.mouseDx[0] + cl.mouseDx[1]) * 0.5f; + my = (cl.mouseDy[0] + cl.mouseDy[1]) * 0.5f; + } + else + { mx = cl.mouseDx[cl.mouseIndex]; my = cl.mouseDy[cl.mouseIndex]; } + cl.mouseIndex ^= 1; cl.mouseDx[cl.mouseIndex] = 0; cl.mouseDy[cl.mouseIndex] = 0; - rate = sqrt( mx * mx + my * my ) / (float)frame_msec; - accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value; - - // scale by FOV - accelSensitivity *= cl.cgameSensitivity; - - if ( rate && cl_showMouseRate->integer ) { - Com_Printf( "%f : %f\n", rate, accelSensitivity ); - } - - mx *= accelSensitivity; - my *= accelSensitivity; - - if (!mx && !my) { + if (mx == 0.0f && my == 0.0f) return; + + if (cl_mouseAccel->value != 0.0f) + { + if(cl_mouseAccelStyle->integer == 0) + { + float accelSensitivity; + float rate; + + rate = sqrt(mx * mx + my * my) / (float) frame_msec; + + accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value; + mx *= accelSensitivity; + my *= accelSensitivity; + + if(cl_showMouseRate->integer) + Com_Printf("rate: %f, accelSensitivity: %f\n", rate, accelSensitivity); + } + else + { + float rate[2]; + float power[2]; + + // sensitivity remains pretty much unchanged at low speeds + // cl_mouseAccel is a power value to how the acceleration is shaped + // cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplification + // NOTE: decouple the config cvars for independent acceleration setup along X and Y? + + rate[0] = fabs(mx) / (float) frame_msec; + rate[1] = fabs(my) / (float) frame_msec; + power[0] = powf(rate[0] / cl_mouseAccelOffset->value, cl_mouseAccel->value); + power[1] = powf(rate[1] / cl_mouseAccelOffset->value, cl_mouseAccel->value); + + mx = cl_sensitivity->value * (mx + ((mx < 0) ? -power[0] : power[0]) * cl_mouseAccelOffset->value); + my = cl_sensitivity->value * (my + ((my < 0) ? -power[1] : power[1]) * cl_mouseAccelOffset->value); + + if(cl_showMouseRate->integer) + Com_Printf("ratex: %f, ratey: %f, powx: %f, powy: %f\n", rate[0], rate[1], power[0], power[1]); + } } + else + { + mx *= cl_sensitivity->value; + my *= cl_sensitivity->value; + } + + // ingame FOV + mx *= cl.cgameSensitivity; + my *= cl.cgameSensitivity; // add mouse X/Y movement to cmd - if ( in_strafe.active ) { - cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx ); - } else { + if(in_strafe.active) + cmd->rightmove = ClampChar(cmd->rightmove + m_side->value * mx); + else cl.viewangles[YAW] -= m_yaw->value * mx; - } - if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) { + if ((in_mlooking || cl_freelook->integer) && !in_strafe.active) cl.viewangles[PITCH] += m_pitch->value * my; - } else { - cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my ); - } + else + cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward->value * my); } |