The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Disconnect mouse cursor from interrupts / mouse driver
dirichs


Joined: 13 Jun 2015
Posts: 2
Hello,

I am developing a game that contains instruction sessions explaining the user interface.
For these instructional parts, I would like to programmatically move the mouse cursor
around to show where to click etc. In SDL, there is the function SDL_WarpMouse, which
allows re-positioning of the mouse. But the user is still allowed to move the mouse by
himself and thus disturb the instruction.

Is it possible to completely disable mouse events triggered by user input? And solely
rely on SDL_WarpMouse to define all movements of the mouse cursor on the screen?

I know that it is always possible to hide the mouse cursor altogether and just move
an image over the screen. Since I would like to demonstrate an already existing game,
this would unfortunately mean a greater restruction of the game architectur just for
this special use case. Thus I would prefer a lean solution that allowed for a complete
"taking over" of the usual mouse cursor by the program.

If this is not possible in SDL (which I suspect), any hints about where to look for the
deeper mechanics would also be greatly appreciated. For now, it would suffice to have
a solution that works under Windows.
Naith


Joined: 03 Jul 2014
Posts: 158
I tried to use the function SDL_WarpMouseInWindow and moved my mouse pointer in a direction, over time, and I couldn't interrupt it's "path" by moving my mouse.
dirichs


Joined: 13 Jun 2015
Posts: 2
That right, as long as SDL_WarpMouse is called continuously, any
mouse movements by the user do not visibly change the mouse
cursor position.

But as soon as there is a pause in these WarpMouse commands,
the mouse can be moved somewhere else. The screen instructions
I am working on are often like

Move mouse to a certain screen area
Explain
Move mouse to another screen area
Explain
Simulate a mouse click within the second area

So there are pauses between the forced mouse movements during
which I would like to suppress any movements caused by the user.

If this is not possible, I now see another alternative: Run WarpMouse
commands continuously in a separate thread. This is a solution that
I have not thought of before, so thanks a lot for your answer.