[util] Support commands with a data parameter

Useful for avoiding a pile of wrapper functions that merely pass on
command-specific data to the actual implementation. Used to clean up the
wrappers in nq and qw cl_input.c
This commit is contained in:
Bill Currie 2021-03-20 03:56:16 +09:00
parent dc7cb97481
commit 0ace799b27
4 changed files with 207 additions and 554 deletions

View File

@ -37,6 +37,7 @@
#include "QF/cbuf.h"
typedef void (*xcommand_t) (void);
typedef void (*xdatacmd_t) (void *data);
typedef enum {
src_client, // came in over a net connection as a clc_stringcmd
@ -48,6 +49,8 @@ typedef struct cmd_function_s {
struct cmd_function_s *next;
const char *name;
xcommand_t function;
xdatacmd_t datafunc;
void *data;
const char *description;
} cmd_function_t;
@ -56,7 +59,10 @@ extern cmd_source_t cmd_source;
void Cmd_Init_Hash (void);
void Cmd_Init (void);
int Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *description);
int Cmd_AddCommand (const char *cmd_name, xcommand_t function,
const char *description);
int Cmd_AddDataCommand (const char *cmd_name, xdatacmd_t function,
void *data, const char *description);
int Cmd_RemoveCommand (const char *cmd_name);
qboolean Cmd_Exists (const char *cmd_name);

View File

@ -118,6 +118,8 @@ Cmd_Command (cbuf_args_t *args)
if (cmd) {
if (cmd->function) {
cmd->function ();
} else if (cmd->datafunc) {
cmd->datafunc (cmd->data);
}
return 0;
}
@ -133,10 +135,9 @@ Cmd_Command (cbuf_args_t *args)
return 0;
}
/* Registers a command and handler function */
VISIBLE int
Cmd_AddCommand (const char *cmd_name, xcommand_t function,
const char *description)
static int
add_command (const char *cmd_name, xcommand_t func, xdatacmd_t datafunc,
void *data, const char *description)
{
cmd_function_t *cmd;
cmd_function_t **c;
@ -152,7 +153,9 @@ Cmd_AddCommand (const char *cmd_name, xcommand_t function,
cmd = calloc (1, sizeof (cmd_function_t));
SYS_CHECKMEM (cmd);
cmd->name = cmd_name;
cmd->function = function;
cmd->function = func;
cmd->datafunc = datafunc;
cmd->data = data;
cmd->description = description;
Hash_Add (cmd_hash, cmd);
for (c = &cmd_functions; *c; c = &(*c)->next)
@ -163,6 +166,22 @@ Cmd_AddCommand (const char *cmd_name, xcommand_t function,
return 1;
}
/* Registers a command and handler function */
VISIBLE int
Cmd_AddCommand (const char *cmd_name, xcommand_t function,
const char *description)
{
return add_command (cmd_name, function, 0, 0, description);
}
/* Registers a command and handler function with data */
VISIBLE int
Cmd_AddDataCommand (const char *cmd_name, xdatacmd_t function,
void *data, const char *description)
{
return add_command (cmd_name, 0, function, data, description);
}
/* Unregisters a command */
VISIBLE int
Cmd_RemoveCommand (const char *name)

View File

@ -77,8 +77,9 @@ int in_impulse;
void (*write_angles) (sizebuf_t *sb, const vec3_t angles);
static void
KeyPress (kbutton_t *b)
KeyPress (void *_b)
{
kbutton_t *b = _b;
const char *c;
int k;
@ -107,8 +108,9 @@ KeyPress (kbutton_t *b)
}
static void
KeyRelease (kbutton_t *b)
KeyRelease (void *_b)
{
kbutton_t *b = _b;
const char *c;
int k;
@ -141,25 +143,7 @@ KeyRelease (kbutton_t *b)
}
static void
IN_KLookPress (void)
{
KeyPress (&in_klook);
}
static void
IN_KLookRelease (void)
{
KeyRelease (&in_klook);
}
static void
IN_MLookPress (void)
{
KeyPress (&in_mlook);
}
static void
IN_MLookRelease (void)
IN_MLookRelease (void *data)
{
KeyRelease (&in_mlook);
if (!freelook && lookspring->int_val)
@ -167,187 +151,7 @@ IN_MLookRelease (void)
}
static void
IN_UpPress (void)
{
KeyPress (&in_up);
}
static void
IN_UpRelease (void)
{
KeyRelease (&in_up);
}
static void
IN_DownPress (void)
{
KeyPress (&in_down);
}
static void
IN_DownRelease (void)
{
KeyRelease (&in_down);
}
static void
IN_LeftPress (void)
{
KeyPress (&in_left);
}
static void
IN_LeftRelease (void)
{
KeyRelease (&in_left);
}
static void
IN_RightPress (void)
{
KeyPress (&in_right);
}
static void
IN_RightRelease (void)
{
KeyRelease (&in_right);
}
static void
IN_ForwardPress (void)
{
KeyPress (&in_forward);
}
static void
IN_ForwardRelease (void)
{
KeyRelease (&in_forward);
}
static void
IN_BackPress (void)
{
KeyPress (&in_back);
}
static void
IN_BackRelease (void)
{
KeyRelease (&in_back);
}
static void
IN_LookupPress (void)
{
KeyPress (&in_lookup);
}
static void
IN_LookupRelease (void)
{
KeyRelease (&in_lookup);
}
static void
IN_LookdownPress (void)
{
KeyPress (&in_lookdown);
}
static void
IN_LookdownRelease (void)
{
KeyRelease (&in_lookdown);
}
static void
IN_MoveleftPress (void)
{
KeyPress (&in_moveleft);
}
static void
IN_MoveleftRelease (void)
{
KeyRelease (&in_moveleft);
}
static void
IN_MoverightPress (void)
{
KeyPress (&in_moveright);
}
static void
IN_MoverightRelease (void)
{
KeyRelease (&in_moveright);
}
static void
IN_SpeedPress (void)
{
KeyPress (&in_speed);
}
static void
IN_SpeedRelease (void)
{
KeyRelease (&in_speed);
}
static void
IN_StrafePress (void)
{
KeyPress (&in_strafe);
}
static void
IN_StrafeRelease (void)
{
KeyRelease (&in_strafe);
}
static void
IN_AttackPress (void)
{
KeyPress (&in_attack);
}
static void
IN_AttackRelease (void)
{
KeyRelease (&in_attack);
}
static void
IN_UsePress (void)
{
KeyPress (&in_use);
}
static void
IN_UseRelease (void)
{
KeyRelease (&in_use);
}
static void
IN_JumpPress (void)
{
KeyPress (&in_jump);
}
static void
IN_JumpRelease (void)
{
KeyRelease (&in_jump);
}
static void
IN_Impulse (void)
IN_Impulse (void *data)
{
in_impulse = atoi (Cmd_Argv (1));
}
@ -608,76 +412,86 @@ CL_SendMove (usercmd_t *cmd)
void
CL_Input_Init (void)
{
Cmd_AddCommand ("+moveup", IN_UpPress, "When active the player is "
"swimming up in a liquid");
Cmd_AddCommand ("-moveup", IN_UpRelease, "When active the player is not "
"swimming up in a liquid");
Cmd_AddCommand ("+movedown", IN_DownPress, "When active the player is "
"swimming down in a liquid");
Cmd_AddCommand ("-movedown", IN_DownRelease, "When active the player is "
"not swimming down in a liquid");
Cmd_AddCommand ("+left", IN_LeftPress, "When active the player is turning "
"left");
Cmd_AddCommand ("-left", IN_LeftRelease, "When active the player is not "
"turning left");
Cmd_AddCommand ("+right", IN_RightPress, "When active the player is "
"turning right");
Cmd_AddCommand ("-right", IN_RightRelease, "When active the player is not "
"turning right");
Cmd_AddCommand ("+forward", IN_ForwardPress, "When active the player is "
"moving forward");
Cmd_AddCommand ("-forward", IN_ForwardRelease, "When active the player is "
"not moving forward");
Cmd_AddCommand ("+back", IN_BackPress, "When active the player is moving "
"backwards");
Cmd_AddCommand ("-back", IN_BackRelease, "When active the player is not "
"moving backwards");
Cmd_AddCommand ("+lookup", IN_LookupPress, "When active the player's view "
"is looking up");
Cmd_AddCommand ("-lookup", IN_LookupRelease, "When active the player's "
"view is not looking up");
Cmd_AddCommand ("+lookdown", IN_LookdownPress, "When active the player's "
"view is looking down");
Cmd_AddCommand ("-lookdown", IN_LookdownRelease, "When active the "
"player's view is not looking up");
Cmd_AddCommand ("+strafe", IN_StrafePress, "When active, +left and +right "
"function like +moveleft and +moveright");
Cmd_AddCommand ("-strafe", IN_StrafeRelease, "When active, +left and "
"+right stop functioning like +moveleft and +moveright");
Cmd_AddCommand ("+moveleft", IN_MoveleftPress, "When active the player is "
"strafing left");
Cmd_AddCommand ("-moveleft", IN_MoveleftRelease, "When active the player "
"is not strafing left");
Cmd_AddCommand ("+moveright", IN_MoverightPress, "When active the player "
"is strafing right");
Cmd_AddCommand ("-moveright", IN_MoverightRelease, "When active the "
"player is not strafing right");
Cmd_AddCommand ("+speed", IN_SpeedPress, "When active the player is "
"running");
Cmd_AddCommand ("-speed", IN_SpeedRelease, "When active the player is not "
"running");
Cmd_AddCommand ("+attack", IN_AttackPress, "When active player is "
"firing/using current weapon");
Cmd_AddCommand ("-attack", IN_AttackRelease, "When active player is not "
"firing/using current weapon");
Cmd_AddCommand ("+use", IN_UsePress, "Non-functional. Left over command "
"for opening doors and triggering switches");
Cmd_AddCommand ("-use", IN_UseRelease, "Non-functional. Left over command "
"for opening doors and triggering switches");
Cmd_AddCommand ("+jump", IN_JumpPress, "When active the player is "
"jumping");
Cmd_AddCommand ("-jump", IN_JumpRelease, "When active the player is not "
"jumping");
Cmd_AddCommand ("impulse", IN_Impulse, "Call a game function or QuakeC "
"function.");
Cmd_AddCommand ("+klook", IN_KLookPress, "When active, +forward and +back "
"perform +lookup and +lookdown");
Cmd_AddCommand ("-klook", IN_KLookRelease, "When active, +forward and "
"+back don't perform +lookup and +lookdown");
Cmd_AddCommand ("+mlook", IN_MLookPress, "When active moving the mouse or "
"joystick forwards and backwards performs +lookup and "
"+lookdown");
Cmd_AddCommand ("-mlook", IN_MLookRelease, "When active moving the mouse "
"or joystick forwards and backwards doesn't perform "
"+lookup and +lookdown");
Cmd_AddDataCommand ("+moveup", KeyPress, &in_up,
"When active the player is swimming up in a liquid");
Cmd_AddDataCommand ("-moveup", KeyRelease, &in_up,
"When active the player is not swimming up in a "
"liquid");
Cmd_AddDataCommand ("+movedown", KeyPress, &in_down,
"When active the player is swimming down in a liquid");
Cmd_AddDataCommand ("-movedown", KeyRelease, &in_down,
"When active the player is not swimming down in a "
"liquid");
Cmd_AddDataCommand ("+left", KeyPress, &in_left,
"When active the player is turning left");
Cmd_AddDataCommand ("-left", KeyRelease, &in_left,
"When active the player is not turning left");
Cmd_AddDataCommand ("+right", KeyPress, &in_right,
"When active the player is turning right");
Cmd_AddDataCommand ("-right", KeyRelease, &in_right,
"When active the player is not turning right");
Cmd_AddDataCommand ("+forward", KeyPress, &in_forward,
"When active the player is moving forward");
Cmd_AddDataCommand ("-forward", KeyRelease, &in_forward,
"When active the player is not moving forward");
Cmd_AddDataCommand ("+back", KeyPress, &in_back,
"When active the player is moving backwards");
Cmd_AddDataCommand ("-back", KeyRelease, &in_back,
"When active the player is not moving backwards");
Cmd_AddDataCommand ("+lookup", KeyPress, &in_lookup,
"When active the player's view is looking up");
Cmd_AddDataCommand ("-lookup", KeyRelease, &in_lookup,
"When active the player's view is not looking up");
Cmd_AddDataCommand ("+lookdown", KeyPress, &in_lookdown,
"When active the player's view is looking down");
Cmd_AddDataCommand ("-lookdown", KeyRelease, &in_lookdown,
"When active the player's view is not looking up");
Cmd_AddDataCommand ("+strafe", KeyPress, &in_strafe,
"When active, +left and +right function like "
"+moveleft and +moveright");
Cmd_AddDataCommand ("-strafe", KeyRelease, &in_strafe,
"When active, +left and +right stop functioning like "
"+moveleft and +moveright");
Cmd_AddDataCommand ("+moveleft", KeyPress, &in_moveleft,
"When active the player is strafing left");
Cmd_AddDataCommand ("-moveleft", KeyRelease, &in_moveleft,
"When active the player is not strafing left");
Cmd_AddDataCommand ("+moveright", KeyPress, &in_moveright,
"When active the player is strafing right");
Cmd_AddDataCommand ("-moveright", KeyRelease, &in_moveright,
"When active the player is not strafing right");
Cmd_AddDataCommand ("+speed", KeyPress, &in_speed,
"When active the player is running");
Cmd_AddDataCommand ("-speed", KeyRelease, &in_speed,
"When active the player is not running");
Cmd_AddDataCommand ("+attack", KeyPress, &in_attack,
"When active player is firing/using current weapon");
Cmd_AddDataCommand ("-attack", KeyRelease, &in_attack,
"When active player is not firing/using current "
"weapon");
Cmd_AddDataCommand ("+use", KeyPress, &in_use,
"Non-functional. Left over command for opening doors "
"and triggering switches");
Cmd_AddDataCommand ("-use", KeyRelease, &in_use,
"Non-functional. Left over command for opening doors "
"and triggering switches");
Cmd_AddDataCommand ("+jump", KeyPress, &in_jump,
"When active the player is jumping");
Cmd_AddDataCommand ("-jump", KeyRelease, &in_jump,
"When active the player is not jumping");
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
"Call a game function or QuakeC function.");
Cmd_AddDataCommand ("+klook", KeyPress, &in_klook,
"When active, +forward and +back perform +lookup and "
"+lookdown");
Cmd_AddDataCommand ("-klook", KeyRelease, &in_klook,
"When active, +forward and +back don't perform "
"+lookup and +lookdown");
Cmd_AddDataCommand ("+mlook", KeyPress, &in_mlook,
"When active moving the mouse or joystick forwards "
"and backwards performs +lookup and "
"+lookdown");
Cmd_AddDataCommand ("-mlook", IN_MLookRelease, &in_mlook,
"When active moving the mouse or joystick forwards "
"and backwards doesn't perform +lookup and +lookdown");
}

View File

@ -89,8 +89,9 @@ int in_impulse;
static void
KeyPress (kbutton_t *b)
KeyPress (void *_b)
{
kbutton_t *b = _b;
const char *c;
int k;
@ -119,8 +120,9 @@ KeyPress (kbutton_t *b)
}
static void
KeyRelease (kbutton_t *b)
KeyRelease (void *_b)
{
kbutton_t *b = _b;
const char *c;
int k;
@ -153,25 +155,7 @@ KeyRelease (kbutton_t *b)
}
static void
IN_KLookPress (void)
{
KeyPress (&in_klook);
}
static void
IN_KLookRelease (void)
{
KeyRelease (&in_klook);
}
static void
IN_MLookPress (void)
{
KeyPress (&in_mlook);
}
static void
IN_MLookRelease (void)
IN_MLookRelease (void *data)
{
KeyRelease (&in_mlook);
if (!freelook && lookspring->int_val)
@ -179,187 +163,7 @@ IN_MLookRelease (void)
}
static void
IN_UpPress (void)
{
KeyPress (&in_up);
}
static void
IN_UpRelease (void)
{
KeyRelease (&in_up);
}
static void
IN_DownPress (void)
{
KeyPress (&in_down);
}
static void
IN_DownRelease (void)
{
KeyRelease (&in_down);
}
static void
IN_LeftPress (void)
{
KeyPress (&in_left);
}
static void
IN_LeftRelease (void)
{
KeyRelease (&in_left);
}
static void
IN_RightPress (void)
{
KeyPress (&in_right);
}
static void
IN_RightRelease (void)
{
KeyRelease (&in_right);
}
static void
IN_ForwardPress (void)
{
KeyPress (&in_forward);
}
static void
IN_ForwardRelease (void)
{
KeyRelease (&in_forward);
}
static void
IN_BackPress (void)
{
KeyPress (&in_back);
}
static void
IN_BackRelease (void)
{
KeyRelease (&in_back);
}
static void
IN_LookupPress (void)
{
KeyPress (&in_lookup);
}
static void
IN_LookupRelease (void)
{
KeyRelease (&in_lookup);
}
static void
IN_LookdownPress (void)
{
KeyPress (&in_lookdown);
}
static void
IN_LookdownRelease (void)
{
KeyRelease (&in_lookdown);
}
static void
IN_MoveleftPress (void)
{
KeyPress (&in_moveleft);
}
static void
IN_MoveleftRelease (void)
{
KeyRelease (&in_moveleft);
}
static void
IN_MoverightPress (void)
{
KeyPress (&in_moveright);
}
static void
IN_MoverightRelease (void)
{
KeyRelease (&in_moveright);
}
static void
IN_SpeedPress (void)
{
KeyPress (&in_speed);
}
static void
IN_SpeedRelease (void)
{
KeyRelease (&in_speed);
}
static void
IN_StrafePress (void)
{
KeyPress (&in_strafe);
}
static void
IN_StrafeRelease (void)
{
KeyRelease (&in_strafe);
}
static void
IN_AttackPress (void)
{
KeyPress (&in_attack);
}
static void
IN_AttackRelease (void)
{
KeyRelease (&in_attack);
}
static void
IN_UsePress (void)
{
KeyPress (&in_use);
}
static void
IN_UseRelease (void)
{
KeyRelease (&in_use);
}
static void
IN_JumpPress (void)
{
KeyPress (&in_jump);
}
static void
IN_JumpRelease (void)
{
KeyRelease (&in_jump);
}
static void
IN_Impulse (void)
IN_Impulse (void *data)
{
in_impulse = atoi (Cmd_Argv (1));
if (Cmd_Argc () <= 2)
@ -772,78 +576,88 @@ CL_SendCmd (void)
void
CL_Input_Init (void)
{
Cmd_AddCommand ("+moveup", IN_UpPress, "When active the player is "
"swimming up in a liquid");
Cmd_AddCommand ("-moveup", IN_UpRelease, "When active the player is not "
"swimming up in a liquid");
Cmd_AddCommand ("+movedown", IN_DownPress, "When active the player is "
"swimming down in a liquid");
Cmd_AddCommand ("-movedown", IN_DownRelease, "When active the player is "
"not swimming down in a liquid");
Cmd_AddCommand ("+left", IN_LeftPress, "When active the player is turning "
"left");
Cmd_AddCommand ("-left", IN_LeftRelease, "When active the player is not "
"turning left");
Cmd_AddCommand ("+right", IN_RightPress, "When active the player is "
"turning right");
Cmd_AddCommand ("-right", IN_RightRelease, "When active the player is not "
"turning right");
Cmd_AddCommand ("+forward", IN_ForwardPress, "When active the player is "
"moving forward");
Cmd_AddCommand ("-forward", IN_ForwardRelease, "When active the player is "
"not moving forward");
Cmd_AddCommand ("+back", IN_BackPress, "When active the player is moving "
"backwards");
Cmd_AddCommand ("-back", IN_BackRelease, "When active the player is not "
"moving backwards");
Cmd_AddCommand ("+lookup", IN_LookupPress, "When active the player's view "
"is looking up");
Cmd_AddCommand ("-lookup", IN_LookupRelease, "When active the player's "
"view is not looking up");
Cmd_AddCommand ("+lookdown", IN_LookdownPress, "When active the player's "
"view is looking down");
Cmd_AddCommand ("-lookdown", IN_LookdownRelease, "When active the "
"player's view is not looking up");
Cmd_AddCommand ("+strafe", IN_StrafePress, "When active, +left and +right "
"function like +moveleft and +moveright");
Cmd_AddCommand ("-strafe", IN_StrafeRelease, "When active, +left and "
"+right stop functioning like +moveleft and +moveright");
Cmd_AddCommand ("+moveleft", IN_MoveleftPress, "When active the player is "
"strafing left");
Cmd_AddCommand ("-moveleft", IN_MoveleftRelease, "When active the player "
"is not strafing left");
Cmd_AddCommand ("+moveright", IN_MoverightPress, "When active the player "
"is strafing right");
Cmd_AddCommand ("-moveright", IN_MoverightRelease, "When active the "
"player is not strafing right");
Cmd_AddCommand ("+speed", IN_SpeedPress, "When active the player is "
"running");
Cmd_AddCommand ("-speed", IN_SpeedRelease, "When active the player is not "
"running");
Cmd_AddCommand ("+attack", IN_AttackPress, "When active player is "
"firing/using current weapon");
Cmd_AddCommand ("-attack", IN_AttackRelease, "When active player is not "
"firing/using current weapon");
Cmd_AddCommand ("+use", IN_UsePress, "Non-functional. Left over command "
"for opening doors and triggering switches");
Cmd_AddCommand ("-use", IN_UseRelease, "Non-functional. Left over command "
"for opening doors and triggering switches");
Cmd_AddCommand ("+jump", IN_JumpPress, "When active the player is "
"jumping");
Cmd_AddCommand ("-jump", IN_JumpRelease, "When active the player is not "
"jumping");
Cmd_AddCommand ("impulse", IN_Impulse, "Call a game function or QuakeC "
"function.");
Cmd_AddCommand ("+klook", IN_KLookPress, "When active, +forward and +back "
"perform +lookup and +lookdown");
Cmd_AddCommand ("-klook", IN_KLookRelease, "When active, +forward and "
"+back don't perform +lookup and +lookdown");
Cmd_AddCommand ("+mlook", IN_MLookPress, "When active moving the mouse or "
"joystick forwards and backwards performs +lookup and "
"+lookdown");
Cmd_AddCommand ("-mlook", IN_MLookRelease, "When active moving the mouse "
"or joystick forwards and backwards doesn't perform "
"+lookup and +lookdown");
Cmd_AddDataCommand ("+moveup", KeyPress, &in_up,
"When active the player is swimming up in a liquid");
Cmd_AddDataCommand ("-moveup", KeyRelease, &in_up,
"When active the player is not swimming up in a "
"liquid");
Cmd_AddDataCommand ("+movedown", KeyPress, &in_down,
"When active the player is swimming down in a liquid");
Cmd_AddDataCommand ("-movedown", KeyRelease, &in_down,
"When active the player is not swimming down in a "
"liquid");
Cmd_AddDataCommand ("+left", KeyPress, &in_left,
"When active the player is turning left");
Cmd_AddDataCommand ("-left", KeyRelease, &in_left,
"When active the player is not turning left");
Cmd_AddDataCommand ("+right", KeyPress, &in_right,
"When active the player is turning right");
Cmd_AddDataCommand ("-right", KeyRelease, &in_right,
"When active the player is not turning right");
Cmd_AddDataCommand ("+forward", KeyPress, &in_forward,
"When active the player is moving forward");
Cmd_AddDataCommand ("-forward", KeyRelease, &in_forward,
"When active the player is not moving forward");
Cmd_AddDataCommand ("+back", KeyPress, &in_back,
"When active the player is moving backwards");
Cmd_AddDataCommand ("-back", KeyRelease, &in_back,
"When active the player is not moving backwards");
Cmd_AddDataCommand ("+lookup", KeyPress, &in_lookup,
"When active the player's view is looking up");
Cmd_AddDataCommand ("-lookup", KeyRelease, &in_lookup,
"When active the player's view is not looking up");
Cmd_AddDataCommand ("+lookdown", KeyPress, &in_lookdown,
"When active the player's view is looking down");
Cmd_AddDataCommand ("-lookdown", KeyRelease, &in_lookdown,
"When active the player's view is not looking up");
Cmd_AddDataCommand ("+strafe", KeyPress, &in_strafe,
"When active, +left and +right function like "
"+moveleft and +moveright");
Cmd_AddDataCommand ("-strafe", KeyRelease, &in_strafe,
"When active, +left and +right stop functioning like "
"+moveleft and +moveright");
Cmd_AddDataCommand ("+moveleft", KeyPress, &in_moveleft,
"When active the player is strafing left");
Cmd_AddDataCommand ("-moveleft", KeyRelease, &in_moveleft,
"When active the player is not strafing left");
Cmd_AddDataCommand ("+moveright", KeyPress, &in_moveright,
"When active the player is strafing right");
Cmd_AddDataCommand ("-moveright", KeyRelease, &in_moveright,
"When active the player is not strafing right");
Cmd_AddDataCommand ("+speed", KeyPress, &in_speed,
"When active the player is running");
Cmd_AddDataCommand ("-speed", KeyRelease, &in_speed,
"When active the player is not running");
Cmd_AddDataCommand ("+attack", KeyPress, &in_attack,
"When active player is firing/using current weapon");
Cmd_AddDataCommand ("-attack", KeyRelease, &in_attack,
"When active player is not firing/using current "
"weapon");
Cmd_AddDataCommand ("+use", KeyPress, &in_use,
"Non-functional. Left over command for opening doors "
"and triggering switches");
Cmd_AddDataCommand ("-use", KeyRelease, &in_use,
"Non-functional. Left over command for opening doors "
"and triggering switches");
Cmd_AddDataCommand ("+jump", KeyPress, &in_jump,
"When active the player is jumping");
Cmd_AddDataCommand ("-jump", KeyRelease, &in_jump,
"When active the player is not jumping");
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
"Call a game function or QuakeC function.");
Cmd_AddDataCommand ("+klook", KeyPress, &in_klook,
"When active, +forward and +back perform +lookup and "
"+lookdown");
Cmd_AddDataCommand ("-klook", KeyRelease, &in_klook,
"When active, +forward and +back don't perform "
"+lookup and +lookdown");
Cmd_AddDataCommand ("+mlook", KeyPress, &in_mlook,
"When active moving the mouse or joystick forwards "
"and backwards performs +lookup and "
"+lookdown");
Cmd_AddDataCommand ("-mlook", IN_MLookRelease, &in_mlook,
"When active moving the mouse or joystick forwards "
"and backwards doesn't perform +lookup and +lookdown");
}
void