X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fsystem.c;h=8c8b7d5ac8515121bc647aec0ecb59b71c14924e;hb=aaa6bf53eceb4c7801966a017dcc8a57c2fdface;hp=fc1e0c69110c72a49170dafc92b5db92fa1e9e38;hpb=eb201ff71896cf5291e3ad61ccc663d9cec1b825;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index fc1e0c69..8c8b7d5a 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -317,6 +317,9 @@ void InitGfxCustomArtworkInfo(void) void InitGfxOtherSettings(void) { gfx.cursor_mode = CURSOR_DEFAULT; + gfx.cursor_mode_override = CURSOR_UNDEFINED; + gfx.cursor_mode_final = gfx.cursor_mode; + gfx.mouse_x = 0; gfx.mouse_y = 0; } @@ -1552,6 +1555,7 @@ void SetMouseCursor(int mode) static struct MouseCursorInfo *cursor_none = NULL; static struct MouseCursorInfo *cursor_playfield = NULL; struct MouseCursorInfo *cursor_new; + int mode_final = mode; if (cursor_none == NULL) cursor_none = get_cursor_from_image(cursor_image_none); @@ -1559,13 +1563,39 @@ void SetMouseCursor(int mode) if (cursor_playfield == NULL) cursor_playfield = get_cursor_from_image(cursor_image_playfield); - cursor_new = (mode == CURSOR_DEFAULT ? NULL : - mode == CURSOR_NONE ? cursor_none : - mode == CURSOR_PLAYFIELD ? cursor_playfield : NULL); + if (gfx.cursor_mode_override != CURSOR_UNDEFINED) + mode_final = gfx.cursor_mode_override; + + cursor_new = (mode_final == CURSOR_DEFAULT ? NULL : + mode_final == CURSOR_NONE ? cursor_none : + mode_final == CURSOR_PLAYFIELD ? cursor_playfield : NULL); SDLSetMouseCursor(cursor_new); gfx.cursor_mode = mode; + gfx.cursor_mode_final = mode_final; +} + +void UpdateRawMousePosition(int mouse_x, int mouse_y) +{ + // mouse events do not contain logical screen size corrections yet + SDLCorrectRawMousePosition(&mouse_x, &mouse_y); + + mouse_x -= video.screen_xoffset; + mouse_y -= video.screen_yoffset; + + gfx.mouse_x = mouse_x; + gfx.mouse_y = mouse_y; +} + +void UpdateMousePosition(void) +{ + int mouse_x, mouse_y; + + SDL_PumpEvents(); + SDL_GetMouseState(&mouse_x, &mouse_y); + + UpdateRawMousePosition(mouse_x, mouse_y); } @@ -1615,6 +1645,11 @@ void SetAudioMode(boolean enabled) // event functions // ============================================================================ +void InitEventFilter(EventFilter filter_function) +{ + SDL_SetEventFilter(filter_function, NULL); +} + boolean PendingEvent(void) { return (SDL_PollEvent(NULL) ? TRUE : FALSE); @@ -1733,6 +1768,20 @@ void StopTextInput(void) #endif } +void PushUserEvent(int code, int value1, int value2) +{ + UserEvent event; + + SDL_memset(&event, 0, sizeof(event)); + + event.type = EVENT_USER; + event.code = code; + event.value1 = value1; + event.value2 = value2; + + SDL_PushEvent((SDL_Event *)&event); +} + // ============================================================================ // joystick functions