void CInput::MouseMove( CUserCmd *cmd )
{
float mouse_x, mouse_y;
float mx, my;
QAngle viewangles;
// Get view angles from engine
engine->GetViewAngles( viewangles );
// Validate mouse speed/acceleration settings
CheckMouseAcclerationVars();
// Don't drift pitch at all while mouselooking.
view->StopPitchDrift ();
//jjb - this disables normal mouse control if the user is trying to
// move the camera, or if the mouse cursor is visible
if ( !m_fCameraInterceptingMouse &&
!vgui::surface()->IsCursorVisible() )
{
// Sample mouse one more time
AccumulateMouse();
// Latch accumulated mouse movements and reset accumulators
GetAccumulatedMouseDeltasAndResetAccumulators( &mx, &my );
// Filter, etc. the delta values and place into mouse_x and mouse_y
GetMouseDelta( mx, my, &mouse_x, &mouse_y );
// Apply scaling factor
ScaleMouse( &mouse_x, &mouse_y );
// Let the client mode at the mouse input before it's used
g_pClientMode->OverrideMouseInput( &mouse_x, &mouse_y );
// Add mouse X/Y movement to cmd
ApplyMouse( viewangles, cmd, mouse_x, mouse_y );
// Re-center the mouse.
ResetMouse();
}
// Store out the new viewangles.
engine->SetViewAngles( viewangles );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *mx -
// *my -
// *unclampedx -
// *unclampedy -
//-----------------------------------------------------------------------------
void CInput::GetFullscreenMousePos( int *mx, int *my, int *unclampedx /*=NULL*/, int *unclampedy /*=NULL*/ )
{
Assert( mx );
Assert( my );
if ( !vgui::surface()->IsCursorVisible() )
{
return;
}
int x, y;
GetWindowCenter( x, y );
int current_posx, current_posy;
GetMousePos(current_posx, current_posy);
current_posx -= x;
current_posy -= y;
// Now need to add back in mid point of viewport
//
int w, h;
vgui::surface()->GetScreenSize( w, h );
current_posx += w / 2;
current_posy += h / 2;
if ( unclampedx )
{
*unclampedx = current_posx;
}
if ( unclampedy )
{
*unclampedy = current_posy;
}
// Clamp
current_posx = MAX( 0, current_posx );
current_posx = MIN( ScreenWidth(), current_posx );
current_posy = MAX( 0, current_posy );
current_posy = MIN( ScreenHeight(), current_posy );
*mx = current_posx;
*my = current_posy;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : mx -
// my -
//-----------------------------------------------------------------------------
void CInput::SetFullscreenMousePos( int mx, int my )
{
SetMousePos( mx, my );
}