]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
sound direction fix (negated yaw angle), submitted by div0
[xonotic/darkplaces.git] / cl_input.c
index 3c8a514082b54c47c96be1f0ad30d020cf372b0a..729e306d073173f8df96b68c861d7c8343ab32f5 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // rights reserved.
 
 #include "quakedef.h"
+#include "csprogs.h"
 
 /*
 ===============================================================================
@@ -53,6 +54,8 @@ kbutton_t     in_strafe, in_speed, in_jump, in_attack, in_use;
 kbutton_t      in_up, in_down;
 // LordHavoc: added 6 new buttons
 kbutton_t      in_button3, in_button4, in_button5, in_button6, in_button7, in_button8;
+//even more
+kbutton_t      in_button9, in_button10, in_button11, in_button12, in_button13, in_button14, in_button15, in_button16;
 
 int                    in_impulse;
 
@@ -173,6 +176,23 @@ void IN_Button7Up(void) {KeyUp(&in_button7);}
 void IN_Button8Down(void) {KeyDown(&in_button8);}
 void IN_Button8Up(void) {KeyUp(&in_button8);}
 
+void IN_Button9Down(void) {KeyDown(&in_button9);}
+void IN_Button9Up(void) {KeyUp(&in_button9);}
+void IN_Button10Down(void) {KeyDown(&in_button10);}
+void IN_Button10Up(void) {KeyUp(&in_button10);}
+void IN_Button11Down(void) {KeyDown(&in_button11);}
+void IN_Button11Up(void) {KeyUp(&in_button11);}
+void IN_Button12Down(void) {KeyDown(&in_button12);}
+void IN_Button12Up(void) {KeyUp(&in_button12);}
+void IN_Button13Down(void) {KeyDown(&in_button13);}
+void IN_Button13Up(void) {KeyUp(&in_button13);}
+void IN_Button14Down(void) {KeyDown(&in_button14);}
+void IN_Button14Up(void) {KeyUp(&in_button14);}
+void IN_Button15Down(void) {KeyDown(&in_button15);}
+void IN_Button15Up(void) {KeyUp(&in_button15);}
+void IN_Button16Down(void) {KeyDown(&in_button16);}
+void IN_Button16Up(void) {KeyUp(&in_button16);}
+
 void IN_JumpDown (void) {KeyDown(&in_jump);}
 void IN_JumpUp (void) {KeyUp(&in_jump);}
 
@@ -396,7 +416,7 @@ void CL_Move (void)
        old_mouse_y = my;
 
        // if not in menu, apply mouse move to viewangles/movement
-       if (in_client_mouse)
+       if (!cl.csqc_wantsmousemove && in_client_mouse)
        {
                if (cl_prydoncursor.integer)
                {
@@ -409,18 +429,18 @@ void CL_Move (void)
                {
                        // strafing mode, all looking is movement
                        V_StopPitchDrift();
-                       cl.cmd.sidemove += m_side.value * in_mouse_x * sensitivity.value * cl.viewzoom;
+                       cl.cmd.sidemove += m_side.value * in_mouse_x * sensitivity.value;
                        if (noclip_anglehack)
-                               cl.cmd.upmove -= m_forward.value * in_mouse_y * sensitivity.value * cl.viewzoom;
+                               cl.cmd.upmove -= m_forward.value * in_mouse_y * sensitivity.value;
                        else
-                               cl.cmd.forwardmove -= m_forward.value * in_mouse_y * sensitivity.value * cl.viewzoom;
+                               cl.cmd.forwardmove -= m_forward.value * in_mouse_y * sensitivity.value;
                }
                else if ((in_mlook.state & 1) || freelook.integer)
                {
                        // mouselook, lookstrafe causes turning to become strafing
                        V_StopPitchDrift();
                        if (lookstrafe.integer)
-                               cl.cmd.sidemove += m_side.value * in_mouse_x * sensitivity.value * cl.viewzoom;
+                               cl.cmd.sidemove += m_side.value * in_mouse_x * sensitivity.value;
                        else
                                cl.viewangles[YAW] -= m_yaw.value * in_mouse_x * sensitivity.value * cl.viewzoom;
                        cl.viewangles[PITCH] += m_pitch.value * in_mouse_y * sensitivity.value * cl.viewzoom;
@@ -429,7 +449,7 @@ void CL_Move (void)
                {
                        // non-mouselook, yaw turning and forward/back movement
                        cl.viewangles[YAW] -= m_yaw.value * in_mouse_x * sensitivity.value * cl.viewzoom;
-                       cl.cmd.forwardmove -= m_forward.value * in_mouse_y * sensitivity.value * cl.viewzoom;
+                       cl.cmd.forwardmove -= m_forward.value * in_mouse_y * sensitivity.value;
                }
        }
 
@@ -473,8 +493,8 @@ void CL_UpdatePrydonCursor(void)
        cl.cmd.cursor_screen[1] = bound(-1, cl.cmd.cursor_screen[1], 1);
        cl.cmd.cursor_screen[2] = 1;
 
-       scale[0] = -tan(r_refdef.fov_x * M_PI / 360.0);
-       scale[1] = -tan(r_refdef.fov_y * M_PI / 360.0);
+       scale[0] = -r_refdef.frustum_x;
+       scale[1] = -r_refdef.frustum_y;
        scale[2] = 1;
 
        // trace distance
@@ -487,7 +507,7 @@ void CL_UpdatePrydonCursor(void)
        VectorSet(temp, cl.cmd.cursor_screen[2] * scale[2], cl.cmd.cursor_screen[0] * scale[0], cl.cmd.cursor_screen[1] * scale[1]);
        Matrix4x4_Transform(&r_refdef.viewentitymatrix, temp, cl.cmd.cursor_end);
        // trace from view origin to the cursor
-       cl.cmd.cursor_fraction = CL_SelectTraceLine(cl.cmd.cursor_start, cl.cmd.cursor_end, cl.cmd.cursor_impact, cl.cmd.cursor_normal, &cl.cmd.cursor_entitynumber, (chase_active.integer || cl.intermission) ? &cl_entities[cl.playerentity].render : NULL);
+       cl.cmd.cursor_fraction = CL_SelectTraceLine(cl.cmd.cursor_start, cl.cmd.cursor_end, cl.cmd.cursor_impact, cl.cmd.cursor_normal, &cl.cmd.cursor_entitynumber, (chase_active.integer || cl.intermission) ? &cl_entities[cl.playerentity].render : NULL, false);
        // makes sparks where cursor is
        //CL_SparkShower(cl.cmd.cursor_impact, cl.cmd.cursor_normal, 5, 0);
 }
@@ -784,7 +804,7 @@ void CL_SendMove(void)
        int i;
        int bits;
        sizebuf_t buf;
-       qbyte data[128];
+       unsigned char data[128];
 #define MOVEAVERAGING 0
 #if MOVEAVERAGING
        static float forwardmove, sidemove, upmove, total; // accumulation
@@ -835,13 +855,23 @@ void CL_SendMove(void)
        if (in_use.state      & 3) bits |= 256;in_use.state     &= ~2;
        if (key_dest != key_game || key_consoleactive) bits |= 512;
        if (cl_prydoncursor.integer) bits |= 1024;
-       // button bits 11-31 unused currently
+       if (in_button9.state  & 3)  bits |=   2048;in_button9.state  &= ~2;
+       if (in_button10.state  & 3) bits |=   4096;in_button10.state &= ~2;
+       if (in_button11.state  & 3) bits |=   8192;in_button11.state &= ~2;
+       if (in_button12.state  & 3) bits |=  16384;in_button12.state &= ~2;
+       if (in_button13.state  & 3) bits |=  32768;in_button13.state &= ~2;
+       if (in_button14.state  & 3) bits |=  65536;in_button14.state &= ~2;
+       if (in_button15.state  & 3) bits |= 131072;in_button15.state &= ~2;
+       if (in_button16.state  & 3) bits |= 262144;in_button16.state &= ~2;
+       // button bits 19-31 unused currently
        // rotate/zoom view serverside if PRYDON_CLIENTCURSOR cursor is at edge of screen
        if (cl.cmd.cursor_screen[0] <= -1) bits |= 8;
        if (cl.cmd.cursor_screen[0] >=  1) bits |= 16;
        if (cl.cmd.cursor_screen[1] <= -1) bits |= 32;
        if (cl.cmd.cursor_screen[1] >=  1) bits |= 64;
 
+       csqc_buttons = bits;
+
        // always dump the first two messages, because they may contain leftover inputs from the last level
        if (++cl.movemessages >= 2)
        {
@@ -1041,6 +1071,22 @@ void CL_InitInput (void)
        Cmd_AddCommand ("-button7", IN_Button7Up);
        Cmd_AddCommand ("+button8", IN_Button8Down);
        Cmd_AddCommand ("-button8", IN_Button8Up);
+       Cmd_AddCommand ("+button9", IN_Button9Down);
+       Cmd_AddCommand ("-button9", IN_Button9Up);
+       Cmd_AddCommand ("+button10", IN_Button10Down);
+       Cmd_AddCommand ("-button10", IN_Button10Up);
+       Cmd_AddCommand ("+button11", IN_Button11Down);
+       Cmd_AddCommand ("-button11", IN_Button11Up);
+       Cmd_AddCommand ("+button12", IN_Button12Down);
+       Cmd_AddCommand ("-button12", IN_Button12Up);
+       Cmd_AddCommand ("+button13", IN_Button13Down);
+       Cmd_AddCommand ("-button13", IN_Button13Up);
+       Cmd_AddCommand ("+button14", IN_Button14Down);
+       Cmd_AddCommand ("-button14", IN_Button14Up);
+       Cmd_AddCommand ("+button15", IN_Button15Down);
+       Cmd_AddCommand ("-button15", IN_Button15Up);
+       Cmd_AddCommand ("+button16", IN_Button16Down);
+       Cmd_AddCommand ("-button16", IN_Button16Up);
 
        Cvar_RegisterVariable(&cl_movement);
        Cvar_RegisterVariable(&cl_movement_latency);