X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=7a366aa7fc4e24b7f121fd7a7f41df31ae168923;hb=7b3e068e43bcfeb38ce390d5d1c3b1a13c81cb55;hp=1d02e8c238d01295a3a9a643d0dd3e99bd9e26ff;hpb=36fdadd45345a6ce4402fa3bdbb3b12b4cbb62ee;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 1d02e8c2..7a366aa7 100644 --- a/src/events.c +++ b/src/events.c @@ -22,7 +22,7 @@ #include "network.h" -#define DEBUG_EVENTS 1 +#define DEBUG_EVENTS 0 #define DEBUG_EVENTS_BUTTON (DEBUG_EVENTS * 0) #define DEBUG_EVENTS_MOTION (DEBUG_EVENTS * 0) @@ -33,9 +33,9 @@ static boolean cursor_inside_playfield = FALSE; -static boolean playfield_cursor_set = FALSE; -static unsigned int playfield_cursor_delay = 0; - +static int cursor_mode_last = CURSOR_DEFAULT; +static unsigned int special_cursor_delay = 0; +static unsigned int special_cursor_delay_value = 1000; /* event filter especially needed for SDL event filtering due to delay problems with lots of mouse motion events when mouse button @@ -64,11 +64,18 @@ static int FilterEventsExt(const Event *event) cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && motion->y >= SY && motion->y < SY + SYSIZE); - if (game_status == GAME_MODE_PLAYING && playfield_cursor_set) + /* do no reset mouse cursor before all pending events have been processed */ + if (gfx.cursor_mode == cursor_mode_last && + ((effectiveGameStatus() == GAME_MODE_TITLE && + gfx.cursor_mode == CURSOR_NONE) || + (game_status == GAME_MODE_PLAYING && + gfx.cursor_mode == CURSOR_PLAYFIELD))) { SetMouseCursor(CURSOR_DEFAULT); - playfield_cursor_set = FALSE; - DelayReached(&playfield_cursor_delay, 0); + + DelayReached(&special_cursor_delay, 0); + + cursor_mode_last = CURSOR_DEFAULT; } /* skip mouse motion events without pressed button outside level editor */ @@ -202,21 +209,34 @@ void EventLoop(void) } else { - /* when playing, display a special mouse pointer inside the playfield */ - if (game_status == GAME_MODE_PLAYING && !tape.pausing) + if (effectiveGameStatus() == GAME_MODE_TITLE) + { + /* when showing title screens, hide mouse pointer (if not moved) */ + + if (gfx.cursor_mode != CURSOR_NONE && + DelayReached(&special_cursor_delay, special_cursor_delay_value)) + { + SetMouseCursor(CURSOR_NONE); + } + } + else if (game_status == GAME_MODE_PLAYING && !tape.pausing) { - if (!playfield_cursor_set && cursor_inside_playfield && - DelayReached(&playfield_cursor_delay, 1000)) + /* when playing, display a special mouse pointer inside the playfield */ + + if (gfx.cursor_mode != CURSOR_PLAYFIELD && + cursor_inside_playfield && + DelayReached(&special_cursor_delay, special_cursor_delay_value)) { SetMouseCursor(CURSOR_PLAYFIELD); - playfield_cursor_set = TRUE; } } - else if (playfield_cursor_set) + else if (gfx.cursor_mode != CURSOR_DEFAULT) { SetMouseCursor(CURSOR_DEFAULT); - playfield_cursor_set = FALSE; } + + /* this is set after all pending events have been processed */ + cursor_mode_last = gfx.cursor_mode; } /* also execute after pending events have been processed before */ @@ -231,8 +251,6 @@ void EventLoop(void) } else { - SyncDisplay(); - if (!PendingEvent()) /* delay only if no pending events */ Delay(10); } @@ -801,11 +819,7 @@ void HandleTextEvent(TextEvent *event) } #endif - // if (game_status != GAME_MODE_PLAYING && GetKeyModState() != KMOD_None) - /* - if (game_status != GAME_MODE_PLAYING && - (GetKeyModState() & KMOD_TextInput) != KMOD_None) - */ + // only handle key input with text modifier keys pressed if (checkTextInputKeyModState()) { HandleKey(key, KEY_PRESSED); @@ -854,6 +868,7 @@ void HandleKeyEvent(KeyEvent *event) HandleKeyModState(keymod, key_status); #if defined(TARGET_SDL2) + // only handle raw key input without text modifier keys pressed if (!checkTextInputKeyModState()) HandleKey(key, key_status); #else