rnd-20020314-3-src
[rocksndiamonds.git] / src / events.c
index 95d3752203352663e0def25858d35f4a4fa6c53b..79ffdd4ad02613fb5bf65e609be6ed563b87405b 100644 (file)
@@ -1,26 +1,27 @@
 /***********************************************************
-*  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"
+
 #include "events.h"
 #include "init.h"
 #include "screens.h"
 #include "tools.h"
 #include "game.h"
 #include "editor.h"
-#include "misc.h"
+#include "files.h"
 #include "tape.h"
 #include "joystick.h"
-#include "buttons.h"
 #include "network.h"
 
 /* values for key_status */
@@ -45,6 +46,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 +71,7 @@ void EventLoop(void)
     {
       Event event;
 
-      NextEvent(&event);
-
-      if (FilterMouseMotionEvents(&event))
+      if (NextValidEvent(&event))
       {
        switch(event.type)
        {
@@ -550,6 +566,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;
       }