Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Relative Cursor Movement  (Read 6153 times)

0 Members and 1 Guest are viewing this topic.

MrDoomMaster

  • Newbie
  • *
  • Posts: 26
    • View Profile
Relative Cursor Movement
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Relative Cursor Movement
« Reply #1 on: December 01, 2007, 11:07:07 am »
Quote
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.
Laurent Gomila - SFML developer

PM

  • Newbie
  • *
  • Posts: 18
    • View Profile
Relative Cursor Movement
« Reply #2 on: December 01, 2007, 04:12:43 pm »
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:
Code: [Select]

...
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Relative Cursor Movement
« Reply #3 on: December 01, 2007, 04:31:32 pm »
That's what I'm going to do, I just need to check if the X11 and Win32 APIs can do it easily.
Laurent Gomila - SFML developer

MrDoomMaster

  • Newbie
  • *
  • Posts: 26
    • View Profile
Relative Cursor Movement
« Reply #4 on: April 18, 2008, 10:37:10 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Relative Cursor Movement
« Reply #5 on: April 19, 2008, 03:26:33 am »
No, sorry. I'll try to work on this soon.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Relative Cursor Movement
« Reply #6 on: April 19, 2008, 01:43:40 pm »
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.
Laurent Gomila - SFML developer

MrDoomMaster

  • Newbie
  • *
  • Posts: 26
    • View Profile
Relative Cursor Movement
« Reply #7 on: April 21, 2008, 02:42:31 am »
Quote from: "Laurent"
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)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Relative Cursor Movement
« Reply #8 on: April 21, 2008, 03:11:19 am »
Should be in the next few weeks, I'm mainly waiting for the MacOS port to be ready.
Laurent Gomila - SFML developer

 

anything