/*
===========
IN_Accumulate
===========
*/
void CL_DLLEXPORT IN_Accumulate(void)
{
	//only accumulate mouse if we are not moving the camera with the mouse
	if(!iMouseInUse && !g_iVisibleMouse)
	{
		if(mouseactive)
		{
#ifdef _WIN32
			if(!m_bRawInput)
			{
				if(!m_bMouseThread)
				{
					GetCursorPos(&current_pos);

					mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX();
					my_accum += current_pos.y - gEngfuncs.GetWindowCenterY();
				}
			}
			else
#endif
			{
				int deltaX, deltaY;
				SDL_GetRelativeMouseState(&deltaX, &deltaY);
				mx_accum += deltaX;
				my_accum += deltaY;
			}
			// force the mouse to the center, so there's room to move
			IN_ResetMouse();
		}
	}
}
Exemple #2
0
/*
===========
IN_Accumulate
===========
*/
void DLLEXPORT IN_Accumulate (void)
{
	//only accumulate mouse if we are not moving the camera with the mouse
	if ( !iMouseInUse && !g_iVisibleMouse )
	{
	    if (mouseactive)
	    {
			GetCursorPos (&current_pos);

			mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX();
			my_accum += current_pos.y - gEngfuncs.GetWindowCenterY();

			// force the mouse to the center, so there's room to move
			IN_ResetMouse();
		}
	}

}
Exemple #3
0
/*
===========
IN_Accumulate
===========
*/
void CL_DLLEXPORT IN_Accumulate (void)
{
	//only accumulate mouse if we are not moving the camera with the mouse
	if ( !iMouseInUse && !g_iVisibleMouse)
	{
	    if (mouseactive)
	    {
			int deltaX, deltaY;
			SDL_GetRelativeMouseState( &deltaX, &deltaY );
			mx_accum += deltaX;
			my_accum += deltaY;	
			// force the mouse to the center, so there's room to move
			IN_ResetMouse();
			
		}
	}

}
Exemple #4
0
/*
===========
IN_ActivateMouse
===========
*/
void CL_DLLEXPORT IN_ActivateMouse (void)
{
	if (mouseinitialized)
	{
#ifdef _WIN32
		bool lockEntered = MouseThread_ActiveLock_Enter();
#endif

		IN_SetMouseMode(true);

		mouseactive = 1;

#ifdef _WIN32
		UpdateMouseThreadActive();
		if(lockEntered) MouseThread_ActiveLock_Exit();
#endif

		// now is a good time to reset mouse positon:
		IN_ResetMouse();
	}
}
Exemple #5
0
/*
===========
IN_MouseMove
===========
*/
void IN_MouseMove ( float frametime, usercmd_t *cmd)
{
	int		mx, my;
	vec3_t viewangles;

	gEngfuncs.GetViewAngles( (float *)viewangles );

	if ( in_mlook.state & 1)
	{
		V_StopPitchDrift ();
	}

	//jjb - this disbles normal mouse control if the user is trying to 
	//      move the camera, or if the mouse cursor is visible or if we're in intermission
	if ( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission )
	{
		GetCursorPos (&current_pos);

		mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum;
		my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum;

		mx_accum = 0;
		my_accum = 0;

		if (m_filter->value)
		{
			mouse_x = (mx + old_mouse_x) * 0.5;
			mouse_y = (my + old_mouse_y) * 0.5;
		}
		else
		{
			mouse_x = mx;
			mouse_y = my;
		}

		old_mouse_x = mx;
		old_mouse_y = my;

		if ( gHUD.GetSensitivity() != 0 )
		{
			mouse_x *= gHUD.GetSensitivity();
			mouse_y *= gHUD.GetSensitivity();
		}
		else
		{
			mouse_x *= sensitivity->value;
			mouse_y *= sensitivity->value;
		}

		// add mouse X/Y movement to cmd
		if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) ))
			cmd->sidemove += m_side->value * mouse_x;
		else
			viewangles[YAW] -= m_yaw->value * mouse_x;

		if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
		{
			viewangles[PITCH] += m_pitch->value * mouse_y;
			if (viewangles[PITCH] > cl_pitchdown->value)
				viewangles[PITCH] = cl_pitchdown->value;
			if (viewangles[PITCH] < -cl_pitchup->value)
				viewangles[PITCH] = -cl_pitchup->value;
		}
		else
		{
			if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() )
			{
				cmd->upmove -= m_forward->value * mouse_y;
			}
			else
			{
				cmd->forwardmove -= m_forward->value * mouse_y;
			}
		}

		// if the mouse has moved, force it to the center, so there's room to move
		if ( mx || my )
		{
			IN_ResetMouse();
		}
	}

	gEngfuncs.SetViewAngles( (float *)viewangles );

/*
//#define TRACE_TEST
#if defined( TRACE_TEST )
	{
		int mx, my;
		void V_Move( int mx, int my );
		IN_GetMousePos( &mx, &my );
		V_Move( mx, my );
	}
#endif
*/
}
/*
===========
IN_MouseMove
===========
*/
void IN_MouseMove(float frametime, usercmd_t *cmd)
{
	int    mx, my;
	vec3_t viewangles;

	gEngfuncs.GetViewAngles((float *)viewangles);

	if(in_mlook.state & 1)
	{
		V_StopPitchDrift();
	}

	//jjb - this disbles normal mouse control if the user is trying to
	//      move the camera, or if the mouse cursor is visible or if we're in intermission
	if(!iMouseInUse && !gHUD.m_iIntermission && !g_iVisibleMouse)
	{
		int deltaX, deltaY;
#ifdef _WIN32
		if(!m_bRawInput)
		{
			if(m_bMouseThread)
			{
				ThreadInterlockedExchange(&current_pos.x, s_mouseDeltaX);
				ThreadInterlockedExchange(&current_pos.y, s_mouseDeltaY);
				ThreadInterlockedExchange(&s_mouseDeltaX, 0);
				ThreadInterlockedExchange(&s_mouseDeltaY, 0);
			}
			else
			{
				GetCursorPos(&current_pos);
			}
		}
		else
#endif
		{
			SDL_GetRelativeMouseState(&deltaX, &deltaY);
			current_pos.x = deltaX;
			current_pos.y = deltaY;
		}

#ifdef _WIN32
		if(!m_bRawInput)
		{
			if(m_bMouseThread)
			{
				mx = current_pos.x;
				my = current_pos.y;
			}
			else
			{
				mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum;
				my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum;
			}
		}
		else
#endif
		{
			mx = deltaX + mx_accum;
			my = deltaY + my_accum;
		}

		mx_accum = 0;
		my_accum = 0;

		if(m_filter && m_filter->value)
		{
			mouse_x = (mx + old_mouse_x) * 0.5;
			mouse_y = (my + old_mouse_y) * 0.5;
		}
		else
		{
			mouse_x = mx;
			mouse_y = my;
		}

		old_mouse_x = mx;
		old_mouse_y = my;

		// Apply custom mouse scaling/acceleration
		IN_ScaleMouse(&mouse_x, &mouse_y);

		// add mouse X/Y movement to cmd
		if((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
			cmd->sidemove += m_side->value * mouse_x;
		else
			viewangles[YAW] -= m_yaw->value * mouse_x;

		if((in_mlook.state & 1) && !(in_strafe.state & 1))
		{
			viewangles[PITCH] += m_pitch->value * mouse_y;
			if(viewangles[PITCH] > cl_pitchdown->value)
				viewangles[PITCH] = cl_pitchdown->value;
			if(viewangles[PITCH] < -cl_pitchup->value)
				viewangles[PITCH] = -cl_pitchup->value;
		}
		else
		{
			if((in_strafe.state & 1) && gEngfuncs.IsNoClipping())
			{
				cmd->upmove -= m_forward->value * mouse_y;
			}
			else
			{
				cmd->forwardmove -= m_forward->value * mouse_y;
			}
		}

		// if the mouse has moved, force it to the center, so there's room to move
		if(mx || my)
		{
			IN_ResetMouse();
		}
	}

	gEngfuncs.SetViewAngles((float *)viewangles);

	/*
//#define TRACE_TEST
#if defined( TRACE_TEST )
	{
		int mx, my;
		void V_Move( int mx, int my );
		IN_GetMousePos( &mx, &my );
		V_Move( mx, my );
	}
#endif
*/
}
Exemple #7
0
void IN_GetMouseDelta( int *pOutX, int *pOutY)
{
	bool active = mouseactive && !iVisibleMouse;
	int mx, my;

	if(active)
	{
		int deltaX, deltaY;
#ifdef _WIN32
		if ( !m_bRawInput )
		{
			if ( m_bMouseThread )
			{
				bool lockEntered = MouseThread_ActiveLock_Enter();

				current_pos.x = InterlockedExchange( &mouseThreadDeltaX, 0 );
				current_pos.y = InterlockedExchange( &mouseThreadDeltaY, 0 );

				if(lockEntered) MouseThread_ActiveLock_Exit();
			}
			else
			{
				GetCursorPos (&current_pos);
			}
		}
		else
#endif
		{
			SDL_GetRelativeMouseState( &deltaX, &deltaY );
			current_pos.x = deltaX;
			current_pos.y = deltaY;	
		}

#ifdef _WIN32
		if ( !m_bRawInput )
		{
			if ( m_bMouseThread )
			{
				mx = current_pos.x;
				my = current_pos.y;
			}
			else
			{
				mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum;
				my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum;
			}
		}
		else
#endif
		{
			mx = deltaX + mx_accum;
			my = deltaY + my_accum;
		}

		mx_accum = 0;
		my_accum = 0;

		// reset mouse position if required, so there is room to move:
#ifdef _WIN32
		// do not reset if mousethread would do it:
		if ( m_bRawInput || !m_bMouseThread )
#else
		if(true)
#endif
			IN_ResetMouse();

#ifdef _WIN32
		// update m_bRawInput occasionally: 
		if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f )
		{
			s_flRawInputUpdateTime = gpGlobals->time;

			bool lockEntered = MouseThread_ActiveLock_Enter();

			m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;

			if(m_bRawInput && !isMouseRelative)
			{
				SDL_SetRelativeMouseMode(SDL_TRUE);
				isMouseRelative = true;
			}
			else if(!m_bRawInput && isMouseRelative)
			{
				SDL_SetRelativeMouseMode(SDL_FALSE);
				isMouseRelative = false;
			}

			UpdateMouseThreadActive();
			if(lockEntered) MouseThread_ActiveLock_Exit();
		}
#endif
	}
	else
	{
		mx = my = 0;
	}

	if(pOutX) *pOutX = mx;
	if(pOutY) *pOutY = my;
}