diff --git a/src/video/toaru/SDL_toaruevents.c b/src/video/toaru/SDL_toaruevents.c index c4c45db..6020d5e 100644 --- a/src/video/toaru/SDL_toaruevents.c +++ b/src/video/toaru/SDL_toaruevents.c @@ -79,7 +79,27 @@ void TOARU_PumpEvents(_THIS) { SDL_PrivateQuit(); break; } - /* TODO mouse events */ + + int i; + signed int x = me->new_x - this->hidden->o_w; + signed int y = me->new_y - this->hidden->o_h; + +#define CONVERT_MOUSE(i) (i == 0 ? 1 : (i == 1 ? 3 : (i == 2 ? 2 : 0))) + + for (i = 0; i < 3; ++i) { + int was = mouse_state & (1 << i); + int is = me->buttons & (1 << i); + if (is && (was != is)) { + SDL_PrivateMouseButton(SDL_PRESSED, CONVERT_MOUSE(i), x, y); + } else if ((was) && (was != is)) { + SDL_PrivateMouseButton(SDL_RELEASED, CONVERT_MOUSE(i), x, y); + } else if (was != is) { + SDL_PrivateMouseButton(SDL_RELEASED, CONVERT_MOUSE(i), x, y); + } + } + mouse_state = me->buttons; + + SDL_PrivateMouseMotion(0, 0, x, y); } break; case YUTANI_MSG_SESSION_END: diff --git a/src/video/toaru/SDL_toarumouse.c b/src/video/toaru/SDL_toarumouse.c index fee4d63..febba31 100644 --- a/src/video/toaru/SDL_toarumouse.c +++ b/src/video/toaru/SDL_toarumouse.c @@ -31,3 +31,31 @@ struct WMcursor { int unused; }; + +/* There isn't any implementation dependent data */ +void TOARU_FreeWMCursor(_THIS, WMcursor *cursor) +{ + return; +} + +/* There isn't any implementation dependent data */ +WMcursor *TOARU_CreateWMCursor(_THIS, + Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) +{ + return((WMcursor *)0x01); +} + +static void TOARU_MoveCursor(_THIS, SDL_Cursor *cursor, int x, int y) +{ + /* do nothing */ +} + +void TOARU_MoveWMCursor(_THIS, int x, int y) +{ + /* do nothing */ +} + +int TOARU_ShowWMCursor(_THIS, WMcursor *wmcursor) +{ + return (1); +} diff --git a/src/video/toaru/SDL_toarumouse_c.h b/src/video/toaru/SDL_toarumouse_c.h index c7243c3..d614e49 100644 --- a/src/video/toaru/SDL_toarumouse_c.h +++ b/src/video/toaru/SDL_toarumouse_c.h @@ -24,3 +24,8 @@ #include "SDL_toaruvideo.h" /* Functions to be exported */ +extern void TOARU_FreeWMCursor(_THIS, WMcursor *cursor); +extern WMcursor *TOARU_CreateWMCursor(_THIS, + Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); +extern void TOARU_MoveWMCursor(_THIS, int x, int y); +extern int TOARU_ShowWMCursor(_THIS, WMcursor *cursor); diff --git a/src/video/toaru/SDL_toaruvideo.c b/src/video/toaru/SDL_toaruvideo.c index 379baf8..9521f5f 100644 --- a/src/video/toaru/SDL_toaruvideo.c +++ b/src/video/toaru/SDL_toaruvideo.c @@ -125,6 +125,10 @@ static SDL_VideoDevice *TOARU_CreateDevice(int devindex) device->IconifyWindow = NULL; device->GrabInput = NULL; device->GetWMInfo = NULL; + device->FreeWMCursor = TOARU_FreeWMCursor; + device->CreateWMCursor = TOARU_CreateWMCursor; + device->ShowWMCursor = TOARU_ShowWMCursor; + device->MoveWMCursor = TOARU_MoveWMCursor; device->InitOSKeymap = TOARU_InitOSKeymap; device->PumpEvents = TOARU_PumpEvents; device->SetCaption = TOARU_SetCaption;