X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=d599dde4ba1ee695dcd450730cb23da75074bdef;hb=1c428c3e9e9625ec4a0fbec9129138baf3cf8a63;hp=1d02e8c238d01295a3a9a643d0dd3e99bd9e26ff;hpb=36fdadd45345a6ce4402fa3bdbb3b12b4cbb62ee;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 1d02e8c2..d599dde4 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 */ @@ -101,9 +108,8 @@ boolean SkipPressedMouseMotionEvent(const Event *event) if (event->type != EVENT_MOTIONNOTIFY) return FALSE; - /* only skip motion events with pressed button outside level editor */ - if (button_status == MB_RELEASED || - game_status == GAME_MODE_EDITOR || game_status == GAME_MODE_PLAYING) + /* only skip motion events with pressed button outside the game */ + if (button_status == MB_RELEASED || game_status == GAME_MODE_PLAYING) return FALSE; if (PendingEvent()) @@ -124,7 +130,7 @@ boolean SkipPressedMouseMotionEvent(const Event *event) when using SDL with properly installed event filter, this function can be replaced with a simple "NextEvent()" call, but it doesn't hurt either */ -static boolean NextValidEvent(Event *event) +boolean NextValidEvent(Event *event) { while (PendingEvent()) { @@ -202,21 +208,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 +250,6 @@ void EventLoop(void) } else { - SyncDisplay(); - if (!PendingEvent()) /* delay only if no pending events */ Delay(10); } @@ -801,11 +818,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 +867,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