SDL_WarpMouseInWindow() is one of the most confusing functions in SDL2 to me.
The docs say:
“Use this function to move the mouse to the given position within the window.”
“This function generates a mouse motion event.”
From my tests, the mouse warps immediately, but the corresponding mouse motion event is queued at the end of the queue.
How is this consistent with the rest of mouse handling? What if there are pending mouse motion events when this function is called? The event queue will then not accurately represent the true mouse motion.
Can someone have mercy with me and explain how I can avoid the problem of having mouse motion events out of order when I use this function? Is it possible to warp the mouse without generating a mouse motion event at the wrong place in the queue?
Should I just hack the internal SDL mouse state structure and write x, y values directly to circumvent this?