hedgewars/hwengine.pas
branchsdl2transition
changeset 9697 198c3ed28fe8
parent 9694 e8d0fe885169
child 9699 fab319c85a39
equal deleted inserted replaced
9694:e8d0fe885169 9697:198c3ed28fe8
   152         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL2}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   152         while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL2}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do
   153         begin
   153         begin
   154             case event.type_ of
   154             case event.type_ of
   155 {$IFDEF SDL2}
   155 {$IFDEF SDL2}
   156                 SDL_KEYDOWN:
   156                 SDL_KEYDOWN:
   157                     if GameState = gsChat then
   157                     if (GameState <> gsChat) and (GameState >= gsGame) then
   158                         begin
   158                         ProcessKey(event.key);
   159                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
       
   160                         KeyPressChat(SDL_GetKeyFromScancode(event.key.keysym.sym), event.key.keysym.sym); //TODO correct for keymodifiers
       
   161                         end
       
   162                     else
       
   163                         if GameState >= gsGame then ProcessKey(event.key);
       
   164                 SDL_KEYUP:
   159                 SDL_KEYUP:
   165                     if (GameState <> gsChat) and (GameState >= gsGame) then
   160                     if (GameState <> gsChat) and (GameState >= gsGame) then
   166                         ProcessKey(event.key);
   161                         ProcessKey(event.key);
   167 
   162 
   168                 SDL_MOUSEBUTTONDOWN:
   163                 SDL_MOUSEBUTTONDOWN:
   174                 SDL_MOUSEBUTTONUP:
   169                 SDL_MOUSEBUTTONUP:
   175                     if (GameState >= gsGame) then ProcessMouse(event.button, false);
   170                     if (GameState >= gsGame) then ProcessMouse(event.button, false);
   176 
   171 
   177                 SDL_MOUSEWHEEL:
   172                 SDL_MOUSEWHEEL:
   178                     ProcessMouseWheel(event.wheel.x, event.wheel.y);
   173                     ProcessMouseWheel(event.wheel.x, event.wheel.y);
       
   174 
       
   175                 SDL_TEXTINPUT: AddFileLog('[Text input] ' + event.text.text);
       
   176                 SDL_TEXTEDITING: AddFileLog('[Text edit] ''' + event.edit.text + ''' ' + inttostr(event.edit.start) + ' ' + inttostr(event.edit.length));
   179 
   177 
   180                 SDL_WINDOWEVENT:
   178                 SDL_WINDOWEVENT:
   181                     if event.window.event = SDL_WINDOWEVENT_SHOWN then
   179                     if event.window.event = SDL_WINDOWEVENT_SHOWN then
   182                     begin
   180                     begin
   183                         cHasFocus:= true;
   181                         cHasFocus:= true;
   350     WriteToConsole('Init SDL... ');
   348     WriteToConsole('Init SDL... ');
   351     if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
   349     if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, 'SDL_Init', true);
   352     WriteLnToConsole(msgOK);
   350     WriteLnToConsole(msgOK);
   353 
   351 
   354 {$IFDEF SDL2}
   352 {$IFDEF SDL2}
   355     SDL_StartTextInput();
   353     //SDL_StartTextInput();
   356 {$ELSE}
   354 {$ELSE}
   357     SDL_EnableUNICODE(1);
   355     SDL_EnableUNICODE(1);
   358 {$ENDIF}
   356 {$ENDIF}
   359     SDL_ShowCursor(0);
   357     SDL_ShowCursor(0);
   360 
   358