MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CL_MouseMove

Function CL_MouseMove

code/client/cl_input.cpp:531–603  ·  view source on GitHub ↗

================= CL_MouseMove ================= */

Source from the content-addressed store, hash-verified

529=================
530*/
531void CL_MouseMove( usercmd_t *cmd ) {
532 float mx, my;
533 float accelSensitivity;
534 float rate;
535 const float speed = static_cast<float>(frame_msec);
536 const float pitch = m_pitch->value;
537
538 // allow mouse smoothing
539 if ( m_filter->integer ) {
540 mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
541 my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
542 } else {
543 mx = cl.mouseDx[cl.mouseIndex];
544 my = cl.mouseDy[cl.mouseIndex];
545 }
546
547 cl.mouseIndex ^= 1;
548 cl.mouseDx[cl.mouseIndex] = 0;
549 cl.mouseDy[cl.mouseIndex] = 0;
550
551 rate = SQRTFAST( mx * mx + my * my ) / speed;
552 accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
553
554 // scale by FOV
555 accelSensitivity *= cl.cgameSensitivity;
556
557 if ( rate && cl_showMouseRate->integer ) {
558 Com_Printf( "%f : %f\n", rate, accelSensitivity );
559 }
560
561 mx *= accelSensitivity;
562 my *= accelSensitivity;
563
564 if (!mx && !my) {
565 return;
566 }
567
568 // add mouse X/Y movement to cmd
569 if ( in_strafe.active ) {
570 cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
571 } else {
572 if ( cl_mYawOverride )
573 {
574 cl.viewangles[YAW] -= cl_mYawOverride * mx;
575 }
576 else
577 {
578 cl.viewangles[YAW] -= m_yaw->value * mx;
579 }
580 }
581
582 if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
583 // VVFIXME - This is supposed to be a CVAR
584 const float cl_pitchSensitivity = 1.0f;
585 if ( cl_mPitchOverride )
586 {
587 if ( pitch > 0 )
588 {

Callers 1

CL_CreateCmdFunction · 0.70

Calls 2

ClampCharFunction · 0.85
Com_PrintfFunction · 0.50

Tested by

no test coverage detected