rnd-20010115-1-src
[rocksndiamonds.git] / src / events.c
index 604345d90f07054d1639ee0f285d45c1123547db..365d79621582c8f9895e69d5842c964e29d4d13a 100644 (file)
@@ -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"
@@ -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)
        {