VM_isfunction, // #607
NULL, // #608
NULL, // #609
-NULL, // #610
+VM_findkeysforcommand, // #610 string findkeysforcommand(string command[, float bindmap])
NULL, // #611
NULL, // #612
VM_parseentitydata, // #613
VM_sprintf, // #627 string sprintf(string format, ...)
VM_getsurfacenumtriangles, // #628 float(entity e, float s) getsurfacenumpoints (DP_QC_GETSURFACETRIANGLE)
VM_getsurfacetriangle, // #629 vector(entity e, float s, float n) getsurfacepoint (DP_QC_GETSURFACETRIANGLE)
-NULL, // #630
+VM_setkeybind, // #630 float(float key, string bind[, float bindmap]) setkeybind
+VM_getbindmaps, // #631 vector(void) getbindmap
+VM_setbindmaps, // #632 float(vector bm) setbindmap
+NULL, // #633
};
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
// r_font_postprocess_shadow_z X : font outline shadow z shift amount, applied during blurring
//description: engine support for truetype/freetype fonts
//so .AFM+.PFB/.OTF/.TTF files could be stuffed as fontmaps in loadfont()
-//(console command version will support them as well)
\ No newline at end of file
+//(console command version will support them as well)
+
+//DP_CSQC_BINDMAPS
+//idea: daemon, motorsep
+//darkplaces implementation: divVerent
+//builtin definitions:
+string(float key, float bindmap) getkeybind_bindmap = #342;
+float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
+vector(void) getbindmaps = #631;
+float(vector bm) setbindmaps = #632;
+string(string command, float bindmap) findkeysforcommand = #610;
+//<already in EXT_CSQC> float(string key) stringtokeynum = #341;
+//<already in EXT_CSQC> string(float keynum) keynumtostring = #340;
+//description: key bind setting/getting including support for switchable
+//bindmaps.
void writetofile(float fhandle, entity ent) = #606;
vector getresolution(float number) = #608;
string keynumtostring(float keynum) = #609;
-string findkeysforcommand(string command) = #610;
float gethostcachevalue(float type) = #611;
string gethostcachestring(float type, float hostnr) = #612;
+//DP_CSQC_BINDMAPS
+//idea: daemon, motorsep
+//darkplaces implementation: divVerent
+//builtin definitions:
+string(float key, float bindmap) getkeybind_bindmap = #342;
+float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
+vector(void) getbindmaps = #631;
+float(vector bm) setbindmaps = #632;
+string(string command, float bindmap) findkeysforcommand = #610;
+float(string key) stringtokeynum = #341;
+//<also allowed builtin number to match EXT_CSQC> string(float keynum) keynumtostring = #340;
+//description: key bind setting/getting including support for switchable
+//bindmaps.
}
-void
+qboolean
Key_SetBinding (int keynum, int bindmap, const char *binding)
{
char *newbinding;
size_t l;
if (keynum == -1 || keynum >= MAX_KEYS)
- return;
+ return false;
+ if ((bindmap < 0) || (bindmap >= MAX_BINDMAPS))
+ return false;
// free old bindings
if (keybindings[bindmap][keynum]) {
keybindings[bindmap][keynum] = NULL;
}
if(!binding[0]) // make "" binds be removed --blub
- return;
+ return true;
// allocate memory for new binding
l = strlen (binding);
newbinding = (char *)Z_Malloc (l + 1);
memcpy (newbinding, binding, l + 1);
newbinding[l] = 0;
keybindings[bindmap][keynum] = newbinding;
+ return true;
+}
+
+void Key_GetBindMap(int *fg, int *bg)
+{
+ if(fg)
+ *fg = key_bmap;
+ if(bg)
+ *bg = key_bmap2;
+}
+
+qboolean Key_SetBindMap(int fg, int bg)
+{
+ if(fg >= MAX_BINDMAPS)
+ return false;
+ if(bg >= MAX_BINDMAPS)
+ return false;
+ if(fg >= 0)
+ key_bmap = fg;
+ if(bg >= 0)
+ key_bmap2 = bg;
+ return true;
}
static void
}
m = strtol(Cmd_Argv (1), &errchar, 0);
- if ((m < 0) || (m >= 8) || (errchar && *errchar)) {
+ if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
return;
}
return;
}
- Key_SetBinding (b, m, "");
+ if(!Key_SetBinding (b, m, ""))
+ Con_Printf("Key_SetBinding failed for unknown reason\n");
}
static void
}
m = strtol(Cmd_Argv (1), &errchar, 0);
- if ((m < 0) || (m >= 8) || (errchar && *errchar)) {
+ if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
return;
}
strlcat (cmd, " ", sizeof (cmd));
}
- Key_SetBinding (b, m, cmd);
+ if(!Key_SetBinding (b, m, cmd))
+ Con_Printf("Key_SetBinding failed for unknown reason\n");
}
static void
}
m1 = strtol(Cmd_Argv (1), &errchar, 0);
- if ((m1 < 0) || (m1 >= 8) || (errchar && *errchar)) {
+ if ((m1 < 0) || (m1 >= MAX_BINDMAPS) || (errchar && *errchar)) {
Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
return;
}
m2 = strtol(Cmd_Argv (2), &errchar, 0);
- if ((m2 < 0) || (m2 >= 8) || (errchar && *errchar)) {
+ if ((m2 < 0) || (m2 >= MAX_BINDMAPS) || (errchar && *errchar)) {
Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(2));
return;
}
return;
}
- Key_SetBinding (b, 0, "");
+ if(!Key_SetBinding (b, 0, ""))
+ Con_Printf("Key_SetBinding failed for unknown reason\n");
}
static void
{
int i, j;
- for (j = 0; j < 8; j++)
+ for (j = 0; j < MAX_BINDMAPS; j++)
for (i = 0; i < (int)(sizeof(keybindings[0])/sizeof(keybindings[0][0])); i++)
if (keybindings[j][i])
Key_SetBinding (i, j, "");
if(Cmd_Argc() >= 2)
{
m = strtol(Cmd_Argv(1), &errchar, 0);
- if ((m < 0) || (m >= 8) || (errchar && *errchar)) {
+ if ((m < 0) || (m >= MAX_BINDMAPS) || (errchar && *errchar)) {
Con_Printf("%s isn't a valid bindmap\n", Cmd_Argv(1));
return;
}
strlcat (cmd, " ", sizeof (cmd));
}
- Key_SetBinding (b, 0, cmd);
+ if(!Key_SetBinding (b, 0, cmd))
+ Con_Printf("Key_SetBinding failed for unknown reason\n");
}
/*
const char *bind;
if (key < 0 || key >= MAX_KEYS)
return NULL;
+ if(bindmap >= MAX_BINDMAPS)
+ return NULL;
if(bindmap >= 0)
{
bind = keybindings[bindmap][key];
for (j = 0;j < numkeys;j++)
keys[j] = -1;
+ if(bindmap >= MAX_BINDMAPS)
+ return;
+
count = 0;
for (j = 0; j < MAX_KEYS; ++j)
void Key_Init_Cvars(void);
void Key_Event(int key, int ascii, qboolean down);
void Key_ClearStates (void);
-void Key_SetBinding (int keynum, int bindmap, const char *binding);
void Key_EventQueue_Block(void);
void Key_EventQueue_Unblock(void);
+qboolean Key_SetBinding (int keynum, int bindmap, const char *binding);
const char *Key_GetBind (int key, int bindmap);
void Key_FindKeysForCommand (const char *command, int *keys, int numkeys, int bindmap);
+qboolean Key_SetBindMap(int fg, int bg);
+void Key_GetBindMap(int *fg, int *bg);
#endif // __KEYS_H
char *vm_m_extensions =
"BX_WAL_SUPPORT "
"DP_CINEMATIC_DPV "
+"DP_CSQC_BINDMAPS "
"DP_GFX_FONTS "
"DP_GFX_FONTS_FREETYPE "
"DP_UTF8 "
NULL, // #337
NULL, // #338
NULL, // #339
-NULL, // #340
-NULL, // #341
+VM_keynumtostring, // #340 string keynumtostring(float keynum)
+VM_stringtokeynum, // #341 float stringtokeynum(string key)
VM_getkeybind, // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
NULL, // #343
NULL, // #344
VM_netaddress_resolve, // #625 string netaddress_resolve(string, float)
VM_M_getgamedirinfo, // #626 string getgamedirinfo(float n, float prop)
VM_sprintf, // #627 string sprintf(string format, ...)
+NULL, // #628
+NULL, // #629
+VM_setkeybind, // #630 float(float key, string bind[, float bindmap]) setkeybind
+VM_getbindmaps, // #631 vector(void) getbindmap
+VM_setbindmaps, // #632 float(vector bm) setbindmap
NULL
};
=========
VM_findkeysforcommand
-string findkeysforcommand(string command)
+string findkeysforcommand(string command, float bindmap)
the returned string is an altstring
=========
=========
VM_getkeybind
-string getkeybind(float key)
+string getkeybind(float key, float bindmap)
=========
*/
void VM_getkeybind (void)
PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(Key_GetBind((int)PRVM_G_FLOAT(OFS_PARM0), bindmap));
}
+/*
+=========
+VM_setkeybind
+
+float setkeybind(float key, string cmd, float bindmap)
+=========
+*/
+void VM_setkeybind (void)
+{
+ int bindmap;
+ VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_setkeybind);
+ if(prog->argc == 3)
+ bindmap = bound(-1, PRVM_G_FLOAT(OFS_PARM2), MAX_BINDMAPS-1);
+ else
+ bindmap = 0; // consistent to "bind"
+
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if(Key_SetBinding((int)PRVM_G_FLOAT(OFS_PARM0), bindmap, PRVM_G_STRING(OFS_PARM1)))
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+
+/*
+=========
+VM_getbindmap
+
+vector getbindmaps()
+=========
+*/
+void VM_getbindmaps (void)
+{
+ int fg, bg;
+ VM_SAFEPARMCOUNT(0, VM_CL_getbindmap);
+ Key_GetBindMap(&fg, &bg);
+ PRVM_G_VECTOR(OFS_RETURN)[0] = fg;
+ PRVM_G_VECTOR(OFS_RETURN)[1] = bg;
+ PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
+}
+
+/*
+=========
+VM_setbindmap
+
+float setbindmaps(vector bindmap)
+=========
+*/
+void VM_setbindmaps (void)
+{
+ VM_SAFEPARMCOUNT(1, VM_CL_setbindmap);
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ if(PRVM_G_VECTOR(OFS_PARM0)[2] == 0)
+ if(Key_SetBindMap((int)PRVM_G_VECTOR(OFS_PARM0)[0], (int)PRVM_G_VECTOR(OFS_PARM0)[1]))
+ PRVM_G_FLOAT(OFS_RETURN) = 1;
+}
+
// CL_Video interface functions
/*
void VM_getkeybind (void);
void VM_findkeysforcommand (void);
void VM_stringtokeynum (void);
+void VM_setkeybind (void);
+void VM_getbindmaps (void);
+void VM_setbindmaps (void);
void VM_cin_open( void );
void VM_cin_close( void );
"DP_CON_SET "
"DP_CON_SETA "
"DP_CON_STARTMAP "
+"DP_CSQC_BINDMAPS "
"DP_CSQC_ENTITYNOCULL "
"DP_CSQC_ENTITYTRANSPARENTSORTING_OFFSET "
"DP_CSQC_MULTIFRAME_INTERPOLATION "