I am trying to develop an application to work with the mouse coursor controlled by laser pointer (a webcam scanning the screen, a program scanning frames in search of laser dot, calculates its coordinated and simulates mouse click in these coordinates).
I am coding it in MSVS Community 2019 C++ and SFML.
One of the things I am trying to do is to place a sprite (just a red circle) into a certain place (x,y) which is different for every click using:
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
spriteSircle.setPosition(x, y); //x and y are calculated earlier in the program
}
To simulate mouseClick the laser pointer is set to generate a short (50 msec) laser pulse.
With the standard mouse it works fine.
Yet with the laser pointer two things do happen very often:
1. It misses laser clicks
2. It places the red circle at the coordinates of the PREVIOUS place. I.e. where it should have been places at the previous click
Where might be the error? It might be with the program which scans the frames and simulates the mouseclick, but I have no access to its code, and therefore need to make sure that the problem is not in my code.