SFML community forums
Help => General => Topic started by: MrDoomMaster on November 30, 2007, 11:57:38 pm
-
Hi,
I was wondering if there was any functionality in SFML to facilitate relative cursor movement. For example, each time the MouseMove event is dispatched it would contain the delta x,y position of the cursor (as compared to its last position) instead of the absolute screen coordinates.
If it doesn't facilitate this behavior, I will need to do so myself. The only way I know how to do this is to manually move the cursor back to the center of the screen each time it is moved and calculate the change that way. Is there a way to set the cursor position? If so, does it generate MouseMove events? If it does, that will also be a problem as it will cause redundant and unauthentic MouseMove events.
Any tips on achieving this? Thanks.
-
The only way I know how to do this is to manually move the cursor back to the center of the screen each time it is moved and calculate the change that way
That's the way to do it (see sf::Window::SetCursorPosition). It generates mouse move events, but I'll see if I can remove them.
-
I don't see sf::Window::SetCursorPosition function in the docs. It's probably in SVN, so I don't have the exact header.
Anyway, You should be able to add one more argument to this function, and give a default value to it:
...
void SetCursorPosition(..., bool generateEvent = true);
...
That way, it won't break existing code, and will let people to change the position without generating an event in the new code.
-
That's what I'm going to do, I just need to check if the X11 and Win32 APIs can do it easily.
-
Laurent,
Did you ever figure out this issue? Right now I think SetCursorPosition is still generating WM_MOUSEMOVE events, which cause me to get additional redundant MouseMove messages.
-
No, sorry. I'll try to work on this soon.
-
Done ;)
As I couldn't find any reliable way to do it directly at the OS level, I added some simple code to sf::Window to discard MouseMoved events generated by SetCursorPosition.
-
Done ;)
As I couldn't find any reliable way to do it directly at the OS level, I added some simple code to sf::Window to discard MouseMoved events generated by SetCursorPosition.
Great! Thanks :)
Do you have a release date for SFML 1.3 (I'm assuming 1.3 is the next)?
-
Should be in the next few weeks, I'm mainly waiting for the MacOS port to be ready.