]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
implemented CSQC_InputEvent type 2 and type 3 mouse move events
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 16 Aug 2011 11:39:27 +0000 (11:39 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 16 Aug 2011 11:39:27 +0000 (11:39 +0000)
added cl_csqc_generatemousemoveevents cvar to allow this to be disabled
based on gamemode (currently disabled in GAME_STEELSTORM due to csqc bugs)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11277 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
clvm_cmds.c
cmd.c
csprogs.c
keys.c

index 8fe0d4cbeffc5dd513a1ae86c855836b135339f1..d449bdf6d062a27eed7a281ed9bf5d339f8ab77c 100644 (file)
@@ -457,6 +457,8 @@ cvar_t cl_netimmediatebuttons = {CVAR_SAVE, "cl_netimmediatebuttons", "1", "send
 
 cvar_t cl_nodelta = {0, "cl_nodelta", "0", "disables delta compression of non-player entities in QW network protocol"};
 
+cvar_t cl_csqc_generatemousemoveevents = {0, "cl_csqc_generatemousemoveevents", "1", "enables calls to CSQC_InputEvent with type 2, for compliance with EXT_CSQC spec"};
+
 extern cvar_t v_flipped;
 
 /*
@@ -516,6 +518,7 @@ CL_Input
 Send the intended movement message to the server
 ================
 */
+extern qboolean CL_VM_InputEvent (int eventtype, int x, int y);
 void CL_Input (void)
 {
        float mx, my;
@@ -562,6 +565,27 @@ void CL_Input (void)
        // allow mice or other external controllers to add to the move
        IN_Move ();
 
+       // send mouse move to csqc
+       if (cl.csqc_loaded && cl_csqc_generatemousemoveevents.integer)
+       {
+               if (cl.csqc_wantsmousemove)
+               {
+                       // event type 3 is a DP_CSQC thing
+                       static int oldwindowmouse[2];
+                       if (oldwindowmouse[0] != in_windowmouse_x || oldwindowmouse[1] != in_windowmouse_y)
+                       {
+                               CL_VM_InputEvent(3, in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height);
+                               oldwindowmouse[0] = in_windowmouse_x;
+                               oldwindowmouse[1] = in_windowmouse_y;
+                       }
+               }
+               else
+               {
+                       if (in_mouse_x || in_mouse_y)
+                               CL_VM_InputEvent(2, in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height);
+               }
+       }
+
        // apply m_accelerate if it is on
        if(m_accelerate.value > 1)
        {
@@ -2234,5 +2258,7 @@ void CL_InitInput (void)
        Cvar_RegisterVariable(&cl_netimmediatebuttons);
 
        Cvar_RegisterVariable(&cl_nodelta);
+
+       Cvar_RegisterVariable(&cl_csqc_generatemousemoveevents);
 }
 
index 0b61025e16b405dd46b1ac08c544db295f3e1792..9856f21cce4a161addfc5c1b4d1c4a4cde7101d6 100644 (file)
@@ -1318,7 +1318,7 @@ static void VM_CL_setpause(void)
                cl.csqc_paused = false;
 }
 
-//#343 void(float usecursor) setcursormode (EXT_CSQC)
+//#343 void(float usecursor) setcursormode (DP_CSQC)
 static void VM_CL_setcursormode (void)
 {
        VM_SAFEPARMCOUNT(1, VM_CL_setcursormode);
@@ -1326,7 +1326,7 @@ static void VM_CL_setcursormode (void)
        cl_ignoremousemoves = 2;
 }
 
-//#344 vector() getmousepos (EXT_CSQC)
+//#344 vector() getmousepos (DP_CSQC)
 static void VM_CL_getmousepos(void)
 {
        VM_SAFEPARMCOUNT(0,VM_CL_getmousepos);
@@ -4409,8 +4409,8 @@ VM_print,                                         // #339 void(string s, ...) print (EXT_CSQC, DP_SV_PRINT)
 VM_keynumtostring,                             // #340 string(float keynum) keynumtostring (EXT_CSQC)
 VM_stringtokeynum,                             // #341 float(string keyname) stringtokeynum (EXT_CSQC)
 VM_getkeybind,                                 // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
-VM_CL_setcursormode,                   // #343 void(float usecursor) setcursormode (EXT_CSQC)
-VM_CL_getmousepos,                             // #344 vector() getmousepos (EXT_CSQC)
+VM_CL_setcursormode,                   // #343 void(float usecursor) setcursormode (DP_CSQC)
+VM_CL_getmousepos,                             // #344 vector() getmousepos (DP_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)
diff --git a/cmd.c b/cmd.c
index bbaca649369e1e5be7b88e3251d019894db88ce0..e894a8c2a0da6f5212970af10baaa02d283cf6c3 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -453,6 +453,7 @@ void Cmd_StuffCmds_f (void)
 static void Cmd_Exec(const char *filename)
 {
        char *f;
+       qboolean isdefaultcfg = strlen(filename) >= 11 && !strcmp(filename + strlen(filename) - 11, "default.cfg");
 
        if (!strcmp(filename, "config.cfg"))
        {
@@ -472,7 +473,7 @@ static void Cmd_Exec(const char *filename)
        // if executing default.cfg for the first time, lock the cvar defaults
        // it may seem backwards to insert this text BEFORE the default.cfg
        // but Cbuf_InsertText inserts before, so this actually ends up after it.
-       if (strlen(filename) >= 11 && !strcmp(filename + strlen(filename) - 11, "default.cfg"))
+       if (isdefaultcfg)
                Cbuf_InsertText("\ncvar_lockdefaults\n");
 
        // insert newline after the text to make sure the last line is terminated (some text editors omit the trailing newline)
@@ -481,23 +482,29 @@ static void Cmd_Exec(const char *filename)
        Cbuf_InsertText (f);
        Mem_Free(f);
 
-       // special defaults for specific games go here, these execute before default.cfg
-       // Nehahra pushable crates malfunction in some levels if this is on
-       // Nehahra NPC AI is confused by blowupfallenzombies
-       if (gamemode == GAME_NEHAHRA)
-               Cbuf_InsertText("\nsv_gameplayfix_upwardvelocityclearsongroundflag 0\nsv_gameplayfix_blowupfallenzombies 0\n\n");
-       // hipnotic mission pack has issues in their 'friendly monster' ai, which seem to attempt to attack themselves for some reason when findradius() returns non-solid entities.
-       // hipnotic mission pack has issues with bobbing water entities 'jittering' between different heights on alternate frames at the default 0.0138889 ticrate, 0.02 avoids this issue
-       // hipnotic mission pack has issues in their proximity mine sticking code, which causes them to bounce off.
-       if (gamemode == GAME_HIPNOTIC)
-               Cbuf_InsertText("\nsv_gameplayfix_blowupfallenzombies 0\nsys_ticrate 0.02\nsv_gameplayfix_slidemoveprojectiles 0\n\n");
-       // rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area
-       if (gamemode == GAME_ROGUE)
-               Cbuf_InsertText("\nsv_gameplayfix_findradiusdistancetobox 0\n\n");
-       if (gamemode == GAME_NEXUIZ)
-               Cbuf_InsertText("\nsv_gameplayfix_q2airaccelerate 1\nsv_gameplayfix_stepmultipletimes 1\n\n");
-       if (gamemode == GAME_TENEBRAE)
-               Cbuf_InsertText("\nr_shadow_gloss 2\nr_shadow_bumpscale_basetexture 4\n\n");
+       if (isdefaultcfg)
+       {
+               // special defaults for specific games go here, these execute before default.cfg
+               // Nehahra pushable crates malfunction in some levels if this is on
+               // Nehahra NPC AI is confused by blowupfallenzombies
+               if (gamemode == GAME_NEHAHRA)
+                       Cbuf_InsertText("\nsv_gameplayfix_upwardvelocityclearsongroundflag 0\nsv_gameplayfix_blowupfallenzombies 0\n\n");
+               // hipnotic mission pack has issues in their 'friendly monster' ai, which seem to attempt to attack themselves for some reason when findradius() returns non-solid entities.
+               // hipnotic mission pack has issues with bobbing water entities 'jittering' between different heights on alternate frames at the default 0.0138889 ticrate, 0.02 avoids this issue
+               // hipnotic mission pack has issues in their proximity mine sticking code, which causes them to bounce off.
+               if (gamemode == GAME_HIPNOTIC)
+                       Cbuf_InsertText("\nsv_gameplayfix_blowupfallenzombies 0\nsys_ticrate 0.02\nsv_gameplayfix_slidemoveprojectiles 0\n\n");
+               // rogue mission pack has a guardian boss that does not wake up if findradius returns one of the entities around its spawn area
+               if (gamemode == GAME_ROGUE)
+                       Cbuf_InsertText("\nsv_gameplayfix_findradiusdistancetobox 0\n\n");
+               if (gamemode == GAME_NEXUIZ)
+                       Cbuf_InsertText("\nsv_gameplayfix_q2airaccelerate 1\nsv_gameplayfix_stepmultipletimes 1\n\n");
+               if (gamemode == GAME_TENEBRAE)
+                       Cbuf_InsertText("\nr_shadow_gloss 2\nr_shadow_bumpscale_basetexture 4\n\n");
+               // Steel Storm: Burning Retribution csqc misinterprets CSQC_InputEvent if type is a value other than 0 or 1
+               if (gamemode == GAME_STEELSTORM)
+                       Cbuf_InsertText("\ncl_csqc_generatemousemoveevents 0\n\n");
+       }
 }
 
 /*
index 55bf6bf1716a7f8a6d0a552f625bbbde8699e084..8ebaa7f22b1e3fbe6aff4c9cdb22b63f70c99fab 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -427,7 +427,11 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        return true;
 }
 
-qboolean CL_VM_InputEvent (qboolean down, int key, int ascii)
+// 0 = keydown, key, character (EXT_CSQC)
+// 1 = keyup, key, character (EXT_CSQC)
+// 2 = mousemove relative, x, y (EXT_CSQC)
+// 3 = mousemove absolute, x, y (DP_CSQC)
+qboolean CL_VM_InputEvent (int eventtype, int x, int y)
 {
        qboolean r;
 
@@ -441,9 +445,9 @@ qboolean CL_VM_InputEvent (qboolean down, int key, int ascii)
                {
                        PRVM_clientglobalfloat(time) = cl.time;
                        PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
-                       PRVM_G_FLOAT(OFS_PARM0) = !down; // 0 is down, 1 is up
-                       PRVM_G_FLOAT(OFS_PARM1) = key;
-                       PRVM_G_FLOAT(OFS_PARM2) = ascii;
+                       PRVM_G_FLOAT(OFS_PARM0) = eventtype;
+                       PRVM_G_FLOAT(OFS_PARM1) = x; // key or x
+                       PRVM_G_FLOAT(OFS_PARM2) = y; // ascii or y
                        PRVM_ExecuteProgram(PRVM_clientfunction(CSQC_InputEvent), "QC function CSQC_InputEvent is missing");
                        r = CSQC_RETURNVAL != 0;
                }
diff --git a/keys.c b/keys.c
index 817ce92da6a38ae589788aa4f374b33ba420db61..aa84c237cb6ef7c0474e65b7d5d5731035dbc899 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -1686,7 +1686,7 @@ void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bi
        }
 }
 
-qboolean CL_VM_InputEvent (qboolean down, int key, int ascii);
+extern qboolean CL_VM_InputEvent (int eventtype, int x, int y);
 
 /*
 ===================
@@ -1852,7 +1852,7 @@ Key_Event (int key, int ascii, qboolean down)
 
                        case key_game:
                                // csqc has priority over toggle menu if it wants to (e.g. handling escape for UI stuff in-game.. :sick:)
-                               q = CL_VM_InputEvent(down, key, ascii);
+                               q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
                                if (!q && down)
                                        MR_ToggleMenu(1);
                                break;
@@ -1936,7 +1936,7 @@ Key_Event (int key, int ascii, qboolean down)
                        MR_KeyEvent (key, ascii, down);
                        break;
                case key_game:
-                       q = CL_VM_InputEvent(down, key, ascii);
+                       q = CL_VM_InputEvent(down ? 0 : 1, key, ascii);
                        // ignore key repeats on binds and only send the bind if the event hasnt been already processed by csqc
                        if (!q && bind)
                        {