equal
deleted
inserted
replaced
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 |
189 cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight); |
189 cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight); |
190 cScreenResizeDelay:= RealTicks + 500{$IFDEF IPHONEOS}div 2{$ENDIF}; |
190 cScreenResizeDelay:= RealTicks + 500{$IFDEF IPHONEOS}div 2{$ENDIF}; |
191 end; |
191 end; |
192 |
192 |
193 SDL_FINGERMOTION: |
193 SDL_FINGERMOTION: |
194 onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId); |
194 onTouchMotion(event.tfinger.x, event.tfinger.y, event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId); |
195 |
195 |
196 SDL_FINGERDOWN: |
196 SDL_FINGERDOWN: |
197 onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); |
197 onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); |
198 |
198 |
199 SDL_FINGERUP: |
199 SDL_FINGERUP: |
335 |
335 |
336 WriteToConsole('Init SDL... '); |
336 WriteToConsole('Init SDL... '); |
337 if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true); |
337 if not cOnlyStats then SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true); |
338 WriteLnToConsole(msgOK); |
338 WriteLnToConsole(msgOK); |
339 |
339 |
|
340 {$IFDEF SDL2} |
|
341 SDL_StartTextInput(); |
|
342 {$ELSE} |
340 SDL_EnableUNICODE(1); |
343 SDL_EnableUNICODE(1); |
|
344 {$ENDIF} |
341 SDL_ShowCursor(0); |
345 SDL_ShowCursor(0); |
342 |
346 |
343 WriteToConsole('Init SDL_ttf... '); |
347 WriteToConsole('Init SDL_ttf... '); |
344 SDLTry(TTF_Init() <> -1, true); |
348 SDLTry(TTF_Init() <> -1, true); |
345 WriteLnToConsole(msgOK); |
349 WriteLnToConsole(msgOK); |