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) getkeybind (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_getinputstate, // #345 float(float framenum) getinputstate (EXT_CSQC)
VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
VM_gettime, // #519 float(float timer) gettime = #519; (DP_QC_GETTIME)
VM_keynumtostring, // #520 string keynumtostring(float keynum)
-VM_findkeysforcommand, // #521 string findkeysforcommand(string command)
+VM_findkeysforcommand, // #521 string findkeysforcommand(string command[, float bindmap])
VM_CL_InitParticleSpawner, // #522 void(float max_themes) initparticlespawner (DP_CSQC_SPAWNPARTICLE)
VM_CL_ResetParticle, // #523 void() resetparticle (DP_CSQC_SPAWNPARTICLE)
VM_CL_ParticleTheme, // #524 void(float theme) particletheme (DP_CSQC_SPAWNPARTICLE)
Key_History_Shutdown();
}
-const char *Key_GetBind (int key)
+const char *Key_GetBind (int key, int bindmap)
{
const char *bind;
if (key < 0 || key >= MAX_KEYS)
return NULL;
- bind = keybindings[key_bmap][key];
- if (!bind)
- bind = keybindings[key_bmap2][key];
+ if(bindmap >= 0)
+ {
+ bind = keybindings[bindmap][key];
+ }
+ else
+ {
+ bind = keybindings[key_bmap][key];
+ if (!bind)
+ bind = keybindings[key_bmap2][key];
+ }
return bind;
}
+void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bindmap)
+{
+ int count;
+ int j;
+ char *b;
+
+ for (j = 0;j < numkeys;j++)
+ keys[j] = -1;
+
+ count = 0;
+
+ for (j = 0; j < MAX_KEYS; ++j)
+ {
+ b = Key_GetBind(j, bindmap);
+ if (!b)
+ continue;
+ if (!strcmp (b, command) )
+ {
+ keys[count++] = j;
+ if (count == numkeys)
+ break;
+ }
+ }
+}
+
qboolean CL_VM_InputEvent (qboolean down, int key, int ascii);
/*
void Key_EventQueue_Block(void);
void Key_EventQueue_Unblock(void);
+const char *Key_GetBind (int key, int bindmap);
+void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bindmap);
+
#endif // __KEYS_H
#define NUMKEYS 5
-void M_FindKeysForCommand (const char *command, int *keys)
-{
- int count;
- int j;
- char *b;
-
- for (j = 0;j < NUMKEYS;j++)
- keys[j] = -1;
-
- count = 0;
-
- for (j = 0; j < (int)sizeof (keybindings[0]) / (int)sizeof (keybindings[0][0]); j++)
- {
- b = keybindings[0][j];
- if (!b)
- continue;
- if (!strcmp (b, command) )
- {
- keys[count++] = j;
- if (count == NUMKEYS)
- break;
- }
- }
-}
-
static void M_UnbindCommand (char *command)
{
int j;
else
M_Print(16, y, bindnames[i][1]);
- M_FindKeysForCommand (bindnames[i][0], keys);
+ Key_FindKeysForCommand (bindnames[i][0], keys, NUMKEYS, 0);
// LordHavoc: redesigned to print more than 2 keys, inspired by Tomaz's MiniRacer
if (keys[0] == -1)
break;
case K_ENTER: // go into bind mode
- M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
+ Key_FindKeysForCommand (bindnames[keys_cursor][0], keys, NUMKEYS, 0);
S_LocalSound ("sound/misc/menu2.wav");
if (keys[NUMKEYS - 1] != -1)
M_UnbindCommand (bindnames[keys_cursor][0]);
NULL, // #339
NULL, // #340
NULL, // #341
-VM_getkeybind, // #342 string(float keynum) getkeybind (EXT_CSQC)
+VM_getkeybind, // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
NULL, // #343
NULL, // #344
NULL, // #345
VM_isfunction, // #607 float isfunction(string function_name)
VM_M_getresolution, // #608 vector getresolution(float number, [float forfullscreen])
VM_keynumtostring, // #609 string keynumtostring(float keynum)
-VM_findkeysforcommand, // #610 string findkeysforcommand(string command)
+VM_findkeysforcommand, // #610 string findkeysforcommand(string command[, float bindmap])
VM_M_getserverliststat, // #611 float gethostcachevalue(float type)
VM_M_getserverliststring, // #612 string gethostcachestring(float type, float hostnr)
VM_parseentitydata, // #613 void parseentitydata(entity ent, string data)
the returned string is an altstring
=========
*/
-#define NUMKEYS 5 // TODO: merge the constant in keys.c with this one somewhen
-
+#define FKFC_NUMKEYS 5
void M_FindKeysForCommand(const char *command, int *keys);
void VM_findkeysforcommand(void)
{
const char *cmd;
char ret[VM_STRINGTEMP_LENGTH];
- int keys[NUMKEYS];
+ int keys[FKFC_NUMKEYS];
int i;
+ int bindmap;
- VM_SAFEPARMCOUNT(1, VM_findkeysforcommand);
+ VM_SAFEPARMCOUNTRANGE(1, 2, VM_findkeysforcommand);
cmd = PRVM_G_STRING(OFS_PARM0);
+ if(prog->argc == 2)
+ bindmap = bound(0, PRVM_G_FLOAT(OFS_PARM1), MAX_BINDMAPS-1);
+ else
+ bindmap = -1;
VM_CheckEmptyString(cmd);
- M_FindKeysForCommand(cmd, keys);
+ Key_FindKeysForCommand(cmd, keys, FKFC_NUMKEYS, bindmap);
ret[0] = 0;
- for(i = 0; i < NUMKEYS; i++)
+ for(i = 0; i < FKFC_NUMKEYS; i++)
strlcat(ret, va(" \'%i\'", keys[i]), sizeof(ret));
PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(ret);
string getkeybind(float key)
=========
*/
-const char *Key_GetBind (int key);
void VM_getkeybind (void)
{
- VM_SAFEPARMCOUNT(1, VM_CL_getkeybind);
- PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_GetBind((int)PRVM_G_FLOAT(OFS_PARM0)));
+ int bindmap;
+ VM_SAFEPARMCOUNTRANGE(1, 2, VM_CL_getkeybind);
+ if(prog->argc == 2)
+ bindmap = bound(0, PRVM_G_FLOAT(OFS_PARM1), MAX_BINDMAPS-1);
+ else
+ bindmap = -1;
+
+ PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_GetBind((int)PRVM_G_FLOAT(OFS_PARM0), bindmap));
}
// CL_Video interface functions