Lines 45-57
Link Here
|
45 |
// |
45 |
// |
46 |
// replacing refresh manager |
46 |
// replacing refresh manager |
47 |
// |
47 |
// |
48 |
unsigned tics; |
48 |
int tics; |
49 |
|
49 |
|
50 |
// |
50 |
// |
51 |
// control info |
51 |
// control info |
52 |
// |
52 |
// |
53 |
boolean mouseenabled, joystickenabled; |
53 |
boolean mouseenabled, joystickenabled; |
54 |
int dirscan[4] = { sc_UpArrow, sc_RightArrow, sc_DownArrow, sc_LeftArrow }; |
54 |
int dirscan[4] = { sc_W, sc_D, sc_S, sc_A }; |
55 |
int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4 }; |
55 |
int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4 }; |
56 |
int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton }; |
56 |
int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton }; |
57 |
int buttonjoy[32] = { |
57 |
int buttonjoy[32] = { |
Lines 77-83
Link Here
|
77 |
// |
77 |
// |
78 |
// current user input |
78 |
// current user input |
79 |
// |
79 |
// |
80 |
int controlx, controly; // range from -100 to 100 per tic |
80 |
int controlx, controly, controlh; // range from -100 to 100 per tic |
81 |
boolean buttonstate[NUMBUTTONS]; |
81 |
boolean buttonstate[NUMBUTTONS]; |
82 |
|
82 |
|
83 |
int lastgamemusicoffset = 0; |
83 |
int lastgamemusicoffset = 0; |
Lines 315-330
Link Here
|
315 |
|
315 |
|
316 |
void PollKeyboardMove (void) |
316 |
void PollKeyboardMove (void) |
317 |
{ |
317 |
{ |
318 |
int delta = buttonstate[bt_run] ? RUNMOVE * tics : BASEMOVE * tics; |
|
|
319 |
|
320 |
if (Keyboard[dirscan[di_north]]) |
318 |
if (Keyboard[dirscan[di_north]]) |
321 |
controly -= delta; |
319 |
if (Keyboard[dirscan[di_south]]) |
322 |
if (Keyboard[dirscan[di_south]]) |
320 |
if (Keyboard[dirscan[di_west]]) |
323 |
controly += delta; |
321 |
{ |
324 |
if (Keyboard[dirscan[di_west]]) |
322 |
if (!Keyboard[dirscan[di_east]]) |
325 |
controlx -= delta; |
323 |
controlx = -BASEMOVE * tics; |
326 |
if (Keyboard[dirscan[di_east]]) |
324 |
} |
327 |
controlx += delta; |
325 |
else |
|
|
326 |
{ |
327 |
if (Keyboard[dirscan[di_east]]) |
328 |
controlx = BASEMOVE * tics; |
329 |
} |
330 |
else |
331 |
if (Keyboard[dirscan[di_west]]) |
332 |
if (Keyboard[dirscan[di_east]]) |
333 |
controly = (buttonstate[bt_run]) ? -RUNMOVE * tics : -BASEMOVE * tics; |
334 |
else |
335 |
{ |
336 |
controlx = (buttonstate[bt_run]) ? -RUNMOVEDIAG * tics : -BASEMOVEDIAG * tics; |
337 |
controly = controlx; |
338 |
} |
339 |
else |
340 |
if (Keyboard[dirscan[di_east]]) |
341 |
{ |
342 |
controlx = (buttonstate[bt_run]) ? RUNMOVEDIAG * tics : BASEMOVEDIAG * tics; |
343 |
controly = -controlx; |
344 |
} |
345 |
else |
346 |
controly = (buttonstate[bt_run]) ? -RUNMOVE * tics : -BASEMOVE * tics; |
347 |
else |
348 |
if (Keyboard[dirscan[di_south]]) |
349 |
if (Keyboard[dirscan[di_west]]) |
350 |
if (Keyboard[dirscan[di_east]]) |
351 |
controly = (buttonstate[bt_run]) ? RUNMOVE * tics : BASEMOVE * tics; |
352 |
else |
353 |
{ |
354 |
controly = (buttonstate[bt_run]) ? RUNMOVEDIAG * tics : BASEMOVEDIAG * tics; |
355 |
controlx = -controly; |
356 |
} |
357 |
else |
358 |
if (Keyboard[dirscan[di_east]]) |
359 |
{ |
360 |
controlx = (buttonstate[bt_run]) ? RUNMOVEDIAG * tics : BASEMOVEDIAG * tics; |
361 |
controly = controlx; |
362 |
} |
363 |
else |
364 |
controly = (buttonstate[bt_run]) ? RUNMOVE * tics : BASEMOVE * tics; |
365 |
else |
366 |
if (Keyboard[dirscan[di_west]]) |
367 |
{ |
368 |
if (!Keyboard[dirscan[di_east]]) |
369 |
controlx = -BASEMOVE * tics; |
370 |
} |
371 |
else |
372 |
if (Keyboard[dirscan[di_east]]) |
373 |
controlx = BASEMOVE * tics; |
328 |
} |
374 |
} |
329 |
|
375 |
|
330 |
|
376 |
|
Lines 345-354
Link Here
|
345 |
IN_CenterMouse(); |
391 |
IN_CenterMouse(); |
346 |
|
392 |
|
347 |
mousexmove -= screenWidth / 2; |
393 |
mousexmove -= screenWidth / 2; |
348 |
mouseymove -= screenHeight / 2; |
|
|
349 |
|
394 |
|
350 |
controlx += mousexmove * 10 / (13 - mouseadjustment); |
395 |
controlh += (mousexmove << 4) / (13 - mouseadjustment); |
351 |
controly += mouseymove * 20 / (13 - mouseadjustment); |
|
|
352 |
} |
396 |
} |
353 |
|
397 |
|
354 |
|
398 |
|
Lines 366-381
Link Here
|
366 |
|
410 |
|
367 |
IN_GetJoyDelta (&joyx, &joyy); |
411 |
IN_GetJoyDelta (&joyx, &joyy); |
368 |
|
412 |
|
369 |
int delta = buttonstate[bt_run] ? RUNMOVE * tics : BASEMOVE * tics; |
413 |
if (buttonstate[bt_strafe]) |
370 |
|
414 |
{ |
371 |
if (joyx > 64 || buttonstate[bt_turnright]) |
415 |
if (joyy < -64) |
372 |
controlx += delta; |
416 |
if (joyx < -64) |
373 |
else if (joyx < -64 || buttonstate[bt_turnleft]) |
417 |
{ |
374 |
controlx -= delta; |
418 |
controlx = (buttonstate[bt_run]) ? BASEMOVEDIAG * tics : RUNMOVEDIAG * tics; |
375 |
if (joyy > 64 || buttonstate[bt_movebackward]) |
419 |
controly = controlx; |
376 |
controly += delta; |
420 |
} |
377 |
else if (joyy < -64 || buttonstate[bt_moveforward]) |
421 |
else if (joyx > 64) |
378 |
controly -= delta; |
422 |
{ |
|
|
423 |
controlx = (buttonstate[bt_run]) ? BASEMOVEDIAG * tics : RUNMOVEDIAG * tics; |
424 |
controly = -controlx; |
425 |
} |
426 |
else |
427 |
controly = (buttonstate[bt_run]) ? -BASEMOVE * tics : -RUNMOVE * tics; |
428 |
else |
429 |
if (joyy > 64) |
430 |
if (joyx < -64) |
431 |
{ |
432 |
controly = (buttonstate[bt_run]) ? BASEMOVEDIAG * tics : RUNMOVEDIAG * tics; |
433 |
controlx = -controly; |
434 |
} |
435 |
else if (joyx > 64) |
436 |
{ |
437 |
controlx = (buttonstate[bt_run]) ? BASEMOVEDIAG * tics : RUNMOVEDIAG * tics; |
438 |
controly = controlx; |
439 |
} |
440 |
else |
441 |
controly = (buttonstate[bt_run]) ? BASEMOVE * tics : RUNMOVE * tics; |
442 |
} |
443 |
else |
444 |
{ |
445 |
if (joyx < -64) |
446 |
controlh = (buttonstate[bt_run]) ? -BASEMOVE * tics : -RUNMOVE * tics; |
447 |
else if (joyx > 64) |
448 |
controlh = (buttonstate[bt_run]) ? BASEMOVE * tics : RUNMOVE * tics; |
449 |
if (joyy < -64) |
450 |
controly = (buttonstate[bt_run]) ? -BASEMOVE * tics : -RUNMOVE * tics; |
451 |
else if (joyy > 64) |
452 |
controly = (buttonstate[bt_run]) ? BASEMOVE * tics : RUNMOVE * tics; |
453 |
} |
379 |
} |
454 |
} |
380 |
|
455 |
|
381 |
/* |
456 |
/* |
Lines 395-401
Link Here
|
395 |
|
470 |
|
396 |
void PollControls (void) |
471 |
void PollControls (void) |
397 |
{ |
472 |
{ |
398 |
int max, min, i; |
473 |
int max, min, rmax, rmin, i; |
399 |
byte buttonbits; |
474 |
byte buttonbits; |
400 |
|
475 |
|
401 |
IN_ProcessEvents(); |
476 |
IN_ProcessEvents(); |
Lines 422-427
Link Here
|
422 |
|
497 |
|
423 |
controlx = 0; |
498 |
controlx = 0; |
424 |
controly = 0; |
499 |
controly = 0; |
|
|
500 |
controlh = 0; |
425 |
memcpy (buttonheld, buttonstate, sizeof (buttonstate)); |
501 |
memcpy (buttonheld, buttonstate, sizeof (buttonstate)); |
426 |
memset (buttonstate, 0, sizeof (buttonstate)); |
502 |
memset (buttonstate, 0, sizeof (buttonstate)); |
427 |
|
503 |
|
Lines 445-450
Link Here
|
445 |
|
521 |
|
446 |
controlx *= (int) tics; |
522 |
controlx *= (int) tics; |
447 |
controly *= (int) tics; |
523 |
controly *= (int) tics; |
|
|
524 |
controlh *= (int) tics; |
448 |
|
525 |
|
449 |
return; |
526 |
return; |
450 |
} |
527 |
} |
Lines 477-482
Link Here
|
477 |
// |
554 |
// |
478 |
max = 100 * tics; |
555 |
max = 100 * tics; |
479 |
min = -max; |
556 |
min = -max; |
|
|
557 |
rmax = max << 4; |
558 |
rmin = -rmax; |
480 |
if (controlx > max) |
559 |
if (controlx > max) |
481 |
controlx = max; |
560 |
controlx = max; |
482 |
else if (controlx < min) |
561 |
else if (controlx < min) |
Lines 487-492
Link Here
|
487 |
else if (controly < min) |
566 |
else if (controly < min) |
488 |
controly = min; |
567 |
controly = min; |
489 |
|
568 |
|
|
|
569 |
if (controlh > rmax) |
570 |
controlh = rmax; |
571 |
else if (controlh < rmin) |
572 |
controlh = rmin; |
573 |
|
490 |
if (demorecord) |
574 |
if (demorecord) |
491 |
{ |
575 |
{ |
492 |
// |
576 |
// |
Lines 494-499
Link Here
|
494 |
// |
578 |
// |
495 |
controlx /= (int) tics; |
579 |
controlx /= (int) tics; |
496 |
controly /= (int) tics; |
580 |
controly /= (int) tics; |
|
|
581 |
controlh /= (int) tics; |
497 |
|
582 |
|
498 |
buttonbits = 0; |
583 |
buttonbits = 0; |
499 |
|
584 |
|
Lines 508-513
Link Here
|
508 |
*demoptr++ = buttonbits; |
593 |
*demoptr++ = buttonbits; |
509 |
*demoptr++ = controlx; |
594 |
*demoptr++ = controlx; |
510 |
*demoptr++ = controly; |
595 |
*demoptr++ = controly; |
|
|
596 |
*demoptr++ = controlh; |
511 |
|
597 |
|
512 |
if (demoptr >= lastdemoptr - 8) |
598 |
if (demoptr >= lastdemoptr - 8) |
513 |
playstate = ex_completed; |
599 |
playstate = ex_completed; |
Lines 515-520
Link Here
|
515 |
{ |
601 |
{ |
516 |
controlx *= (int) tics; |
602 |
controlx *= (int) tics; |
517 |
controly *= (int) tics; |
603 |
controly *= (int) tics; |
|
|
604 |
controlh *= (int) tics; |
518 |
} |
605 |
} |
519 |
} |
606 |
} |
520 |
} |
607 |
} |