145 {$WARNINGS OFF} |
144 {$WARNINGS OFF} |
146 // disable "Some fields weren't initialized" warning |
145 // disable "Some fields weren't initialized" warning |
147 const event: TSDL_Event = (); |
146 const event: TSDL_Event = (); |
148 {$WARNINGS ON} |
147 {$WARNINGS ON} |
149 var PrevTime, CurrTime: Longword; |
148 var PrevTime, CurrTime: Longword; |
|
149 prevFocusState: boolean; |
150 begin |
150 begin |
151 PrevTime:= SDL_GetTicks; |
151 PrevTime:= SDL_GetTicks; |
152 while isTerminated = false do |
152 while isTerminated = false do |
153 begin |
153 begin |
154 {$IFDEF ANDROID} |
154 {$IFDEF ANDROID} |
163 {$IFDEF SDL13} |
163 {$IFDEF SDL13} |
164 // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3 |
164 // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3 |
165 KeyPressChat(event.key.keysym.sym); |
165 KeyPressChat(event.key.keysym.sym); |
166 SDL_WINDOWEVENT: |
166 SDL_WINDOWEVENT: |
167 if event.window.event = SDL_WINDOWEVENT_SHOWN then |
167 if event.window.event = SDL_WINDOWEVENT_SHOWN then |
|
168 begin |
168 cHasFocus:= true; |
169 cHasFocus:= true; |
|
170 onFocusStateChanged() |
|
171 end; |
169 {$ELSE} |
172 {$ELSE} |
170 KeyPressChat(event.key.keysym.unicode); |
173 KeyPressChat(event.key.keysym.unicode); |
171 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true; |
174 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true; |
172 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true; |
175 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true; |
173 SDL_ACTIVEEVENT: |
176 SDL_ACTIVEEVENT: |
174 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
177 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
|
178 begin |
|
179 prevFocusState:= cHasFocus; |
175 cHasFocus:= event.active.gain = 1; |
180 cHasFocus:= event.active.gain = 1; |
|
181 if prevFocusState xor cHasFocus then |
|
182 onFocusStateChanged() |
|
183 end; |
176 {$ENDIF} |
184 {$ENDIF} |
177 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
185 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
178 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
186 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
179 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
187 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
180 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
188 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |