Hey,
when setting the mouse cursor position manually by calling sf::Window::SetCursorPosition(), the next call to GetMouseX/Y() returns exactly that position, even if the mouse has moved during that time (needed by mouse look/mouse grabbing, for example).
I haven't checked how it's implemented, yet, therefore I'm asking if the delay is too short so that sf::Window (or even the OS/window manager) isn't able to fetch the mouse move event in-time.
Here's a minimal example to reproduce the problem. It prints out the relative position from the window's center when the mouse has moved + one iteration after that.
#include <SFML/Graphics.hpp>
#include <iostream>
int main() {
sf::RenderWindow window( sf::VideoMode( 800, 600, 16 ), "Minimal" );
sf::Event event;
const sf::Input& input( window.GetInput() );
unsigned char print_count( 0 );
window.EnableVerticalSync( true );
while( window.IsOpened() ) {
while( window.PollEvent( event ) ) {
if( event.Type == sf::Event::Closed ) {
window.Close();
}
}
// Get mouse movement delta values.
sf::Vector2i mouse_delta(
input.GetMouseX() - (800 / 2),
input.GetMouseY() - (600 / 2)
);
if( mouse_delta.x || mouse_delta.y ) {
print_count = 2;
// Reset mouse cursor to window center (fake grabbing).
window.SetCursorPosition( 800 / 2, 600 / 2 );
}
// Print 'em.
if( print_count ) {
std::cout << mouse_delta.x << ", " << mouse_delta.y << std::endl;
--print_count;
}
window.Clear();
window.Display();
}
}
The example shows that the mouse deltas are always (0, 0) after each mouse move which results in stuttering mouse looks. Any ideas?