SDL_Cursor mouse position

hi all,

I’ve a problem which I guess is not very advanced. I have problem with the
cursor I am creating.
I intend to make a ‘+’ shaped mouse pointer. And for that I’ve this code:

void init_system_cursor()
{
/* Creates a new mouse cursor from an XPM /
/
XPM */
static const char image[] = {
/
width height num_colors chars_per_pixel /
" 32 32 3 1",
/
colors /
“X c #000000”,
". c #ffffff",
" c None",
/
pixels */
" XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX ",
"XXXXXXXXXXXXXXXXXXXX ",
"XXXXXXXXXXXXXXXXXXXX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” XX “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” “,
” ",
“0,0”
};

int i, row, col;
Uint8 data[432];
Uint8 mask[4
32];
int hot_x, hot_y;

i = -1;
for ( row=0; row<32; ++row ) {
for ( col=0; col<32; ++col ) {
if ( col % 8 ) {
data[i] <<= 0;
mask[i] <<= 1;
} else {
++i;
data[i] = mask[i] = 0;
}
switch (image[4+row][col]) {
case ‘X’:
data[i] |= 0x01;
mask[i] |= 0x01;
break;
case ‘.’:
mask[i] |= 0x01;
break;
case ’ ':
break;
}
}
}
sscanf(image[4+row], “%d,%d”, &hot_x, &hot_y);
SDL_Cursor *cursor = SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
if(cursor == NULL)
cout<<“Problem initializing the cursor.”<<endl;
SDL_SetCursor(cursor);
}

The cursor is created and works fine but the problem is that the point for
which it returns the current mouse position is the top left corner of the
XPM above, and I want that point to be on the center point of the XPM (the
point of cross-section of two lines above).

can someone please help me in this regard. what is the shceme that I should
use to accomplish this.

Thanks in advance :slight_smile:

regards,
sandra

sandra.jhonson at softhome.net escribi?:

hi all,

I’ve a problem which I guess is not very advanced. I have problem with the
cursor I am creating.

[snip]

" “,
” ",
“0,0”
};

Your code reads the hotspot from those last two values. You simply need to
change them to your desired value.

Regards,
Wizord.

oh my God, this one was tooooo simple… what was I thinking

sorry for wasting everyone’s time…> ----- Original Message -----

From: wizord@mi.madritel.es (Jose Luis Sanchez)
To:
Sent: Friday, September 06, 2002 7:20 AM
Subject: Re: [SDL] SDL_Cursor mouse position

@Sandra escribi?:

hi all,

I’ve a problem which I guess is not very advanced. I have problem with
the

cursor I am creating.

[snip]

" “,
” ",
“0,0”
};

Your code reads the hotspot from those last two values. You simply need
to
change them to your desired value.

Regards,
Wizord.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl