From 058a0200acb4cc6e3f161da224f24a65f77f6675 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 8 May 2008 17:05:39 +0000 Subject: [PATCH] fixed several bugs with mouse grabbing git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8289 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 5 ++++- prvm_cmds.c | 2 +- vid.h | 3 +++ vid_agl.c | 2 +- vid_glx.c | 2 +- vid_sdl.c | 2 +- vid_wgl.c | 4 +--- 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index b2d2ecc3..044dc6db 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -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; diff --git a/prvm_cmds.c b/prvm_cmds.c index a20c55ae..eb677b61 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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 e76fbae6..9f9e86d7 100644 --- 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 diff --git a/vid_agl.c b/vid_agl.c index df4f817f..1caf2664 100644 --- 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; diff --git a/vid_glx.c b/vid_glx.c index adbe7a59..3593ac34 100644 --- 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) diff --git a/vid_sdl.c b/vid_sdl.c index b38a22a3..31e2f7aa 100644 --- 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) { diff --git a/vid_wgl.c b/vid_wgl.c index 0c551102..7b39e228 100644 --- 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 -- 2.39.2