mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[input] Move button name and description
This puts the name and description into the button itself, making it much easier to look them up.
This commit is contained in:
parent
09e3e62a0a
commit
fae9e043df
4 changed files with 193 additions and 177 deletions
|
@ -91,6 +91,7 @@ typedef struct in_button_s {
|
||||||
int down[2]; ///< button ids holding this button down
|
int down[2]; ///< button ids holding this button down
|
||||||
int state; ///< in_button_state
|
int state; ///< in_button_state
|
||||||
const char *name;
|
const char *name;
|
||||||
|
const char *description;
|
||||||
} in_button_t;
|
} in_button_t;
|
||||||
|
|
||||||
typedef struct in_axisbinding_s {
|
typedef struct in_axisbinding_s {
|
||||||
|
@ -211,8 +212,7 @@ IN_ButtonReleased (in_button_t *button)
|
||||||
|
|
||||||
void IN_ButtonAction (in_button_t *buttin, int id, int pressed);
|
void IN_ButtonAction (in_button_t *buttin, int id, int pressed);
|
||||||
|
|
||||||
int IN_RegisterButton (in_button_t *button, const char *name,
|
int IN_RegisterButton (in_button_t *button);
|
||||||
const char *description);
|
|
||||||
int IN_RegisterAxis (in_axis_t *axis, const char *name,
|
int IN_RegisterAxis (in_axis_t *axis, const char *name,
|
||||||
const char *description);
|
const char *description);
|
||||||
in_button_t *IN_FindButton (const char *name);
|
in_button_t *IN_FindButton (const char *name);
|
||||||
|
|
|
@ -45,8 +45,6 @@
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
typedef struct regbutton_s {
|
typedef struct regbutton_s {
|
||||||
const char *name;
|
|
||||||
const char *description;
|
|
||||||
in_button_t *button;
|
in_button_t *button;
|
||||||
char *press_cmd;
|
char *press_cmd;
|
||||||
char *release_cmd;
|
char *release_cmd;
|
||||||
|
@ -58,7 +56,7 @@ static const char *
|
||||||
button_get_key (const void *b, void *data)
|
button_get_key (const void *b, void *data)
|
||||||
{
|
{
|
||||||
__auto_type regbutton = (const regbutton_t *) b;
|
__auto_type regbutton = (const regbutton_t *) b;
|
||||||
return regbutton->name;
|
return regbutton->button->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -162,16 +160,14 @@ button_release_cmd (void *_b)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE int
|
VISIBLE int
|
||||||
IN_RegisterButton (in_button_t *button, const char *name,
|
IN_RegisterButton (in_button_t *button)
|
||||||
const char *description)
|
|
||||||
{
|
{
|
||||||
|
const char *name = button->name;
|
||||||
if (Hash_Find (button_tab, name)) {
|
if (Hash_Find (button_tab, name)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
size_t size = strlen (name) + 2;
|
size_t size = strlen (name) + 2;
|
||||||
regbutton_t *regbutton = malloc (sizeof (regbutton_t) + 2 * size);
|
regbutton_t *regbutton = malloc (sizeof (regbutton_t) + 2 * size);
|
||||||
regbutton->name = name;
|
|
||||||
regbutton->description = description;
|
|
||||||
regbutton->button = button;
|
regbutton->button = button;
|
||||||
|
|
||||||
regbutton->press_cmd = (char *) (regbutton + 1);
|
regbutton->press_cmd = (char *) (regbutton + 1);
|
||||||
|
|
|
@ -50,88 +50,99 @@
|
||||||
#include "nq/include/client.h"
|
#include "nq/include/client.h"
|
||||||
#include "nq/include/host.h"
|
#include "nq/include/host.h"
|
||||||
|
|
||||||
/*
|
in_button_t in_left = {
|
||||||
KEY BUTTONS
|
.name = "left",
|
||||||
|
.description = "When active the player is turning left"
|
||||||
Continuous button event tracking is complicated by the fact that two
|
};
|
||||||
different input sources (say, mouse button 1 and the control key) can
|
in_button_t in_right = {
|
||||||
both press the same button, but the button should be released only when
|
.name = "right",
|
||||||
both of the pressing key have been released.
|
.description = "When active the player is turning right"
|
||||||
|
};
|
||||||
When a key event issues a button command (+forward, +attack, etc), it
|
in_button_t in_forward = {
|
||||||
appends its key number as a parameter to the command so it can be
|
.name = "forward",
|
||||||
matched up with the release.
|
.description = "When active the player is moving forward"
|
||||||
|
};
|
||||||
state bit 0 is the current state of the key
|
in_button_t in_back = {
|
||||||
state bit 1 is edge triggered on the up to down transition
|
.name = "back",
|
||||||
state bit 2 is edge triggered on the down to up transition
|
.description = "When active the player is moving backwards"
|
||||||
*/
|
};
|
||||||
|
in_button_t in_lookup = {
|
||||||
in_button_t in_left, in_right, in_forward, in_back;
|
.name = "lookup",
|
||||||
in_button_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
.description = "When active the player's view is looking up"
|
||||||
in_button_t in_use, in_jump, in_attack;
|
};
|
||||||
in_button_t in_up, in_down;
|
in_button_t in_lookdown = {
|
||||||
in_button_t in_strafe, in_klook, in_speed, in_mlook;
|
.name = "lookdown",
|
||||||
|
.description = "When active the player's view is looking down"
|
||||||
static struct {
|
};
|
||||||
const char *name;
|
in_button_t in_moveleft = {
|
||||||
in_button_t *button;
|
.name = "moveleft",
|
||||||
const char *description;
|
.description = "When active the player is strafing left"
|
||||||
} cl_in_buttons[] = {
|
};
|
||||||
{ "left", &in_left,
|
in_button_t in_moveright = {
|
||||||
"When active the player is turning left"
|
.name = "moveright",
|
||||||
},
|
.description = "When active the player is strafing right"
|
||||||
{ "right", &in_right,
|
};
|
||||||
"When active the player is turning right"
|
in_button_t in_use = {
|
||||||
},
|
.name = "use",
|
||||||
{ "forward", &in_forward,
|
.description = "Left over command for opening doors and triggering"
|
||||||
"When active the player is moving forward"
|
" switches"
|
||||||
},
|
};
|
||||||
{ "back", &in_back,
|
in_button_t in_jump = {
|
||||||
"When active the player is moving backwards"
|
.name = "jump",
|
||||||
},
|
.description = "When active the player is jumping"
|
||||||
{ "lookup", &in_lookup,
|
};
|
||||||
"When active the player's view is looking up"
|
in_button_t in_attack = {
|
||||||
},
|
.name = "attack",
|
||||||
{ "lookdown", &in_lookdown,
|
.description = "When active player is firing/using current weapon"
|
||||||
"When active the player's view is looking down"
|
};
|
||||||
},
|
in_button_t in_up = {
|
||||||
{ "moveleft", &in_moveleft,
|
.name = "moveup",
|
||||||
"When active the player is strafing left"
|
.description = "When active the player is swimming up in a liquid"
|
||||||
},
|
};
|
||||||
{ "moveright", &in_moveright,
|
in_button_t in_down = {
|
||||||
"When active the player is strafing right"
|
.name = "movedown",
|
||||||
},
|
.description = "When active the player is swimming down in a liquid"
|
||||||
{ "use", &in_use,
|
};
|
||||||
"Left over command for opening doors and triggering switches"
|
in_button_t in_strafe = {
|
||||||
},
|
.name = "strafe",
|
||||||
{ "jump", &in_jump,
|
.description = "When active, +left and +right function like +moveleft and"
|
||||||
"When active the player is jumping"
|
" +moveright"
|
||||||
},
|
};
|
||||||
{ "attack", &in_attack,
|
in_button_t in_klook = {
|
||||||
"When active player is firing/using current weapon"
|
.name = "klook",
|
||||||
},
|
.description = "When active, +forward and +back perform +lookup and"
|
||||||
{ "moveup", &in_up,
|
" +lookdown"
|
||||||
"When active the player is swimming up in a liquid"
|
};
|
||||||
},
|
in_button_t in_speed = {
|
||||||
{ "movedown", &in_down,
|
.name = "speed",
|
||||||
"When active the player is swimming down in a liquid"
|
.description = "When active the player is running"
|
||||||
},
|
};
|
||||||
{ "strafe", &in_strafe,
|
in_button_t in_mlook = {
|
||||||
"When active, +left and +right function like +moveleft and +moveright"
|
.name = "mlook",
|
||||||
},
|
.description = "When active moving the mouse or joystick forwards "
|
||||||
{ "speed", &in_speed,
|
|
||||||
"When active the player is running"
|
|
||||||
},
|
|
||||||
{ "klook", &in_klook,
|
|
||||||
"When active, +forward and +back perform +lookup and +lookdown"
|
|
||||||
},
|
|
||||||
{ "mlook", &in_mlook,
|
|
||||||
"When active moving the mouse or joystick forwards "
|
|
||||||
"and backwards performs +lookup and "
|
"and backwards performs +lookup and "
|
||||||
"+lookdown"
|
"+lookdown"
|
||||||
},
|
};
|
||||||
{ }
|
|
||||||
|
static in_button_t *cl_in_buttons[] = {
|
||||||
|
&in_left,
|
||||||
|
&in_right,
|
||||||
|
&in_forward,
|
||||||
|
&in_back,
|
||||||
|
&in_lookup,
|
||||||
|
&in_lookdown,
|
||||||
|
&in_moveleft,
|
||||||
|
&in_moveright,
|
||||||
|
&in_use,
|
||||||
|
&in_jump,
|
||||||
|
&in_attack,
|
||||||
|
&in_up,
|
||||||
|
&in_down,
|
||||||
|
&in_strafe,
|
||||||
|
&in_klook,
|
||||||
|
&in_speed,
|
||||||
|
&in_mlook,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
int in_impulse;
|
int in_impulse;
|
||||||
|
@ -351,9 +362,8 @@ CL_SendMove (usercmd_t *cmd)
|
||||||
void
|
void
|
||||||
CL_Input_Init (void)
|
CL_Input_Init (void)
|
||||||
{
|
{
|
||||||
for (int i = 0; cl_in_buttons[i].name; i++) {
|
for (int i = 0; cl_in_buttons[i]; i++) {
|
||||||
IN_RegisterButton (cl_in_buttons[i].button, cl_in_buttons[i].name,
|
IN_RegisterButton (cl_in_buttons[i]);
|
||||||
cl_in_buttons[i].description);
|
|
||||||
}
|
}
|
||||||
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
||||||
"Call a game function or QuakeC function.");
|
"Call a game function or QuakeC function.");
|
||||||
|
|
|
@ -63,88 +63,99 @@ cvar_t *cl_nodelta;
|
||||||
cvar_t *cl_maxnetfps;
|
cvar_t *cl_maxnetfps;
|
||||||
cvar_t *cl_spamimpulse;
|
cvar_t *cl_spamimpulse;
|
||||||
|
|
||||||
/*
|
in_button_t in_left = {
|
||||||
KEY BUTTONS
|
.name = "left",
|
||||||
|
.description = "When active the player is turning left"
|
||||||
Continuous button event tracking is complicated by the fact that two
|
};
|
||||||
different input sources (say, mouse button 1 and the control key) can
|
in_button_t in_right = {
|
||||||
both press the same button, but the button should be released only when
|
.name = "right",
|
||||||
both of the pressing key have been released.
|
.description = "When active the player is turning right"
|
||||||
|
};
|
||||||
When a key event issues a button command (+forward, +attack, etc), it
|
in_button_t in_forward = {
|
||||||
appends its key number as a parameter to the command so it can be
|
.name = "forward",
|
||||||
matched up with the release.
|
.description = "When active the player is moving forward"
|
||||||
|
};
|
||||||
state bit 0 is the current state of the key
|
in_button_t in_back = {
|
||||||
state bit 1 is edge triggered on the up to down transition
|
.name = "back",
|
||||||
state bit 2 is edge triggered on the down to up transition
|
.description = "When active the player is moving backwards"
|
||||||
*/
|
};
|
||||||
|
in_button_t in_lookup = {
|
||||||
in_button_t in_left, in_right, in_forward, in_back;
|
.name = "lookup",
|
||||||
in_button_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
.description = "When active the player's view is looking up"
|
||||||
in_button_t in_use, in_jump, in_attack;
|
};
|
||||||
in_button_t in_up, in_down;
|
in_button_t in_lookdown = {
|
||||||
in_button_t in_strafe, in_klook, in_speed, in_mlook;
|
.name = "lookdown",
|
||||||
|
.description = "When active the player's view is looking down"
|
||||||
static struct {
|
};
|
||||||
const char *name;
|
in_button_t in_moveleft = {
|
||||||
in_button_t *button;
|
.name = "moveleft",
|
||||||
const char *description;
|
.description = "When active the player is strafing left"
|
||||||
} cl_in_buttons[] = {
|
};
|
||||||
{ "left", &in_left,
|
in_button_t in_moveright = {
|
||||||
"When active the player is turning left"
|
.name = "moveright",
|
||||||
},
|
.description = "When active the player is strafing right"
|
||||||
{ "right", &in_right,
|
};
|
||||||
"When active the player is turning right"
|
in_button_t in_use = {
|
||||||
},
|
.name = "use",
|
||||||
{ "forward", &in_forward,
|
.description = "Left over command for opening doors and triggering"
|
||||||
"When active the player is moving forward"
|
" switches"
|
||||||
},
|
};
|
||||||
{ "back", &in_back,
|
in_button_t in_jump = {
|
||||||
"When active the player is moving backwards"
|
.name = "jump",
|
||||||
},
|
.description = "When active the player is jumping"
|
||||||
{ "lookup", &in_lookup,
|
};
|
||||||
"When active the player's view is looking up"
|
in_button_t in_attack = {
|
||||||
},
|
.name = "attack",
|
||||||
{ "lookdown", &in_lookdown,
|
.description = "When active player is firing/using current weapon"
|
||||||
"When active the player's view is looking down"
|
};
|
||||||
},
|
in_button_t in_up = {
|
||||||
{ "moveleft", &in_moveleft,
|
.name = "moveup",
|
||||||
"When active the player is strafing left"
|
.description = "When active the player is swimming up in a liquid"
|
||||||
},
|
};
|
||||||
{ "moveright", &in_moveright,
|
in_button_t in_down = {
|
||||||
"When active the player is strafing right"
|
.name = "movedown",
|
||||||
},
|
.description = "When active the player is swimming down in a liquid"
|
||||||
{ "use", &in_use,
|
};
|
||||||
"Left over command for opening doors and triggering switches"
|
in_button_t in_strafe = {
|
||||||
},
|
.name = "strafe",
|
||||||
{ "jump", &in_jump,
|
.description = "When active, +left and +right function like +moveleft and"
|
||||||
"When active the player is jumping"
|
" +moveright"
|
||||||
},
|
};
|
||||||
{ "attack", &in_attack,
|
in_button_t in_klook = {
|
||||||
"When active player is firing/using current weapon"
|
.name = "klook",
|
||||||
},
|
.description = "When active, +forward and +back perform +lookup and"
|
||||||
{ "moveup", &in_up,
|
" +lookdown"
|
||||||
"When active the player is swimming up in a liquid"
|
};
|
||||||
},
|
in_button_t in_speed = {
|
||||||
{ "movedown", &in_down,
|
.name = "speed",
|
||||||
"When active the player is swimming down in a liquid"
|
.description = "When active the player is running"
|
||||||
},
|
};
|
||||||
{ "strafe", &in_strafe,
|
in_button_t in_mlook = {
|
||||||
"When active, +left and +right function like +moveleft and +moveright"
|
.name = "mlook",
|
||||||
},
|
.description = "When active moving the mouse or joystick forwards "
|
||||||
{ "speed", &in_speed,
|
|
||||||
"When active the player is running"
|
|
||||||
},
|
|
||||||
{ "klook", &in_klook,
|
|
||||||
"When active, +forward and +back perform +lookup and +lookdown"
|
|
||||||
},
|
|
||||||
{ "mlook", &in_mlook,
|
|
||||||
"When active moving the mouse or joystick forwards "
|
|
||||||
"and backwards performs +lookup and "
|
"and backwards performs +lookup and "
|
||||||
"+lookdown"
|
"+lookdown"
|
||||||
},
|
};
|
||||||
{ }
|
|
||||||
|
static in_button_t *cl_in_buttons[] = {
|
||||||
|
&in_left,
|
||||||
|
&in_right,
|
||||||
|
&in_forward,
|
||||||
|
&in_back,
|
||||||
|
&in_lookup,
|
||||||
|
&in_lookdown,
|
||||||
|
&in_moveleft,
|
||||||
|
&in_moveright,
|
||||||
|
&in_use,
|
||||||
|
&in_jump,
|
||||||
|
&in_attack,
|
||||||
|
&in_up,
|
||||||
|
&in_down,
|
||||||
|
&in_strafe,
|
||||||
|
&in_klook,
|
||||||
|
&in_speed,
|
||||||
|
&in_mlook,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
int in_impulse;
|
int in_impulse;
|
||||||
|
@ -508,9 +519,8 @@ CL_SendCmd (void)
|
||||||
void
|
void
|
||||||
CL_Input_Init (void)
|
CL_Input_Init (void)
|
||||||
{
|
{
|
||||||
for (int i = 0; cl_in_buttons[i].name; i++) {
|
for (int i = 0; cl_in_buttons[i]; i++) {
|
||||||
IN_RegisterButton (cl_in_buttons[i].button, cl_in_buttons[i].name,
|
IN_RegisterButton (cl_in_buttons[i]);
|
||||||
cl_in_buttons[i].description);
|
|
||||||
}
|
}
|
||||||
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
||||||
"Call a game function or QuakeC function.");
|
"Call a game function or QuakeC function.");
|
||||||
|
|
Loading…
Reference in a new issue