I have a problem with SDL_GetMouseState: I want to get the inital
mouse coords before the user moves the mouse, but the function only
returns 0 for the x and y coord.
I have attached a MWE that shows my problem. The first line that is
printed is always “init: 0, 0”. I expected it to give the actual coords.
The problem is that if the mouse is outside the window there is no data to get. If the SDL_GetMouseState is called while the window is inside the window you will get data. Try creating a bigger where the mouse is inside the window.
The problem is that if the mouse is outside the window there is no data
to get. If the SDL_GetMouseState is called while the window is inside
the window you will get data. Try creating a bigger where the mouse is
inside the window.
I’m not talking about the case where the mouse is outside the program.
Run my attached program. Then remember the position of the window. Close
the program. Then move the mouse into the position where the window was
created last time. Start the program again.
Now you can see that the initial call of SDL_GetMouseState always
returns (0,0) although the mouse is inside the window.
The problem is that if the mouse is outside the window there is no data
to get. If the SDL_GetMouseState is called while the window is inside
the window you will get data. Try creating a bigger where the mouse is
inside the window.
I’m not talking about the case where the mouse is outside the program.
Run my attached program. Then remember the position of the window. Close
the program. Then move the mouse into the position where the window was
created last time. Start the program again.
Now you can see that the initial call of SDL_GetMouseState always
returns (0,0) although the mouse is inside the window.