Add SDL_CreateSystemCursor for Windows and Linux.
This commit is contained in:
parent
7b16b8577c
commit
8f081103e5
6 changed files with 132 additions and 0 deletions
|
@ -102,6 +102,45 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
WIN_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
LPCTSTR name;
|
||||
|
||||
switch(id)
|
||||
{
|
||||
default:
|
||||
SDL_assert(0);
|
||||
return NULL;
|
||||
case SDL_SYSTEM_CURSOR_ARROW: name = IDC_ARROW; break;
|
||||
case SDL_SYSTEM_CURSOR_IBEAM: name = IDC_IBEAM; break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT: name = IDC_WAIT; break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR: name = IDC_CROSS; break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: name = IDC_WAIT; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE: name = IDC_SIZENWSE; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW: name = IDC_SIZENESW; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE: name = IDC_SIZEWE; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS: name = IDC_SIZENS; break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL: name = IDC_SIZEALL; break;
|
||||
case SDL_SYSTEM_CURSOR_NO: name = IDC_NO; break;
|
||||
case SDL_SYSTEM_CURSOR_HAND: name = IDC_HAND; break;
|
||||
}
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
HICON hicon;
|
||||
|
||||
hicon = LoadCursor(NULL, name);
|
||||
|
||||
cursor->driverdata = hicon;
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_FreeCursor(SDL_Cursor * cursor)
|
||||
{
|
||||
|
@ -190,6 +229,7 @@ WIN_InitMouse(_THIS)
|
|||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
mouse->CreateCursor = WIN_CreateCursor;
|
||||
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
|
||||
mouse->ShowCursor = WIN_ShowCursor;
|
||||
mouse->FreeCursor = WIN_FreeCursor;
|
||||
mouse->WarpMouse = WIN_WarpMouse;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue