the returned SDL_cursor from SDL_GetCursor() can't be used with SDL_GetMouseState()?
Question
I'm trying to get the x, y, and state of my mouse in SDL. I tried using the lines
int mstate, mx, my = 0;
mstate, mx, my = SDL_GetCursor().SDL_GetMouseState();
But it gives me the error
C:[path]\particletest2\main.cpp|107|error: request for member
SDL_GetMouseState' in
SDL_GetCursor()', which is of non-class type `SDL_Cursor*'|
Is there any way I can get this to work? It seems like a waste to create a SDL_cursor object when SDL_GetCursor() should be creating one to return for you.
Solution
http://www.libsdl.org/docs/html/sdlgetcursor.html
SDL_GetCursor()
returns a pointer and so you need to use the ->
operator to access its member.
Responding to your reply:
I think
mstate, mx, my = SDL_GetCursor()->SDL_GetMouseState();
is a problem if it wasn't incorrectly pasted. I do not think that this is doing what you think it should be doing, and I am not really sure what you think it should be doing.
OTHER TIPS
you have to put pointers to yours variables and then this gonna have the coordinates
int x,y;
SDL_GetMouseState(&x,&y);
now x and y have the coordinates of your cursor