186 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
187 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
187 {*Keys are in uKeys.pas*} |
188 {*Keys are in uKeys.pas*} |
188 SDL_MOUSEBUTTONDOWN: begin |
189 SDL_MOUSEBUTTONDOWN: begin |
189 mouseState:= SDL_GetMouseState(0, @x, @y); |
190 mouseState:= SDL_GetMouseState(0, @x, @y); |
190 if x <= 50 then |
191 if x <= 50 then |
191 begin |
192 begin |
|
193 {$IFDEF DEBUGFILE} |
192 AddFileLog('Wheel -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
194 AddFileLog('Wheel -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
195 {$ENDIF} |
193 {* sliding *} |
196 {* sliding *} |
194 if oldy - y > 0 then uKeys.wheelUp:= true |
197 if oldy - y > 0 then uKeys.wheelUp:= true |
195 else uKeys.wheelDown:= true; |
198 else uKeys.wheelDown:= true; |
196 {* update value only if movement is consistent *} |
199 {* update value only if movement is consistent *} |
197 // if (y > oldy - 10 ) or (y > oldy + 10 ) then oldy:= y |
200 // if (y > oldy - 10 ) or (y > oldy + 10 ) then oldy:= y |
205 |
208 |
206 if (y <= 50) and (x > 135) and (x <= 185) then uKeys.upKey:= true; |
209 if (y <= 50) and (x > 135) and (x <= 185) then uKeys.upKey:= true; |
207 if (y > 430) and (x > 135) and (x <= 185) then uKeys.downKey:= true; |
210 if (y > 430) and (x > 135) and (x <= 185) then uKeys.downKey:= true; |
208 if (x > 270) and (y > 215) and (y > 265) then uKeys.rightClick:= true; |
211 if (x > 270) and (y > 215) and (y > 265) then uKeys.rightClick:= true; |
209 if (x <= 100) and (y > 215) and (y > 265) then uKeys.leftClick:= true; |
212 if (x <= 100) and (y > 215) and (y > 265) then uKeys.leftClick:= true; |
210 end; |
213 end;*} |
211 |
214 |
212 if (y > 430) and (x > 50) and (x <= 135) then |
215 if (y > 430) and (x > 50) and (x <= 135) then |
213 begin |
216 begin |
|
217 {$IFDEF DEBUGFILE} |
214 AddFileLog('Space -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
218 AddFileLog('Space -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
215 uKeys.spaceKey:= true; |
219 {$ENDIF} |
|
220 ParseCommand('ljump', true); |
216 end; |
221 end; |
217 if (y > 430) and (x > 185) and (x <= 270) then |
222 if (y > 430) and (x > 185) and (x <= 270) then |
218 begin |
223 begin |
219 AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
224 {$IFDEF DEBUGFILE} |
220 uKeys.enterKey:= true; |
225 AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
221 end;*} |
226 {$ENDIF} |
|
227 ParseCommand('hjump', true); |
|
228 end; |
|
229 if (y <= 50) and (x > 50) and (x <= 270) then |
|
230 begin |
|
231 {$IFDEF DEBUGFILE} |
|
232 AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
233 {$ENDIF} |
|
234 //ParseCommand('hjump', true); |
|
235 end; |
222 end; |
236 end; |
223 SDL_MOUSEBUTTONUP: begin |
237 SDL_MOUSEBUTTONUP: begin |
224 mouseState:= SDL_GetMouseState(0, @x, @y); |
238 mouseState:= SDL_GetMouseState(0, @x, @y); |
225 x_up:= x; |
|
226 y_up:= y; |
|
227 |
|
228 {* open ammo menu *} |
239 {* open ammo menu *} |
229 if (y > 430) and (x > 270) then |
240 if (y > 430) and (x > 270) then |
230 begin |
241 begin |
|
242 {$IFDEF DEBUGFILE} |
231 AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
243 AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
|
244 {$ENDIF} |
232 uKeys.rightClick:= true; |
245 uKeys.rightClick:= true; |
233 end; |
246 end; |
234 {* reset zoom *} |
247 {* reset zoom *} |
235 if (x > 270) and (y <= 50) then |
248 if (x > 270) and (y <= 50) then |
236 begin |
249 begin |
|
250 {$IFDEF DEBUGFILE} |
237 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
251 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
252 {$ENDIF} |
238 uKeys.middleClick:= true; |
253 uKeys.middleClick:= true; |
239 end; |
254 end; |
240 |
|
241 |
|
242 end; |
255 end; |
|
256 SDL_JOYAXIS: begin |
|
257 {axis 2 = back and forth; axis 1 = up and down; axis 0 = left and right} |
|
258 //AddFileLog('which: ' + inttostr(event.jaxis.which) + ' axis: ' + inttostr(event.jaxis.axis) + ' value: ' + inttostr(event.jaxis.value)); |
|
259 if (event.jaxis.axis = 0) and (CurrentTeam <> nil) then |
|
260 begin |
|
261 if (modulo(event.jaxis.value) > (oldJoy + 400)) or (modulo(event.jaxis.value) < (oldJoy - 400)) then |
|
262 begin |
|
263 if event.jaxis.value > 1500 then ParseCommand('+right', true) else |
|
264 if event.jaxis.value <= -1500 then ParseCommand('+left', true) else |
|
265 if (event.jaxis.value > 0) and (event.jaxis.value <= 1500) then ParseCommand('-right', true) else |
|
266 if (event.jaxis.value <= 0) and (event.jaxis.value > -1500) then ParseCommand('-left', true); |
|
267 {$IFDEF DEBUGFILE} |
|
268 AddFileLog('Joystick value: ' + inttostr(event.jaxis.value) + ' oldJoy: ' + inttostr(oldJoy)); |
|
269 {$ENDIF} |
|
270 oldJoy:= modulo(event.jaxis.value); |
|
271 end; |
|
272 end; |
|
273 |
|
274 end; |
|
275 |
243 {$ELSE} |
276 {$ELSE} |
244 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; |
277 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; |
245 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true; |
278 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true; |
246 {$ENDIF} |
|
247 SDL_JOYAXIS: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
279 SDL_JOYAXIS: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
248 SDL_JOYHAT: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
280 SDL_JOYHAT: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
249 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
281 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
250 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
282 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
|
283 {$ENDIF} |
251 SDL_QUITEV: isTerminated:= true |
284 SDL_QUITEV: isTerminated:= true |
252 end; |
285 end; |
253 CurrTime:= SDL_GetTicks; |
286 CurrTime:= SDL_GetTicks; |
254 if PrevTime + cTimerInterval <= CurrTime then |
287 if PrevTime + cTimerInterval <= CurrTime then |
255 begin |
288 begin |