Keeping my mouse cursor within my program...

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
Miik3h
Posts: 9
Joined: Mon Oct 17, 2005 1:08 am
Location: Australia

Keeping my mouse cursor within my program...

Post by Miik3h »

Hi,

With FPS Camera the mouse gets "stuck" inside my programs 'window' ie. I keep moving it too the left and it just stays within my window...

However with a Non-FPS Camera the mouse cursor falls outta my window... so if I keep moving it too the left it will fall out onto the background window...

(I am using Newton and so I needed to emulate the FPS camera from a normal camera using Newton forces to move it around...)

Any ideas how I can trap the mouse ~cursor~ within my program?...

Thanks,
Miik3h
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

re:

Post by Conquistador »

Miik3h
Posts: 9
Joined: Mon Oct 17, 2005 1:08 am
Location: Australia

Post by Miik3h »

Thanks for a reply,

But it doesn't seem to help... :roll:
Guest

Post by Guest »

Simple stuff - just keep setting the mousecursor position to dead centre and read it of relatively (if you are controlling say a breakout bat, or turning a mesh) - if you want freedom to move the cursor around WITHIN the window then simply do a check - if mouse cursor X < > screen extents then set mouse cursor x TO screen extent - it will NEVER go out if you do it properly to cover for FAST moves,
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

I just went through this problem myself. You can find my source at http://www.s-fonline.com/webhosting/dhenton9000, the Newton Irrlicht demo.

What I did, which isn't the best idea is related to other suggestions that you got here. In the mousehandling OnEvent, I obtain the mouse position compare it to last mouse position I've saved, compute the difference, and replace the old mouse position with the new one. Using that difference, I set a rotation angle, which is used for rotation. Then in my game loop, after render, I check to see if my mouse is getting close to out of bounds (via ICursorControl) and pop it back to the center if I need to.


HTH
Post Reply