| 813 | } |
| 814 | |
| 815 | void DoKeyboardMovement(game_controls *controls) { |
| 816 | float dx, dy, dz, dp, dh, db, d_afterburn; |
| 817 | ct_packet key_x1, key_x0, key_y1, key_y0, key_z1, key_z0; |
| 818 | ct_packet key_p1, key_p0, key_h1, key_h0, key_b1, key_b0; |
| 819 | ct_packet key_afterburn; |
| 820 | |
| 821 | // read controls |
| 822 | Controller->get_packet(ctfFORWARD_THRUSTKEY, &key_z1); |
| 823 | Controller->get_packet(ctfREVERSE_THRUSTKEY, &key_z0); |
| 824 | Controller->get_packet(ctfUP_THRUSTKEY, &key_y1); |
| 825 | Controller->get_packet(ctfDOWN_THRUSTKEY, &key_y0); |
| 826 | Controller->get_packet(ctfRIGHT_THRUSTKEY, &key_x1); |
| 827 | Controller->get_packet(ctfLEFT_THRUSTKEY, &key_x0); |
| 828 | Controller->get_packet(ctfPITCH_DOWNKEY, &key_p1); |
| 829 | Controller->get_packet(ctfPITCH_UPKEY, &key_p0); |
| 830 | Controller->get_packet(ctfBANK_RIGHTKEY, &key_b1); |
| 831 | Controller->get_packet(ctfBANK_LEFTKEY, &key_b0); |
| 832 | Controller->get_packet(ctfHEADING_RIGHTKEY, &key_h1); |
| 833 | Controller->get_packet(ctfHEADING_LEFTKEY, &key_h0); |
| 834 | |
| 835 | Controller->get_packet(ctfAFTERBURN_KEY, &key_afterburn); |
| 836 | |
| 837 | // check keyboard controls first. |
| 838 | |
| 839 | // do thrust and orientation controls. since packet contains time since last call, frametime is taken into |
| 840 | // account. note that the ctDigital packets are for those rare cases where a key is down, but there is no key down |
| 841 | // time registered as of yet, which happens on some systems. |
| 842 | dx = (key_x1.value - key_x0.value); |
| 843 | dy = (key_y1.value - key_y0.value); |
| 844 | dz = (key_z1.value - key_z0.value); |
| 845 | dp = (key_p1.value - key_p0.value); |
| 846 | db = (key_b0.value - key_b1.value); |
| 847 | dh = (key_h1.value - key_h0.value); |
| 848 | |
| 849 | d_afterburn = (key_afterburn.value); |
| 850 | |
| 851 | controls->sideways_thrust += |
| 852 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dx, KEY_RAMPUP_TIME, Key_ramp.x, Key_ramp.ox) / KEY_RAMPUP_TIME) : dx; |
| 853 | controls->vertical_thrust += |
| 854 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dy, KEY_RAMPUP_TIME, Key_ramp.y, Key_ramp.oy) / KEY_RAMPUP_TIME) : dy; |
| 855 | controls->forward_thrust += |
| 856 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dz, KEY_RAMPUP_TIME, Key_ramp.z, Key_ramp.oz) / KEY_RAMPUP_TIME) : dz; |
| 857 | |
| 858 | controls->afterburn_thrust += d_afterburn / Frametime; |
| 859 | |
| 860 | if (!controls->toggle_slide && !controls->toggle_bank) { |
| 861 | // clamp pitch ramp time to limits. |
| 862 | controls->pitch_thrust += |
| 863 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dp, KEY_RAMPUP_TIME, Key_ramp.p, Key_ramp.op) / KEY_RAMPUP_TIME) : dp; |
| 864 | controls->heading_thrust += |
| 865 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dh, KEY_RAMPUP_TIME, Key_ramp.h, Key_ramp.oh) / KEY_RAMPUP_TIME) : dh; |
| 866 | } |
| 867 | |
| 868 | if (controls->toggle_slide) { |
| 869 | controls->sideways_thrust += |
| 870 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dh, KEY_RAMPUP_TIME, Key_ramp.h, Key_ramp.oh) / KEY_RAMPUP_TIME) : dh; |
| 871 | controls->vertical_thrust += |
| 872 | (KEY_RAMPUP_TIME) ? (ramp_control_value(dp, KEY_RAMPUP_TIME, Key_ramp.p, Key_ramp.op) / KEY_RAMPUP_TIME) : dp; |
no test coverage detected