Window Mode Mouse Boundaries

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
[ds] Swift
Posts: 20
Joined: Sun Nov 14, 2004 1:57 am
Location: Rochester, New York, USA

Window Mode Mouse Boundaries

Post by [ds] Swift »

while not fullscreen is there a way that i can keep the mouse pointer from leaving the window? I want to be able to move my mouse all the way up to any edge of the window and the have it stop.
There's a crack in everything -- That's how the light gets in.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Code: Select all

int maxX = m_gameCore->GetVideoDriver ( )->getViewPort ( ).LowerRightCorner.X;
int maxY = m_gameCore->GetVideoDriver ( )->getViewPort ( ).LowerRightCorner.Y;

if ( m_mouseLocation.X < 0 || m_mouseLocation.Y < 0 || m_mouseLocation.X > maxX || m_mouseLocation.Y > maxY )
{
	if ( m_mouseLocation.X < 0 )
		m_mouseLocation.X = 0;
	else if ( m_mouseLocation.X > maxX )
		m_mouseLocation.X = maxX;

	if ( m_mouseLocation.Y < 0 )
		m_mouseLocation.Y = 0;
	else if ( m_mouseLocation.Y > maxY )
		m_mouseLocation.Y = maxY;

	m_gameCore->GetDevice ( )->getCursorControl ( )->setPosition ( m_mouseLocation.X, m_mouseLocation.Y );
}
[ds] Swift
Posts: 20
Joined: Sun Nov 14, 2004 1:57 am
Location: Rochester, New York, USA

Thanks

Post by [ds] Swift »

thanks spintz, that worked perfectly!!!
There's a crack in everything -- That's how the light gets in.
Post Reply