Skip to content

Commit

Permalink
split VM_getmousepos into client and menu versions because they need to
Browse files Browse the repository at this point in the history
check different variables to decide whether to return window coordinates
or delta mouse motions


git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8290 d7cf8633-e32d-0410-b094-e92efae38249
  • Loading branch information
havoc committed May 8, 2008
1 parent 058a020 commit e0eea3a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,7 @@ void CL_UpdateScreen(void)
else if (key_dest == key_menu_grabbed)
grabmouse = true;
else if (key_dest == key_menu)
grabmouse = in_client_mouse;
grabmouse = !in_client_mouse;
else if (key_dest == key_game)
grabmouse = vid_mouse.integer && !cls.demoplayback && !cl.csqc_wantsmousemove;
else
Expand Down
13 changes: 12 additions & 1 deletion clvm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,17 @@ static void VM_CL_setcursormode (void)
cl_ignoremousemoves = 2;
}

//#344 vector() getmousepos (EXT_CSQC)
static void VM_CL_getmousepos(void)
{
VM_SAFEPARMCOUNT(0,VM_CL_getmousepos);

if (cl.csqc_wantsmousemove)
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);
}

//#345 float(float framenum) getinputstate (EXT_CSQC)
static void VM_CL_getinputstate (void)
{
Expand Down Expand Up @@ -3247,7 +3258,7 @@ VM_keynumtostring, // #340 string(float keynum) keynumtostring (EXT_CSQC)
VM_stringtokeynum, // #341 float(string keyname) stringtokeynum (EXT_CSQC)
VM_CL_getkeybind, // #342 string(float keynum) getkeybind (EXT_CSQC)
VM_CL_setcursormode, // #343 void(float usecursor) setcursormode (EXT_CSQC)
VM_getmousepos, // #344 vector() getmousepos (EXT_CSQC)
VM_CL_getmousepos, // #344 vector() getmousepos (EXT_CSQC)
VM_CL_getinputstate, // #345 float(float framenum) getinputstate (EXT_CSQC)
VM_CL_setsensitivityscale, // #346 void(float sens) setsensitivityscale (EXT_CSQC)
VM_CL_runplayerphysics, // #347 void() runstandardplayerphysics (EXT_CSQC)
Expand Down
13 changes: 12 additions & 1 deletion mvm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,17 @@ static void VM_M_copyentity (void)
memcpy(out->fields.vp, in->fields.vp, prog->progs->entityfields * 4);
}

//#66 vector() getmousepos (EXT_CSQC)
static void VM_M_getmousepos(void)
{
VM_SAFEPARMCOUNT(0,VM_M_getmousepos);

if (in_client_mouse)
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);
}

prvm_builtin_t vm_m_builtins[] = {
NULL, // #0 NULL function (not callable)
VM_checkextension, // #1
Expand Down Expand Up @@ -852,7 +863,7 @@ VM_clientstate, // #62
VM_clcommand, // #63
VM_changelevel, // #64
VM_localsound, // #65
VM_getmousepos, // #66
VM_M_getmousepos, // #66
VM_gettime, // #67
VM_loadfromdata, // #68
VM_loadfromfile, // #69
Expand Down
18 changes: 0 additions & 18 deletions prvm_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,24 +2298,6 @@ void VM_getostype(void)
#endif
}

/*
=========
VM_getmousepos
vector getmousepos()
=========
*/
void VM_getmousepos(void)
{
VM_SAFEPARMCOUNT(0,VM_getmousepos);

// FIXME: somehow this should involve in_client_mouse if this is menu progs
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);
}

/*
=========
VM_gettime
Expand Down

0 comments on commit e0eea3a

Please sign in to comment.