Skip to content

Commit

Permalink
fixed several bugs with mouse grabbing
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8289 d7cf8633-e32d-0410-b094-e92efae38249
  • Loading branch information
havoc committed May 8, 2008
1 parent 3062091 commit 058a020
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion prvm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions vid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vid_agl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion vid_glx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vid_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 1 addition & 3 deletions vid_wgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 058a020

Please sign in to comment.