179 end |
179 end |
180 else uKeys.isWalking:= false; |
180 else uKeys.isWalking:= false; |
181 {$ENDIF} |
181 {$ENDIF} |
182 case event.type_ of |
182 case event.type_ of |
183 {$IFDEF SDL13} |
183 {$IFDEF SDL13} |
184 SDL_WINDOWEVENT: |
184 SDL_WINDOWEVENT: |
185 {$ELSE} |
185 {$ELSE} |
186 SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); |
186 SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode); |
187 SDL_ACTIVEEVENT: |
187 SDL_ACTIVEEVENT: |
188 {$ENDIF} |
188 {$ENDIF} |
189 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
189 if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then |
190 cHasFocus:= event.active.gain = 1; |
190 cHasFocus:= event.active.gain = 1; |
191 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
191 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
192 {$IFDEF TOUCHINPUT} |
|
193 SDL_MOUSEMOTION: begin |
|
194 {$IFDEF DEBUGFILE} |
|
195 AddFileLog('********************************************* motion'); |
|
196 {$ENDIF} |
|
197 SDL_SelectMouse(event.motion.which); |
|
198 mouseState:= SDL_GetMouseState(@x, @y); |
|
199 SDL_GetRelativeMouseState(event.motion.which, @dx, @dy); |
|
200 |
|
201 direction:= nodir; |
|
202 |
|
203 if boolean(mouseState) then |
|
204 begin |
|
205 {$IFDEF DEBUGFILE} |
|
206 AddFileLog('x: ' + inttostr(x) + ' y: ' + inttostr(y) + ' dx: ' + inttostr(dx) + ' dy: ' + inttostr(dy)); |
|
207 {$ENDIF} |
|
208 |
|
209 {* zoom slider *} |
|
210 if (x <= 50) and (y <= 430) and (y > 50) then |
|
211 begin |
|
212 if (dy > 0) then uKeys.wheelDown:= true |
|
213 else if (dy < 0) then uKeys.wheelUp:= true; |
|
214 end; |
|
215 |
|
216 {* aim slider *} |
|
217 if (x > 270) and (y > 50) and (y <= 430) then |
|
218 begin |
|
219 if (dy > 0) then uKeys.downKey:= true |
|
220 else if (dy < 0) then uKeys.upKey:= true; |
|
221 end; |
|
222 |
|
223 {* switch *} |
|
224 if (x > 50) and (x <= 270) and (y > 400) then |
|
225 begin |
|
226 if (dy <> 0) then uKeys.tabKey:= true |
|
227 end; |
|
228 end; |
|
229 end; |
|
230 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
|
231 SDL_MOUSEBUTTONDOWN: begin |
|
232 {$IFDEF DEBUGFILE} |
|
233 AddFileLog('********************************************* touch down'); |
|
234 {$ENDIF} |
|
235 SDL_SelectMouse(event.motion.which); |
|
236 mouseState:= SDL_GetMouseState(@x, @y); |
|
237 SDL_GetRelativeMouseState(event.motion.which, @dx, @dy); |
|
238 {* attack *} |
|
239 if (x > 50) and (x <= 270) and (y <= 50) then |
|
240 begin |
|
241 WriteLnToConsole('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
242 uKeys.spaceKey:= true; |
|
243 uKeys.isAttacking:= true; |
|
244 end; |
|
245 |
|
246 if (x <= 50) and (y <= 50) then |
|
247 begin |
|
248 WriteLnToConsole('Left Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
249 direction:= left; |
|
250 movedbybuttons:= true; |
|
251 end; |
|
252 |
|
253 if (x > 270) and (y <= 50) then |
|
254 begin |
|
255 WriteLnToConsole('Right Arrow Key DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
256 direction:= right; |
|
257 movedbybuttons:= true; |
|
258 end; |
|
259 |
|
260 {* high jump *} |
|
261 if (x > 160) and (x <= 270) and (y > 400) then |
|
262 begin |
|
263 {$IFDEF DEBUGFILE} |
|
264 AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
265 {$ENDIF} |
|
266 uKeys.backspaceKey:= true; |
|
267 end; |
|
268 end; |
|
269 SDL_MOUSEBUTTONUP: begin |
|
270 {$IFDEF DEBUGFILE} |
|
271 AddFileLog('********************************************* touch up'); |
|
272 {$ENDIF} |
|
273 |
|
274 SDL_SelectMouse(event.motion.which); |
|
275 mouseState:= SDL_GetMouseState(@x, @y); |
|
276 SDL_GetRelativeMouseState(event.motion.which, @dx, @dy); |
|
277 uKeys.leftClick:= true; |
|
278 |
|
279 {* open ammo menu *} |
|
280 if (y > 430) and (x > 270) then |
|
281 begin |
|
282 {$IFDEF DEBUGFILE} |
|
283 AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
|
284 {$ENDIF} |
|
285 uKeys.rightClick:= true; |
|
286 end; |
|
287 |
|
288 {* long jump *} |
|
289 if (x > 50) and (x <= 160) and (y > 400) then |
|
290 begin |
|
291 {$IFDEF DEBUGFILE} |
|
292 AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
293 {$ENDIF} |
|
294 uKeys.enterKey:= true; |
|
295 end; |
|
296 |
|
297 {* reset zoom *} |
|
298 if (x <= 50) and (y > 430) then |
|
299 begin |
|
300 {$IFDEF DEBUGFILE} |
|
301 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
302 {$ENDIF} |
|
303 uKeys.middleClick:= true; |
|
304 end; |
|
305 |
|
306 {* end movement and attack *} |
|
307 {$IFDEF DEBUGFILE} |
|
308 AddFileLog('Arrow Keys UP | Space UP -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
|
309 {$ENDIF} |
|
310 direction:= nodir; |
|
311 movedbybuttons:= false; |
|
312 uKeys.isAttacking:= false; |
|
313 end; |
|
314 {$ENDIF} |
|
315 {$IFDEF IPHONEOS} |
192 {$IFDEF IPHONEOS} |
316 (* SDL_JOYAXISMOTION: begin |
193 (* SDL_JOYAXISMOTION: begin |
317 {* axis 0 = left and right; |
194 {* axis 0 = left and right; |
318 axis 1 = up and down; |
195 axis 1 = up and down; |
319 axis 2 = back and forth; *} |
196 axis 2 = back and forth; *} |
320 |
197 |
321 WriteLnToConsole('********************************************* accelerometer'); |
198 WriteLnToConsole('********************************************* accelerometer'); |
322 |
199 |
323 tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0); |
200 tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0); |
324 |
201 |
325 if (CurrentTeam <> nil) then |
202 if (CurrentTeam <> nil) then |
326 begin |
203 begin |
327 {$IFDEF DEBUGFILE} |
204 {$IFDEF DEBUGFILE} |
328 AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue)); |
205 AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue)); |
329 {$ENDIF} |
206 {$ENDIF} |
330 |
207 if tiltValue > 1500 then |
331 if tiltValue > 1500 then |
208 begin |
332 begin |
209 uKeys.rightKey:= true; |
333 uKeys.rightKey:= true; |
|
334 uKeys.isWalking:= true; |
|
335 end |
|
336 else |
|
337 if tiltValue <= -1500 then |
|
338 begin |
|
339 uKeys.leftKey:= true; |
|
340 uKeys.isWalking:= true; |
210 uKeys.isWalking:= true; |
341 end |
211 end |
342 else |
212 else |
343 if (tiltValue > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false; |
213 if tiltValue <= -1500 then |
|
214 begin |
|
215 uKeys.leftKey:= true; |
|
216 uKeys.isWalking:= true; |
|
217 end |
|
218 else |
|
219 if (tiltValue > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false; |
344 end; |
220 end; |
345 end;*) |
221 end;*) |
346 {$ELSE} |
222 {$ELSE} |
347 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; |
223 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; |
348 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true; |
224 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then uKeys.wheelUp:= true; |
349 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
225 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
350 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
226 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |