SFML community forums

Help => Window => Topic started by: scyth3s on January 27, 2015, 05:01:59 am

Title: Hardware Position of mouse?
Post by: scyth3s on January 27, 2015, 05:01:59 am
Is it possible in SFML a position for the mouse that does not correspond to the position of a window or the desktop itself? For instance, in any 3D game where mouse controls camera, I need to be able to find out movement of the mouse event if it would go beyond the edge of the screen.  I didn't see anything like this in the documentation, but I've also been known to miss things now and again when perusing through.
Title: Re: Hardware Position of mouse?
Post by: Ixrec on January 27, 2015, 08:36:33 am
It sounds like you're asking for the ability to "capture" the mouse.  Some work has been done on this feature (https://github.com/SFML/SFML/pull/614) but I don't think it's been finished yet.  You can try building that branch yourself if you need this feature.
Title: Re: Hardware Position of mouse?
Post by: Hapax on January 27, 2015, 07:27:58 pm
There was something posted in this forum that would work as a work-around in similar situations.
The idea is to lock the mouse cursor (constantly set its position each cycle) but take note of its delta before resetting the position. Then, just use the delta in your code (or store an accumulation).

It's probably best to hide the cursor if you use this method.
Also, you will need to make sure you cover the fact that you can't move the mouse so no interactions with other windows or closing/exiting with the mouse, for example.
Title: Re: Hardware Position of mouse?
Post by: scyth3s on January 28, 2015, 02:46:45 pm
I like that idea... So simple. Just "unlock" the mouse as soon as the user reaches a menu screen or any situation where mouse use is required. Thank you!