]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - keys.c
beginnings of qw protocol support
[xonotic/darkplaces.git] / keys.c
diff --git a/keys.c b/keys.c
index 0be40b504eca3a2044d908a25b7f73147b6fbc9e..2d6fd69a25f68f04772767279ef426c250c9bc1f 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -329,7 +329,7 @@ Key_Console (int key, char ascii)
        // Enhanced by [515]
 
        // left arrow will just move left one without erasing, backspace will
-       // actually erase charcter
+       // actually erase character
        if (key == K_LEFTARROW || key == K_KP_LEFTARROW)
        {
                if (key_linepos < 2)
@@ -465,7 +465,7 @@ Key_Console (int key, char ascii)
                if (keydown[K_CTRL])
                        con_backscroll = 0;
                else
-                       key_linepos = strlen(key_lines[edit_line]);
+                       key_linepos = (int)strlen(key_lines[edit_line]);
                return;
        }
 
@@ -811,15 +811,25 @@ Key_Init (void)
 //
 // register our functions
 //
-       Cmd_AddCommand ("in_bind", Key_In_Bind_f);
-       Cmd_AddCommand ("in_unbind", Key_In_Unbind_f);
-       Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f);
+       Cmd_AddCommand ("in_bind", Key_In_Bind_f, "binds a command to the specified key in the selected bindmap");
+       Cmd_AddCommand ("in_unbind", Key_In_Unbind_f, "removes command on the specified key in the selected bindmap");
+       Cmd_AddCommand ("in_bindmap", Key_In_Bindmap_f, "selects active foreground and background (used only if a key is not bound in the foreground) bindmaps for typing");
+
+       Cmd_AddCommand ("bind", Key_Bind_f, "binds a command to the specified key in bindmap 0");
+       Cmd_AddCommand ("unbind", Key_Unbind_f, "removes a command on the specified key in bindmap 0");
+       Cmd_AddCommand ("unbindall", Key_Unbindall_f, "removes all commands from all keys in all bindmaps (leaving only shift-escape and escape)");
+}
 
-       Cmd_AddCommand ("bind", Key_Bind_f);
-       Cmd_AddCommand ("unbind", Key_Unbind_f);
-       Cmd_AddCommand ("unbindall", Key_Unbindall_f);
+const char *Key_GetBind (int key)
+{
+       const char *bind;
+       bind = keybindings[key_bmap][key];
+       if (!bind)
+               bind = keybindings[key_bmap2][key];
+       return bind;
 }
 
+qboolean CL_VM_InputEvent (qboolean pressed, int key);
 
 /*
 ===================
@@ -831,12 +841,26 @@ void
 Key_Event (int key, char ascii, qboolean down)
 {
        const char *bind;
+       qboolean q;
 
        // get key binding
        bind = keybindings[key_bmap][key];
        if (!bind)
                bind = keybindings[key_bmap2][key];
 
+       if(key_dest == key_game)
+       {
+               q = CL_VM_InputEvent(!down, key);
+               if(q)
+               {
+                       if (down)
+                               keydown[key] = min(keydown[key] + 1, 2);
+                       else
+                               keydown[key] = 0;
+                       return;
+               }
+       }
+
        if (!down)
        {
                // clear repeat count now that the key is released