Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float mouse_sensitivity = ( gHUD.GetSensitivity() != 0 ) // mouse sens != 0
- ? gHUD.GetSensitivity() : sensitivity.GetFloat(); //get mouse sens
- if ( m_customaccel.GetInt() == 1 || m_customaccel.GetInt() == 2 ) //if m_customaccel == 1 || == 2
- {
- float raw_mouse_movement_distance = sqrt( mx * mx + my * my ); //linear curve where sqrt(mx * mx) = mx
- float acceleration_scale = m_customaccel_scale.GetFloat(); // scale of acceleration
- float accelerated_sensitivity_max = m_customaccel_max.GetFloat(); //max sensitivity you can reach
- float accelerated_sensitivity_exponent = m_customaccel_exponent.GetFloat(); //exponent = movement raised to the power of exponent
- float accelerated_sensitivity = ( (float)pow( raw_mouse_movement_distance, accelerated_sensitivity_exponent ) * acceleration_scale + mouse_sensitivity ); //((power of float(distance of linear movement, exponent)) * scale + mouse_sensitivity)
- if ( accelerated_sensitivity_max > 0.0001f &&
- accelerated_sensitivity > accelerated_sensitivity_max ) //if accelerated max > 0.0001 and accelerated sens is over max
- {
- accelerated_sensitivity = accelerated_sensitivity_max; //set accelerated sens to max
- }
- *x *= accelerated_sensitivity; //multiply movement by accelerated sensitivity on pitch
- *y *= accelerated_sensitivity; //multiply movement by accelerated sensitivity on yaw
- if ( m_customaccel.GetInt() == 2 || m_customaccel.GetInt() == 4 ) //if m_customaccel == 2 || == 4
- {
- *x *= m_yaw.GetFloat(); //use m_yaw value for accel
- *y *= m_pitch->GetFloat(); //use m_pitch value for accel
- }
- }
- else if ( m_customaccel.GetInt() == 3 )
- {
- float raw_mouse_movement_distance_squared = mx * mx + my * my; //hyperbola where (mx * mx) = (mx ^ 2)
- float fExp = MAX(0.0f, (m_customaccel_exponent.GetFloat() - 1.0f) / 2.0f); //returns largest of (0.0f) and (m_customaccel_exponent - 1.0f) / 2.0f) if both are the same, 0.0f is returned.
- float accelerated_sensitivity = powf( raw_mouse_movement_distance_squared, fExp ) * mouse_sensitivity; //power of float (movement distance in hyperbola, result of exponent) * mouse_sensitivity;
- *x *= accelerated_sensitivity; //multiply movement by accelerated sensitivity on pitch
- *y *= accelerated_sensitivity; //multiply movement by accelerated sensitivity on yaw
- }
- else
- {
- *x *= mouse_sensitivity; //if accel is not enabled, handle mouse sensitivity normally on pitch
- *y *= mouse_sensitivity; //if accel is not enabled, handle mouse sensitivity normally on yaw
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement