]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - in_win.c
fix mouse in win32, I had forgotten to update a lot of code
[xonotic/darkplaces.git] / in_win.c
index d814845f45fa596aede653baa711fc8f100dd977..60eb8a83e0bc0a067390274005af1d0ebc2f5a04 100644 (file)
--- a/in_win.c
+++ b/in_win.c
@@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 #include "winquake.h"
-//#include "dosisms.h"
 
 #include <dinput.h>
 
@@ -33,8 +32,6 @@ HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
        LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
 
 // mouse variables
-cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
-
 int                    mouse_buttons;
 int                    mouse_oldbuttonstate;
 POINT          current_pos;
@@ -438,9 +435,6 @@ IN_Init
 */
 void IN_Init (void)
 {
-       // mouse variables
-       Cvar_RegisterVariable (&m_filter);
-
        // joystick variables
        Cvar_RegisterVariable (&in_joystick);
        Cvar_RegisterVariable (&joy_name);
@@ -477,7 +471,6 @@ IN_Shutdown
 */
 void IN_Shutdown (void)
 {
-//     usingmouse = false;
        IN_DeactivateMouse ();
        IN_ShowMouse ();
 
@@ -534,7 +527,7 @@ IN_MouseMove
 */
 void IN_MouseMove (usercmd_t *cmd)
 {
-       int                                     i, mx, my, mouselook = (in_mlook.state & 1) || freelook.value;
+       int                                     i, mx, my;
        DIDEVICEOBJECTDATA      od;
        DWORD                           dwElements;
        HRESULT                         hr;
@@ -567,9 +560,7 @@ void IN_MouseMove (usercmd_t *cmd)
 
                        /* Unable to read data or no data available */
                        if (FAILED(hr) || dwElements == 0)
-                       {
                                break;
-                       }
 
                        /* Look at the element to see what happened */
 
@@ -633,57 +624,11 @@ void IN_MouseMove (usercmd_t *cmd)
                my_accum = 0;
        }
 
-//if (mx ||  my)
-//     Con_DPrintf("mx=%d, my=%d\n", mx, my);
-
-       if (m_filter.value)
-       {
-               mouse_x = (mx + old_mouse_x) * 0.5;
-               mouse_y = (my + old_mouse_y) * 0.5;
-       }
-       else
-       {
-               mouse_x = mx;
-               mouse_y = my;
-       }
-
-       old_mouse_x = mx;
-       old_mouse_y = my;
-
-       mouse_x *= sensitivity.value;
-       mouse_y *= sensitivity.value;
-
-// add mouse X/Y movement to cmd
-       if ( (in_strafe.state & 1) || (lookstrafe.value && mouselook))
-               cmd->sidemove += m_side.value * mouse_x;
-       else
-               cl.viewangles[YAW] -= m_yaw.value * mouse_x;
-
-       if (mouselook)
-               V_StopPitchDrift ();
-       
-       // LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
-       if (mouselook && !(in_strafe.state & 1))
-       {
-               cl.viewangles[PITCH] += m_pitch.value * mouse_y;
-               if (cl.viewangles[PITCH] > 90)
-                       cl.viewangles[PITCH] = 90;
-               if (cl.viewangles[PITCH] < -90)
-                       cl.viewangles[PITCH] = -90;
-       }
-       else
-       {
-               if ((in_strafe.state & 1) && noclip_anglehack)
-                       cmd->upmove -= m_forward.value * mouse_y;
-               else
-                       cmd->forwardmove -= m_forward.value * mouse_y;
-       }
+       IN_Mouse(cmd, mx, my);
 
-// if the mouse has moved, force it to the center, so there's room to move
-       if (mx || my)
-       {
+       // if the mouse has moved, force it to the center, so there's room to move
+       if (!dinput && (mx || my))
                SetCursorPos (window_center_x, window_center_y);
-       }
 }
 
 
@@ -694,12 +639,13 @@ IN_Move
 */
 void IN_Move (usercmd_t *cmd)
 {
-
-       if (ActiveApp && !Minimized)
+       if (vid_activewindow && !vid_hidden)
        {
                IN_MouseMove (cmd);
                IN_JoyMove (cmd);
        }
+
+       cl.viewangles[PITCH] = bound (in_pitch_min.value, cl.viewangles[PITCH], in_pitch_max.value);
 }
 
 
@@ -733,7 +679,6 @@ IN_ClearStates
 */
 void IN_ClearStates (void)
 {
-
        if (mouseactive)
        {
                mx_accum = 0;
@@ -753,6 +698,7 @@ void IN_StartupJoystick (void)
        int                     numdevs;
        JOYCAPS         jc;
        MMRESULT        mmr;
+       mmr = 0;
  
        // assume no joystick
        joy_avail = false; 
@@ -859,7 +805,7 @@ void Joy_AdvancedUpdate_f (void)
                pdwRawValue[i] = RawValuePointer(i);
        }
 
-       if( joy_advanced.value == 0.0)
+       if( joy_advanced.integer == 0)
        {
                // default joystick initialization
                // 2 axes only with joystick control
@@ -997,7 +943,7 @@ qboolean IN_ReadJoystick (void)
                // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver
                // rather than having 32768 be the zero point, they have the zero point at 32668
                // go figure -- anyway, now we get the full resolution out of the device
-               if (joy_wwhack1.value != 0.0)
+               if (joy_wwhack1.integer != 0.0)
                {
                        ji.dwUpos += 100;
                }
@@ -1006,10 +952,8 @@ qboolean IN_ReadJoystick (void)
        else
        {
                // read error occurred
-               // turning off the joystick seems too harsh for 1 read error,\
+               // turning off the joystick seems too harsh for 1 read error,
                // but what should be done?
-               // Con_Printf ("IN_ReadJoystick: no response\n");
-               // joy_avail = false;
                return false;
        }
 }
@@ -1024,7 +968,7 @@ void IN_JoyMove (usercmd_t *cmd)
 {
        float   speed, aspeed;
        float   fAxisValue, fTemp;
-       int             i, mouselook = (in_mlook.state & 1) || freelook.value;
+       int             i, mouselook = (in_mlook.state & 1) || freelook.integer;
 
        // complete initialization if first time in
        // this is needed as cvars are not available at initialization time
@@ -1035,11 +979,11 @@ void IN_JoyMove (usercmd_t *cmd)
        }
 
        // verify joystick is available and that the user wants to use it
-       if (!joy_avail || !in_joystick.value)
+       if (!joy_avail || !in_joystick.integer)
        {
                return; 
        }
+
        // collect the joystick data, if possible
        if (IN_ReadJoystick () != true)
        {
@@ -1050,7 +994,8 @@ void IN_JoyMove (usercmd_t *cmd)
                speed = cl_movespeedkey.value;
        else
                speed = 1;
-       aspeed = speed * host_realframetime;
+       // LordHavoc: viewzoom affects sensitivity for sniping
+       aspeed = speed * host_realframetime * cl.viewzoom;
 
        // loop through the axes
        for (i = 0; i < JOY_MAX_AXES; i++)
@@ -1060,7 +1005,7 @@ void IN_JoyMove (usercmd_t *cmd)
                // move centerpoint to zero
                fAxisValue -= 32768.0;
 
-               if (joy_wwhack2.value != 0.0)
+               if (joy_wwhack2.integer != 0.0)
                {
                        if (dwAxisMap[i] == AxisTurn)
                        {
@@ -1082,7 +1027,7 @@ void IN_JoyMove (usercmd_t *cmd)
                switch (dwAxisMap[i])
                {
                case AxisForward:
-                       if ((joy_advanced.value == 0.0) && mouselook)
+                       if ((joy_advanced.integer == 0) && mouselook)
                        {
                                // user wants forward control to become look control
                                if (fabs(fAxisValue) > joy_pitchthreshold.value)
@@ -1127,7 +1072,7 @@ void IN_JoyMove (usercmd_t *cmd)
                        break;
 
                case AxisTurn:
-                       if ((in_strafe.state & 1) || (lookstrafe.value && mouselook))
+                       if ((in_strafe.state & 1) || (lookstrafe.integer && mouselook))
                        {
                                // user wants turn control to become side control
                                if (fabs(fAxisValue) > joy_sidethreshold.value)
@@ -1175,7 +1120,7 @@ void IN_JoyMove (usercmd_t *cmd)
                                        // disable pitch return-to-center unless requested by user
                                        // *** this code can be removed when the lookspring bug is fixed
                                        // *** the bug always has the lookspring feature on
-                                       if(lookspring.value == 0.0)
+                                       if(lookspring.integer == 0)
                                                V_StopPitchDrift();
                                }
                        }
@@ -1185,10 +1130,5 @@ void IN_JoyMove (usercmd_t *cmd)
                        break;
                }
        }
-
-       // bounds check pitch
-       if (cl.viewangles[PITCH] > 80.0)
-               cl.viewangles[PITCH] = 80.0;
-       if (cl.viewangles[PITCH] < -70.0)
-               cl.viewangles[PITCH] = -70.0;
 }
+