1
Window / Re: Centering mouse
« on: February 14, 2017, 09:03:59 pm »
Updated to latest version, now Im using 2.4.2 64 bit version compiled under VS 2015...and its definitely not a problem of my code, which manages my camera...made this little program:
...and bug is still there...on my laptop monitor it works fine but when I switch to second monitor and moves a mouse a little, it is centered at wrong position and stays there while not moving mouse.
#include <SFML\Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "Test", sf::Style::Default);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
sf::Vector2i mousePosition = sf::Mouse::getPosition(window);
sf::Mouse::setPosition(sf::Vector2i(640, 360), window);
std::cout << sf::Mouse::getPosition(window).x << " " << sf::Mouse::getPosition(window).y << std::endl;
window.clear();
window.display();
}
return EXIT_SUCCESS;
}
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "Test", sf::Style::Default);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
sf::Vector2i mousePosition = sf::Mouse::getPosition(window);
sf::Mouse::setPosition(sf::Vector2i(640, 360), window);
std::cout << sf::Mouse::getPosition(window).x << " " << sf::Mouse::getPosition(window).y << std::endl;
window.clear();
window.display();
}
return EXIT_SUCCESS;
}
...and bug is still there...on my laptop monitor it works fine but when I switch to second monitor and moves a mouse a little, it is centered at wrong position and stays there while not moving mouse.