Windowed mode mouse clipping suggestion

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Legion
Posts: 15
Joined: Sun Oct 29, 2006 5:03 pm

Windowed mode mouse clipping suggestion

Post by Legion »

Hey!

My suggestion is adding support for mouse confinement in windowed mode. (clipping)
This isn't really an extremly important feature,
normally it's ok if the mouse isn't locked to the window.
It can bring some annoyment though especially in point and click games,
in my case an RPG game, if you happen to run in windowed mode.

My first idea was to intercept mouse events, locking the mouse in middle
window and handling the cursor virtually.
It has one problem though, GUI won't function since it depend on the event system,
i was hoping to use the native GUI system (although with extensions).

It would work to use "custom" device creation and make sure
coordinates are clipped, but if anything calls getPosition we're screwed.

I could make a little patch for this, incase anyone else is interested.

/Legion
Grey Lantern
Posts: 34
Joined: Sat Jul 30, 2005 9:45 am
Contact:

Post by Grey Lantern »

This is already possible on Windows using a win32 function "ClipCursor()" no patch needed.

Code: Select all

GetWindowRect(gHwnd, &gWindowMouseRegion);
gWindowMouseRegion.top+=gScreenHeight/2;
gWindowMouseRegion.left+=70;
gWindowMouseRegion.bottom-=20;
gWindowMouseRegion.right-=70;
ClipCursor(&gWindowMouseRegion);
Cursor will *NOT* leave the window. You can also set an abitrary rect of any size to restrict the cursor to. When you pause your game just free the cursor using ClipCursor(NULL).
Legion
Posts: 15
Joined: Sun Oct 29, 2006 5:03 pm

Post by Legion »

I see, didn't know about that windows API function heh
Well that makes everything easier.
Post Reply