SDL_GetMouseState - solved
- Posted by ChrisB (moderator) Jan 24, 2023
- 729 views
Hi
Firstly I have solved the problem of getting mouse info from the SDL_Event union in a completely different way, but this has got me conceptually bugged
In C
int mx, my, mouseState; mouseState = SDL_GetMouseState(&mx, &my); //mouse position = mx,my
What this does is create integers mx and my, then gives the function the address of these integers, GetMouseState puts these values into mx and my. C provides an easy method of sending the address of the integers in memory - pass by reference I think.
in eu
include SDL ....etc --relevant lines from SDL_mouse.e export constant xSDL_GetMouseState = define_c_func(sdl,"+SDL_GetMouseState",{C_POINTER,C_POINTER},C_UINT) public function SDL_GetMouseState(atom x,atom y) return c_func(xSDL_GetMouseState,{x,y}) end function integer mx, my, mouseState mouseState = SDL_GetMouseState(????mx, ????my)
How do I, can I, send the address of these variables to the C function.
One possible work aroud (untested, just thought of it) would be to create a structure, and send the address of the variables, then peek the structure. Will try that tomorrow.
Chris