Changed SDL_PollEvent to SDL_PeepEvents
authorXeli
Thu, 01 Sep 2011 17:49:27 +0200
changeset 5724 3064ed85a5bd
parent 5723 87eec4c9a889
child 5726 f342e0cf4f34
Changed SDL_PollEvent to SDL_PeepEvents
hedgewars/SDLh.pas
hedgewars/hwengine.pas
--- a/hedgewars/SDLh.pas	Thu Sep 01 10:13:03 2011 -0400
+++ b/hedgewars/SDLh.pas	Thu Sep 01 17:49:27 2011 +0200
@@ -278,6 +278,11 @@
     IMG_INIT_PNG = $00000002;
     IMG_INIT_TIF = $00000004;
 
+    {* SDL_EventMask type definition *}
+{$IFNDEF SDL13}
+    SDL_ALLEVENTS = $FFFFFFFF;
+{$ENDIF}
+
 /////////////////////////////////////////////////////////////////
 ///////////////////////  TYPE DEFINITIONS ///////////////////////
 /////////////////////////////////////////////////////////////////
@@ -347,6 +352,7 @@
 {$ENDIF}
         end;
 
+    SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT);
 
     PSDL_Surface = ^TSDL_Surface;
     TSDL_Surface = record
@@ -793,6 +799,10 @@
 
 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
 function  SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
+
+function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
+{$ELSE}
+function  SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: LongInt): LongInt; cdecl; external SDLLibName;
 {$ENDIF}
 
 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
--- a/hedgewars/hwengine.pas	Thu Sep 01 10:13:03 2011 -0400
+++ b/hedgewars/hwengine.pas	Thu Sep 01 17:49:27 2011 +0200
@@ -149,8 +149,12 @@
     PrevTime:= SDL_GetTicks;
     while isTerminated = false do
     begin
-
-        while SDL_PollEvent(@event) <> 0 do
+        SDL_PumpEvents();
+        {$IFDEF SDL13}
+        while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0 do
+        {$ELSE}
+        while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0 do
+        {$ENDIF}
         begin
             case event.type_ of
                 SDL_KEYDOWN: if GameState = gsChat then