the returned SDL_cursor from SDL_GetCursor() can't be used with SDL_GetMouseState()?

StackOverflow https://stackoverflow.com/questions/517386

  •  21-08-2019
  •  | 
  •  

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' inSDL_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.

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top