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

Author Topic: mouse warping in sfml  (Read 3367 times)

0 Members and 1 Guest are viewing this topic.

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
mouse warping in sfml
« on: July 16, 2011, 11:46:20 pm »
Hi,

I want to warp the mouse, so that the user can move the camera in FPS style.
in SDL there is a function SDL_WarpMoues() which does this. Is there such thing in SFML? Or how is it done in SFML?

Best regards,
Yours3!f

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
mouse warping in sfml
« Reply #1 on: July 17, 2011, 12:01:02 am »
SFML 1.6 : sf::Window::SetCursorPosition
SFML 2 : See sf::Mouse (documentation not yet uptodate)
SFML / OS X developer

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
mouse warping in sfml
« Reply #2 on: July 17, 2011, 12:15:55 am »
wow, ok, I only checked the docs here on sfml-dev.org...
is the one on github better?

anyways thank you!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
mouse warping in sfml
« Reply #3 on: July 17, 2011, 12:45:56 am »
Depending on which version you use (1.6 or 2 ?) you can use sf::Window::SetCursorPosition or sf::Mouse::SetPosition.

I just checked the doxygen documentation for 2.0 on this site and realized that it wasn't up to date so I put the link to the source code. If you're using 2.0 version then I recommend you to build the documentation while compiling SFML. This way you have an local up-to-date version of the documentation.
SFML / OS X developer

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
mouse warping in sfml
« Reply #4 on: July 17, 2011, 06:29:58 pm »
Thanks, I'm going to build the docs definitely. I'm using version 2.

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
mouse warping in sfml
« Reply #5 on: July 22, 2011, 09:58:09 pm »
ok, I'm having a little bit of problem with this function.
It seems to warp my mouse to:
x coord: middle of the screen
y coord: middle of the screen - mouse height

that is for a 1280x720 window I get the mouse position 640, 340. I don't know if it is an SFML bug or I've done something wrong or it is just the windowing system (Kubuntu 11.04/ KDE), but it is clear that it warps my mouse to that location, because if I move the mouse in a way that in 33 ms (one frame) it moves more than 20-30 pixels then eventually my camera goes down as opposed to always going upwards because of that.

Did anyone have issues like that?

or how can I get the height of the cursor so that I can warp it to the correct position?

Best regards,
Yours3!f

Yours3lf

  • Newbie
  • *
  • Posts: 43
    • View Profile
mouse warping in sfml
« Reply #6 on: July 23, 2011, 09:25:22 am »
I think I solved the problem, I just needed to use
sf::Mouse::SetPosition(pos, window)
instead of
sf::Mouse::SetPosition(pos)

where window was the main window I created.
It seems to set the cursor position to the right location now.

 

anything