X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=652ff31da2097c2690414392f1d62cfc29242e21;hb=41e8d55b767c898f20c29a1b0b8d2ef8840be2f5;hp=604345d90f07054d1639ee0f285d45c1123547db;hpb=da14f69fd95c7bd5a0d70cdf4935af06f1f20a04;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 604345d9..652ff31d 100644 --- a/src/events.c +++ b/src/events.c @@ -1,14 +1,14 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1995-2001 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* events.c * +* events.c * ***********************************************************/ #include "libgame/libgame.h" @@ -19,8 +19,8 @@ #include "tools.h" #include "game.h" #include "editor.h" +#include "files.h" #include "tape.h" -#include "joystick.h" #include "network.h" /* values for key_status */ @@ -45,6 +45,23 @@ int FilterMouseMotionEvents(const Event *event) return 1; } +/* this is only really needed for non-SDL targets to filter unwanted events; + 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) +{ + while (PendingEvent()) + { + NextEvent(event); + + if (FilterMouseMotionEvents(event)) + return TRUE; + } + + return FALSE; +} + void EventLoop(void) { while(1) @@ -53,9 +70,7 @@ void EventLoop(void) { Event event; - NextEvent(&event); - - if (FilterMouseMotionEvents(&event)) + if (NextValidEvent(&event)) { switch(event.type) { @@ -288,8 +303,8 @@ void HandleFocusEvent(FocusChangeEvent *event) int i; KeyboardAutoRepeatOn(); - old_joystick_status = joystick_status; - joystick_status = JOYSTICK_OFF; + old_joystick_status = joystick.status; + joystick.status = JOYSTICK_NOT_AVAILABLE; /* simulate key release events for still pressed keys */ key_joystick_mapping = 0; @@ -320,7 +335,7 @@ void HandleFocusEvent(FocusChangeEvent *event) KeyboardAutoRepeatOff(); } if (old_joystick_status != -1) - joystick_status = old_joystick_status; + joystick.status = old_joystick_status; } } @@ -495,9 +510,9 @@ void HandleKey(Key key, int key_status) } /* allow quick escape to the main menu with the Escape key */ - if (key == KSYM_Escape && game_status != MAINMENU) + if (key == KSYM_Escape && + game_status != MAINMENU && game_status != LEVELED) { - CloseDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); game_status = MAINMENU; DrawMainMenu(); return; @@ -550,6 +565,12 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK); break; +#ifdef DEBUG + case KSYM_t: + DumpTape(&tape); + break; +#endif + default: break; } @@ -583,7 +604,7 @@ void HandleKey(Key key, int key_status) break; case LEVELED: - if (!anyTextGadgetActiveOrJustFinished) + if (!anyTextGadgetActiveOrJustFinished || key == KSYM_Escape) HandleLevelEditorKeyInput(key); break;