I want to find the position of the mouse

I need to find the mouse coordinates. This is what I’m doing:

SDL_Cursor* cursor;
cursor = SDL_GetCursor();

However, cursor->hot_x and cursor->hot_y always contain 0… What am I
doing wrong?

Hello !

I need to find the mouse coordinates. This is what I’m doing:

SDL_Cursor* cursor;
cursor = SDL_GetCursor();

However, cursor->hot_x and cursor->hot_y always contain 0… What am I
doing wrong?

This is wrong, Cursor means here the Bitmap of the Mouse
Cursor, for example you can change the Bitmap of the Mouse
Cursor to a question mark or a waiting hourglass or something
like that.

To get Mouse Events look here :

http://www.libsdl.org/intro.en/usingevents.html

CU

I need to find the mouse coordinates. This is what I’m doing:

SDL_Cursor* cursor;
cursor = SDL_GetCursor();

Use SDL_GetMouseState() or catch the various mouse events.

–ryan.

typedef struct
{
SDL_Rect Src;
int HotSpotOffsetX;
int HotSpotOffsetY;
}MouseCursor;

#define HAND_CURSOR 0
#define WAIT_CURSOR 1

int Curso; // what cursor to display
MouseCursor Cursors[MAXCURSORS];

// on init i do this

Cursors[HAND_CURSOR].Src.x = 0; // pos on bitmap
Cursors[HAND_CURSOR].Src.y = 0; // y pos on bitmap
Cursors[HAND_CURSOR].Src.w = 38; // width of cursor imahe
Cursors[HAND_CURSOR].Src.h = 43; // height of cursor image
Cursors[HAND_CURSOR].HotSpotOffsetX = 30; // hotspot x
Cursors[HAND_CURSOR].HotSpotOffsetY = 5; // hotspot y

// then at the end of the draw loop i do this
CopyRect(&Cursors[Cursor].Src,&Src); // copys SDL_Rect to another SDL_Rect
(not rocket science)
Dest.x = MouseX-Cursors[Cursor].HotSpotOffsetX;
Dest.y = MouseY-Cursors[Cursor].HotSpotOffsetY;
Dest.w = Src.w;
Dest.h = Src.h;
SDL_BlitSurface(gCursors, &Src, gScreen, &Dest);

I hope this helps

Trish x