Commit ab0456f2 authored by deuce's avatar deuce
Browse files

Implement mousepointer() for SDL mode.

parent c1b6e99a
......@@ -191,6 +191,7 @@ static int try_sdl_init(int mode)
cio_api.map_rgb = bitmap_map_rgb;
cio_api.replace_font = bitmap_replace_font;
cio_api.beep = sdl_beep;
cio_api.mousepointer=sdl_mousepointer;
return(1);
}
return(0);
......
......@@ -39,6 +39,7 @@ unsigned char sdl_keynext=0; /* Index into keybuf for next free position */
int sdl_exitcode=0;
SDL_Window *win=NULL;
SDL_Cursor *curs=NULL;
SDL_Renderer *renderer=NULL;
SDL_Texture *texture=NULL;
pthread_mutex_t win_mutex;
......@@ -84,6 +85,7 @@ enum {
,SDL_USEREVENT_INIT
,SDL_USEREVENT_QUIT
,SDL_USEREVENT_GETWINPOS
,SDL_USEREVENT_MOUSEPOINTER
};
const struct sdl_keyvals sdl_keyval[] =
......@@ -214,6 +216,9 @@ static void sdl_user_func(int func, ...)
return;
}
break;
case SDL_USEREVENT_MOUSEPOINTER:
ev.user.data1 = (void *)(intptr_t)va_arg(argptr, int);
break;
case SDL_USEREVENT_SHOWMOUSE:
case SDL_USEREVENT_HIDEMOUSE:
case SDL_USEREVENT_FLUSH:
......@@ -1047,6 +1052,33 @@ void sdl_video_event_thread(void *data)
case SDL_USEREVENT_GETWINPOS:
sdl.GetWindowPosition(win, ev.user.data1, ev.user.data2);
sem_post(&sdl_ufunc_ret);
break;
case SDL_USEREVENT_MOUSEPOINTER:
{
int cid = INT_MIN;
SDL_Cursor *oc = curs;
switch((intptr_t)ev.user.data1) {
case CIOLIB_MOUSEPTR_ARROW:
break; // Default
case CIOLIB_MOUSEPTR_BAR:
cid = SDL_SYSTEM_CURSOR_IBEAM;
break;
}
if (cid == INT_MIN) {
sdl.SetCursor(sdl.GetDefaultCursor());
curs = NULL;
}
else {
curs = sdl.CreateSystemCursor(cid);
if (curs == NULL)
sdl.SetCursor(sdl.GetDefaultCursor());
else
sdl.SetCursor(curs);
}
if (oc)
sdl.FreeCursor(oc);
break;
}
}
break;
}
......@@ -1097,3 +1129,10 @@ sdl_beep(void)
}
xp_play_sample(wave, 2205, TRUE);
}
/* Called from main thread only (Passes Event) */
int sdl_mousepointer(enum ciolib_mouse_ptr type)
{
sdl_user_func(SDL_USEREVENT_MOUSEPOINTER,type);
return(0);
}
......@@ -38,6 +38,7 @@ int sdl_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b);
void sdl_setwinsize(int w, int h);
void sdl_setwinposition(int x, int y);
void sdl_beep(void);
int sdl_mousepointer(enum ciolib_mouse_ptr type);
#if defined(__DARWIN__)
void sdl_init_darwin(void *args);
......
......@@ -4,6 +4,7 @@
#include "gen_defs.h"
#include "threadwrap.h"
#include <SDL.h>
#include "ciolib.h"
#include "sdlfuncs.h"
#include "sdl_con.h"
extern int sdl_video_initialized;
......@@ -16,8 +17,6 @@ struct sdlfuncs sdl;
#endif
#include <xp_dl.h>
#include "ciolib.h"
static int sdl_funcs_loaded=0;
static void QuitWrap(void);
......@@ -179,6 +178,22 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateSystemCursor=xp_dlsym(sdl_dll, SDL_CreateSystemCursor))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->GetDefaultCursor=xp_dlsym(sdl_dll, SDL_GetDefaultCursor))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->FreeCursor=xp_dlsym(sdl_dll, SDL_FreeCursor))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->SetCursor=xp_dlsym(sdl_dll, SDL_SetCursor))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->free=xp_dlsym(sdl_dll, SDL_free))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
......
......@@ -50,6 +50,10 @@ struct sdlfuncs {
void (HACK_HACK_HACK *SetWindowMinimumSize) (SDL_Window *window, int w, int y);
void (HACK_HACK_HACK *SetClipboardText) (const char *);
char *(HACK_HACK_HACK *GetClipboardText) (void);
SDL_Cursor *(HACK_HACK_HACK *CreateSystemCursor) (SDL_SystemCursor id);
SDL_Cursor *(HACK_HACK_HACK *GetDefaultCursor) (void);
void (HACK_HACK_HACK *SetCursor) (SDL_Cursor *curs);
void (HACK_HACK_HACK *FreeCursor) (SDL_Cursor *curs);
void(HACK_HACK_HACK *free) (void *);
int gotfuncs;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment