fixed several bugs with mouse grabbing
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 May 2008 17:05:39 +0000 (17:05 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 May 2008 17:05:39 +0000 (17:05 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8289 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
prvm_cmds.c
vid.h
vid_agl.c
vid_glx.c
vid_sdl.c
vid_wgl.c

index b2d2ecc..044dc6d 100644 (file)
@@ -2279,9 +2279,12 @@ void CL_UpdateScreen(void)
        else if (key_dest == key_menu)
                grabmouse = in_client_mouse;
        else if (key_dest == key_game)
-               grabmouse = (vid.fullscreen || vid_mouse.integer) && !cls.demoplayback && !cl.csqc_wantsmousemove;
+               grabmouse = vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove;
        else
                grabmouse = false;
+       vid.mouseaim = grabmouse;
+       if (vid.fullscreen)
+               grabmouse = true;
        if (!vid_activewindow)
                grabmouse = false;
 
index a20c55a..eb677b6 100644 (file)
@@ -2310,7 +2310,7 @@ void VM_getmousepos(void)
        VM_SAFEPARMCOUNT(0,VM_getmousepos);
 
        // FIXME: somehow this should involve in_client_mouse if this is menu progs
-       if (cl.csqc_wantsmousemove)
+       if (!vid.mouseaim)
                VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
        else
                VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
diff --git a/vid.h b/vid.h
index e76fbae..9f9e86d 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -37,6 +37,9 @@ typedef struct viddef_s
        qboolean userefreshrate;
        int stereobuffer;
        int samples;
+
+       // these are used for state tracking
+       qboolean mouseaim;
 } viddef_t;
 
 // global video state
index df4f817..1caf266 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -968,7 +968,7 @@ void Sys_SendKeyEvents(void)
                                                GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(deltaPos), NULL, &deltaPos);
                                                GetEventParameter(theEvent, kEventParamWindowMouseLocation, typeHIPoint, NULL, sizeof(windowPos), NULL, &windowPos);
 
-                                               if (vid_usingmouse)
+                                               if (vid.mouseaim)
                                                {
                                                        in_mouse_x += deltaPos.x;
                                                        in_mouse_y += deltaPos.y;
index adbe7a5..3593ac3 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -365,7 +365,7 @@ static void HandleEvents(void)
 
                case MotionNotify:
                        // mouse moved
-                       if (vid_usingmouse)
+                       if (vid.mouseaim)
                        {
 #if !defined(__APPLE__) && !defined(SUNOS)
                                if (vid_dgamouse.integer == 1 && vid_x11_dgasupported)
index b38a22a..31e2f7a 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -276,7 +276,7 @@ void IN_Move( void )
        static int old_x = 0, old_y = 0;
        static int stuck = 0;
        int x, y;
-       if( vid_usingmouse )
+       if (vid.mouseaim)
        {
                if(vid_stick_mouse.integer)
                {
index 0c55110..7b39e22 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -243,8 +243,6 @@ static void IN_StartupMouse (void);
 
 void VID_Finish (void)
 {
-       qboolean vid_usemouse;
-
        vid_usevsync = vid_vsync.integer && !cls.timedemo && gl_videosyncavailable;
        if (vid_usingvsync != vid_usevsync && gl_videosyncavailable)
        {
@@ -1477,7 +1475,7 @@ static void IN_MouseMove (void)
        in_windowmouse_x = current_pos.x - window_x;
        in_windowmouse_y = current_pos.y - window_y;
 
-       if (!vid_usingmouse)
+       if (!vid.mouseaim)
                return;
 
 #ifdef SUPPORTDIRECTX