]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - in_win.c
corrected a typo in a comment referring to the e4 hall in start as e1m4
[xonotic/darkplaces.git] / in_win.c
index fb055bbb416e991c11aa2ff4d92029188d1cddb3..d814845f45fa596aede653baa711fc8f100dd977 100644 (file)
--- a/in_win.c
+++ b/in_win.c
@@ -20,11 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // in_win.c -- windows 95 mouse and joystick code
 // 02/21/97 JCB Added extended DirectInput code to support external controllers.
 
-#include <dinput.h>
 #include "quakedef.h"
 #include "winquake.h"
 //#include "dosisms.h"
 
+#include <dinput.h>
+
 #define DINPUT_BUFFERSIZE           16
 #define iDirectInputCreate(a,b,c,d)    pDirectInputCreate(a,b,c,d)
 
@@ -32,7 +33,7 @@ HRESULT (WINAPI *pDirectInputCreate)(HINSTANCE hinst, DWORD dwVersion,
        LPDIRECTINPUT * lplpDirectInput, LPUNKNOWN punkOuter);
 
 // mouse variables
-cvar_t m_filter = {"m_filter","0"};
+cvar_t m_filter = {CVAR_SAVE, "m_filter","0"};
 
 int                    mouse_buttons;
 int                    mouse_oldbuttonstate;
@@ -82,25 +83,25 @@ PDWORD      pdwRawValue[JOY_MAX_AXES];
 // each time.  this avoids any problems with getting back to a default usage
 // or when changing from one controller to another.  this way at least something
 // works.
-cvar_t in_joystick = {"joystick","0", true};
-cvar_t joy_name = {"joyname", "joystick"};
-cvar_t joy_advanced = {"joyadvanced", "0"};
-cvar_t joy_advaxisx = {"joyadvaxisx", "0"};
-cvar_t joy_advaxisy = {"joyadvaxisy", "0"};
-cvar_t joy_advaxisz = {"joyadvaxisz", "0"};
-cvar_t joy_advaxisr = {"joyadvaxisr", "0"};
-cvar_t joy_advaxisu = {"joyadvaxisu", "0"};
-cvar_t joy_advaxisv = {"joyadvaxisv", "0"};
-cvar_t joy_forwardthreshold = {"joyforwardthreshold", "0.15"};
-cvar_t joy_sidethreshold = {"joysidethreshold", "0.15"};
-cvar_t joy_pitchthreshold = {"joypitchthreshold", "0.15"};
-cvar_t joy_yawthreshold = {"joyyawthreshold", "0.15"};
-cvar_t joy_forwardsensitivity = {"joyforwardsensitivity", "-1.0"};
-cvar_t joy_sidesensitivity = {"joysidesensitivity", "-1.0"};
-cvar_t joy_pitchsensitivity = {"joypitchsensitivity", "1.0"};
-cvar_t joy_yawsensitivity = {"joyyawsensitivity", "-1.0"};
-cvar_t joy_wwhack1 = {"joywwhack1", "0.0"};
-cvar_t joy_wwhack2 = {"joywwhack2", "0.0"};
+cvar_t in_joystick = {CVAR_SAVE, "joystick","0"};
+cvar_t joy_name = {0, "joyname", "joystick"};
+cvar_t joy_advanced = {0, "joyadvanced", "0"};
+cvar_t joy_advaxisx = {0, "joyadvaxisx", "0"};
+cvar_t joy_advaxisy = {0, "joyadvaxisy", "0"};
+cvar_t joy_advaxisz = {0, "joyadvaxisz", "0"};
+cvar_t joy_advaxisr = {0, "joyadvaxisr", "0"};
+cvar_t joy_advaxisu = {0, "joyadvaxisu", "0"};
+cvar_t joy_advaxisv = {0, "joyadvaxisv", "0"};
+cvar_t joy_forwardthreshold = {0, "joyforwardthreshold", "0.15"};
+cvar_t joy_sidethreshold = {0, "joysidethreshold", "0.15"};
+cvar_t joy_pitchthreshold = {0, "joypitchthreshold", "0.15"};
+cvar_t joy_yawthreshold = {0, "joyyawthreshold", "0.15"};
+cvar_t joy_forwardsensitivity = {0, "joyforwardsensitivity", "-1.0"};
+cvar_t joy_sidesensitivity = {0, "joysidesensitivity", "-1.0"};
+cvar_t joy_pitchsensitivity = {0, "joypitchsensitivity", "1.0"};
+cvar_t joy_yawsensitivity = {0, "joyyawsensitivity", "-1.0"};
+cvar_t joy_wwhack1 = {0, "joywwhack1", "0.0"};
+cvar_t joy_wwhack2 = {0, "joywwhack2", "0.0"};
 
 qboolean       joy_avail, joy_advancedinit, joy_haspov;
 DWORD          joy_oldbuttonstate, joy_oldpovstate;
@@ -155,17 +156,6 @@ void Joy_AdvancedUpdate_f (void);
 void IN_JoyMove (usercmd_t *cmd);
 
 
-/*
-===========
-Force_CenterView_f
-===========
-*/
-void Force_CenterView_f (void)
-{
-       cl.viewangles[PITCH] = 0;
-}
-
-
 /*
 ===========
 IN_UpdateClipCursor
@@ -188,7 +178,6 @@ IN_ShowMouse
 */
 void IN_ShowMouse (void)
 {
-
        if (!mouseshowtoggle)
        {
                ShowCursor (true);
@@ -204,7 +193,6 @@ IN_HideMouse
 */
 void IN_HideMouse (void)
 {
-
        if (mouseshowtoggle)
        {
                ShowCursor (false);
@@ -248,6 +236,7 @@ void IN_ActivateMouse (void)
                        SetCursorPos (window_center_x, window_center_y);
                        SetCapture (mainwindow);
                        ClipCursor (&window_rect);
+                       
                }
 
                mouseactive = true;
@@ -255,18 +244,6 @@ void IN_ActivateMouse (void)
 }
 
 
-/*
-===========
-IN_SetQuakeMouseState
-===========
-*/
-void IN_SetQuakeMouseState (void)
-{
-       if (mouseactivatetoggle)
-               IN_ActivateMouse ();
-}
-
-
 /*
 ===========
 IN_DeactivateMouse
@@ -304,26 +281,6 @@ void IN_DeactivateMouse (void)
 }
 
 
-/*
-===========
-IN_RestoreOriginalMouseState
-===========
-*/
-void IN_RestoreOriginalMouseState (void)
-{
-       if (mouseactivatetoggle)
-       {
-               IN_DeactivateMouse ();
-               mouseactivatetoggle = true;
-       }
-
-// try to redraw the cursor so it gets reinitialized, because sometimes it
-// has garbage after the mode switch
-       ShowCursor (true);
-       ShowCursor (false);
-}
-
-
 /*
 ===========
 IN_InitDInput
@@ -505,7 +462,6 @@ void IN_Init (void)
        Cvar_RegisterVariable (&joy_wwhack1);
        Cvar_RegisterVariable (&joy_wwhack2);
 
-       Cmd_AddCommand ("force_centerview", Force_CenterView_f);
        Cmd_AddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f);
 
        uiWheelMessage = RegisterWindowMessage ( "MSWHEEL_ROLLMSG" );
@@ -521,7 +477,7 @@ IN_Shutdown
 */
 void IN_Shutdown (void)
 {
-
+//     usingmouse = false;
        IN_DeactivateMouse ();
        IN_ShowMouse ();
 
@@ -578,14 +534,17 @@ IN_MouseMove
 */
 void IN_MouseMove (usercmd_t *cmd)
 {
-       int                                     mx, my;
-       int                                     i;
+       int                                     i, mx, my, mouselook = (in_mlook.state & 1) || freelook.value;
        DIDEVICEOBJECTDATA      od;
        DWORD                           dwElements;
        HRESULT                         hr;
 
        if (!mouseactive)
+       {
+               GetCursorPos (&current_pos);
+               ui_mouseupdate(current_pos.x - window_x, current_pos.y - window_y);
                return;
+       }
 
        if (dinput)
        {
@@ -637,7 +596,7 @@ void IN_MouseMove (usercmd_t *cmd)
                                        else
                                                mstate_di &= ~(1<<1);
                                        break;
-                                       
+
                                case DIMOFS_BUTTON2:
                                        if (od.dwData & 0x80)
                                                mstate_di |= (1<<2);
@@ -661,8 +620,8 @@ void IN_MouseMove (usercmd_t *cmd)
                        {
                                Key_Event (K_MOUSE1 + i, false);
                        }
-               }       
-                       
+               }
+
                mouse_oldbuttonstate = mstate_di;
        }
        else
@@ -695,16 +654,16 @@ void IN_MouseMove (usercmd_t *cmd)
        mouse_y *= sensitivity.value;
 
 // add mouse X/Y movement to cmd
-       if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
+       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 (in_mlook.state & 1)
+       if (mouselook)
                V_StopPitchDrift ();
        
        // LordHavoc: changed limits on pitch from -70 to 80, to -90 to 90
-       if ( (in_mlook.state & 1) && !(in_strafe.state & 1))
+       if (mouselook && !(in_strafe.state & 1))
        {
                cl.viewangles[PITCH] += m_pitch.value * mouse_y;
                if (cl.viewangles[PITCH] > 90)
@@ -1065,7 +1024,7 @@ void IN_JoyMove (usercmd_t *cmd)
 {
        float   speed, aspeed;
        float   fAxisValue, fTemp;
-       int             i;
+       int             i, mouselook = (in_mlook.state & 1) || freelook.value;
 
        // complete initialization if first time in
        // this is needed as cvars are not available at initialization time
@@ -1123,7 +1082,7 @@ void IN_JoyMove (usercmd_t *cmd)
                switch (dwAxisMap[i])
                {
                case AxisForward:
-                       if ((joy_advanced.value == 0.0) && (in_mlook.state & 1))
+                       if ((joy_advanced.value == 0.0) && mouselook)
                        {
                                // user wants forward control to become look control
                                if (fabs(fAxisValue) > joy_pitchthreshold.value)
@@ -1168,7 +1127,7 @@ void IN_JoyMove (usercmd_t *cmd)
                        break;
 
                case AxisTurn:
-                       if ((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
+                       if ((in_strafe.state & 1) || (lookstrafe.value && mouselook))
                        {
                                // user wants turn control to become side control
                                if (fabs(fAxisValue) > joy_sidethreshold.value)
@@ -1195,7 +1154,7 @@ void IN_JoyMove (usercmd_t *cmd)
                        break;
 
                case AxisLook:
-                       if (in_mlook.state & 1)
+                       if (mouselook)
                        {
                                if (fabs(fAxisValue) > joy_pitchthreshold.value)
                                {