hedgewars/hwengine.pas
changeset 9317 a04c30940d2d
parent 9311 5baf10a52f43
child 9379 1bcfcaf0926e
equal deleted inserted replaced
9315:15487f7fed42 9317:a04c30940d2d
   134 ///////////////////////////////////////////////////////////////////////////////
   134 ///////////////////////////////////////////////////////////////////////////////
   135 procedure MainLoop;
   135 procedure MainLoop;
   136 var event: TSDL_Event;
   136 var event: TSDL_Event;
   137     PrevTime, CurrTime: Longword;
   137     PrevTime, CurrTime: Longword;
   138     isTerminated: boolean;
   138     isTerminated: boolean;
   139 {$IFDEF SDL13}
   139 {$IFDEF SDL2}
   140     previousGameState: TGameState;
   140     previousGameState: TGameState;
   141 {$ELSE}
   141 {$ELSE}
   142     prevFocusState: boolean;
   142     prevFocusState: boolean;
   143 {$ENDIF}
   143 {$ENDIF}
   144 begin
   144 begin
   146     PrevTime:= SDL_GetTicks;
   146     PrevTime:= SDL_GetTicks;
   147     while isTerminated = false do
   147     while isTerminated = false do
   148     begin
   148     begin
   149         SDL_PumpEvents();
   149         SDL_PumpEvents();
   150 
   150 
   151         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL13}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   151         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL2}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   152         begin
   152         begin
   153             case event.type_ of
   153             case event.type_ of
   154 {$IFDEF SDL13}
   154 {$IFDEF SDL2}
   155                 SDL_KEYDOWN:
   155                 SDL_KEYDOWN:
   156                     if GameState = gsChat then
   156                     if GameState = gsChat then
   157                         begin
   157                         begin
   158                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
   158                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
   159                         KeyPressChat(SDL_GetKeyFromScancode(event.key.keysym.sym), event.key.keysym.sym); //TODO correct for keymodifiers
   159                         KeyPressChat(SDL_GetKeyFromScancode(event.key.keysym.sym), event.key.keysym.sym); //TODO correct for keymodifiers
   160                         end
   160                         end
   161                     else 
   161                     else
   162                         if GameState >= gsGame then ProcessKey(event.key);
   162                         if GameState >= gsGame then ProcessKey(event.key);
   163                 SDL_KEYUP:
   163                 SDL_KEYUP:
   164                     if (GameState <> gsChat) and (GameState >= gsGame) then
   164                     if (GameState <> gsChat) and (GameState >= gsGame) then
   165                         ProcessKey(event.key);
   165                         ProcessKey(event.key);
   166 
   166 
   337 
   337 
   338     WriteToConsole('Init SDL... ');
   338     WriteToConsole('Init SDL... ');
   339     if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
   339     if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
   340     WriteLnToConsole(msgOK);
   340     WriteLnToConsole(msgOK);
   341 
   341 
       
   342 {$IFDEF SDL2}
       
   343     SDL_StartTextInput();
       
   344 {$ELSE}
   342     SDL_EnableUNICODE(1);
   345     SDL_EnableUNICODE(1);
       
   346 {$ENDIF}
   343     SDL_ShowCursor(0);
   347     SDL_ShowCursor(0);
   344 
   348 
   345     WriteToConsole('Init SDL_ttf... ');
   349     WriteToConsole('Init SDL_ttf... ');
   346     SDLTry(TTF_Init() <> -1, true);
   350     SDLTry(TTF_Init() <> -1, true);
   347     WriteLnToConsole(msgOK);
   351     WriteLnToConsole(msgOK);