2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_input.c
|
|
|
|
|
2001-07-15 00:03:11 +00:00
|
|
|
builds an intended movement command to send to the server
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2021-11-18 06:27:44 +00:00
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-04-11 07:57:08 +00:00
|
|
|
#include "QF/input.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/keys.h"
|
|
|
|
#include "QF/msg.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-11-18 06:27:44 +00:00
|
|
|
#include "QF/input/event.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
2021-11-25 03:46:54 +00:00
|
|
|
#include "client/input.h"
|
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/chase.h"
|
|
|
|
#include "nq/include/client.h"
|
|
|
|
#include "nq/include/host.h"
|
2001-04-15 21:11:41 +00:00
|
|
|
|
2021-11-18 06:27:44 +00:00
|
|
|
int cl_game_context;
|
|
|
|
int cl_demo_context;
|
|
|
|
static int cl_event_id;
|
|
|
|
|
|
|
|
in_axis_t viewdelta_position_forward = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.forward",
|
|
|
|
.description = "Move forward (negative) or backward (positive)",
|
|
|
|
};
|
|
|
|
in_axis_t viewdelta_position_side = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.side",
|
|
|
|
.description = "Move right (positive) or left (negative)",
|
|
|
|
};
|
|
|
|
in_axis_t viewdelta_position_up = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.up",
|
|
|
|
.description = "Move up (positive) or down (negative)",
|
|
|
|
};
|
|
|
|
|
|
|
|
in_axis_t viewdelta_angles_pitch = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.pitch",
|
|
|
|
.description = "Pitch axis",
|
|
|
|
};
|
|
|
|
in_axis_t viewdelta_angles_yaw = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.yaw",
|
|
|
|
.description = "Yaw axis",
|
|
|
|
};
|
|
|
|
in_axis_t viewdelta_angles_roll = {
|
2021-11-23 13:04:56 +00:00
|
|
|
.mode = ina_set,
|
2021-11-18 06:27:44 +00:00
|
|
|
.name = "move.roll",
|
|
|
|
.description = "Roll axis",
|
|
|
|
};
|
|
|
|
|
2021-11-01 04:54:16 +00:00
|
|
|
in_button_t in_left = {
|
|
|
|
.name = "left",
|
|
|
|
.description = "When active the player is turning left"
|
|
|
|
};
|
|
|
|
in_button_t in_right = {
|
|
|
|
.name = "right",
|
|
|
|
.description = "When active the player is turning right"
|
|
|
|
};
|
|
|
|
in_button_t in_forward = {
|
|
|
|
.name = "forward",
|
|
|
|
.description = "When active the player is moving forward"
|
|
|
|
};
|
|
|
|
in_button_t in_back = {
|
|
|
|
.name = "back",
|
|
|
|
.description = "When active the player is moving backwards"
|
|
|
|
};
|
|
|
|
in_button_t in_lookup = {
|
|
|
|
.name = "lookup",
|
|
|
|
.description = "When active the player's view is looking up"
|
|
|
|
};
|
|
|
|
in_button_t in_lookdown = {
|
|
|
|
.name = "lookdown",
|
|
|
|
.description = "When active the player's view is looking down"
|
|
|
|
};
|
|
|
|
in_button_t in_moveleft = {
|
|
|
|
.name = "moveleft",
|
|
|
|
.description = "When active the player is strafing left"
|
|
|
|
};
|
|
|
|
in_button_t in_moveright = {
|
|
|
|
.name = "moveright",
|
|
|
|
.description = "When active the player is strafing right"
|
|
|
|
};
|
|
|
|
in_button_t in_use = {
|
|
|
|
.name = "use",
|
|
|
|
.description = "Left over command for opening doors and triggering"
|
|
|
|
" switches"
|
|
|
|
};
|
|
|
|
in_button_t in_jump = {
|
|
|
|
.name = "jump",
|
|
|
|
.description = "When active the player is jumping"
|
|
|
|
};
|
|
|
|
in_button_t in_attack = {
|
|
|
|
.name = "attack",
|
|
|
|
.description = "When active player is firing/using current weapon"
|
|
|
|
};
|
|
|
|
in_button_t in_up = {
|
|
|
|
.name = "moveup",
|
|
|
|
.description = "When active the player is swimming up in a liquid"
|
|
|
|
};
|
|
|
|
in_button_t in_down = {
|
|
|
|
.name = "movedown",
|
|
|
|
.description = "When active the player is swimming down in a liquid"
|
|
|
|
};
|
|
|
|
in_button_t in_strafe = {
|
|
|
|
.name = "strafe",
|
|
|
|
.description = "When active, +left and +right function like +moveleft and"
|
|
|
|
" +moveright"
|
|
|
|
};
|
|
|
|
in_button_t in_klook = {
|
|
|
|
.name = "klook",
|
|
|
|
.description = "When active, +forward and +back perform +lookup and"
|
|
|
|
" +lookdown"
|
|
|
|
};
|
|
|
|
in_button_t in_speed = {
|
|
|
|
.name = "speed",
|
|
|
|
.description = "When active the player is running"
|
|
|
|
};
|
|
|
|
in_button_t in_mlook = {
|
|
|
|
.name = "mlook",
|
|
|
|
.description = "When active moving the mouse or joystick forwards "
|
|
|
|
"and backwards performs +lookup and "
|
|
|
|
"+lookdown"
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-11-18 06:27:44 +00:00
|
|
|
static in_axis_t *cl_in_axes[] = {
|
|
|
|
&viewdelta_position_forward,
|
|
|
|
&viewdelta_position_side,
|
|
|
|
&viewdelta_position_up,
|
|
|
|
&viewdelta_angles_pitch,
|
|
|
|
&viewdelta_angles_yaw,
|
|
|
|
&viewdelta_angles_roll,
|
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
2021-11-01 04:54:16 +00:00
|
|
|
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
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int in_impulse;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
void (*write_angles) (sizebuf_t *sb, const vec3_t angles);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-19 18:56:16 +00:00
|
|
|
IN_Impulse (void *data)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
in_impulse = atoi (Cmd_Argv (1));
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_anglespeedkey;
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_backspeed;
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_forwardspeed;
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_movespeedkey;
|
|
|
|
cvar_t *cl_pitchspeed;
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_sidespeed;
|
|
|
|
cvar_t *cl_upspeed;
|
|
|
|
cvar_t *cl_yawspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-05-14 03:08:24 +00:00
|
|
|
CL_AdjustAngles
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
Moves the local angle positions
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_AdjustAngles (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-19 00:49:39 +00:00
|
|
|
float down, up;
|
|
|
|
float pitchspeed, yawspeed;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2011-06-19 00:49:39 +00:00
|
|
|
pitchspeed = cl_pitchspeed->value;
|
|
|
|
yawspeed = cl_yawspeed->value;
|
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (in_speed.state & inb_down) {
|
2011-06-19 00:49:39 +00:00
|
|
|
pitchspeed *= cl_anglespeedkey->value;
|
|
|
|
yawspeed *= cl_anglespeedkey->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cl.fpd & FPD_LIMIT_PITCH) && pitchspeed > FPD_MAXPITCH)
|
|
|
|
pitchspeed = FPD_MAXPITCH;
|
|
|
|
if ((cl.fpd & FPD_LIMIT_YAW) && yawspeed > FPD_MAXYAW)
|
|
|
|
yawspeed = FPD_MAXYAW;
|
|
|
|
|
|
|
|
pitchspeed *= host_frametime;
|
|
|
|
yawspeed *= host_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (!(in_strafe.state & inb_down)) {
|
|
|
|
cl.viewstate.angles[YAW] -= yawspeed * IN_ButtonState (&in_right);
|
|
|
|
cl.viewstate.angles[YAW] += yawspeed * IN_ButtonState (&in_left);
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[YAW] = anglemod (cl.viewstate.angles[YAW]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (in_klook.state & inb_down) {
|
2001-02-19 21:15:25 +00:00
|
|
|
V_StopPitchDrift ();
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
cl.viewstate.angles[PITCH] -= pitchspeed * IN_ButtonState (&in_forward);
|
|
|
|
cl.viewstate.angles[PITCH] += pitchspeed * IN_ButtonState (&in_back);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
up = IN_ButtonState (&in_lookup);
|
|
|
|
down = IN_ButtonState (&in_lookdown);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH] -= pitchspeed * up;
|
|
|
|
cl.viewstate.angles[PITCH] += pitchspeed * down;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (up || down)
|
|
|
|
V_StopPitchDrift ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2011-06-19 00:49:39 +00:00
|
|
|
// FIXME: Need to clean up view angle limits
|
2021-03-19 11:18:45 +00:00
|
|
|
if (cl.viewstate.angles[PITCH] > 80)
|
|
|
|
cl.viewstate.angles[PITCH] = 80;
|
|
|
|
if (cl.viewstate.angles[PITCH] < -70)
|
|
|
|
cl.viewstate.angles[PITCH] = -70;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
if (cl.viewstate.angles[ROLL] > 50)
|
|
|
|
cl.viewstate.angles[ROLL] = 50;
|
|
|
|
if (cl.viewstate.angles[ROLL] < -50)
|
|
|
|
cl.viewstate.angles[ROLL] = -50;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 03:08:24 +00:00
|
|
|
CL_BaseMove
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
Send the intended movement message to the server
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_BaseMove (usercmd_t *cmd)
|
|
|
|
{
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (IN_ButtonReleased (&in_mlook) && !freelook && lookspring->int_val) {
|
|
|
|
V_StartPitchDrift ();
|
|
|
|
}
|
|
|
|
|
2021-03-19 16:48:26 +00:00
|
|
|
if (cls.state != ca_active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2021-03-19 16:48:26 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_AdjustAngles ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
memset (cmd, 0, sizeof (*cmd));
|
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (in_strafe.state & inb_down) {
|
|
|
|
cmd->sidemove += cl_sidespeed->value * IN_ButtonState (&in_right);
|
|
|
|
cmd->sidemove -= cl_sidespeed->value * IN_ButtonState (&in_left);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
cmd->sidemove += cl_sidespeed->value * IN_ButtonState (&in_moveright);
|
|
|
|
cmd->sidemove -= cl_sidespeed->value * IN_ButtonState (&in_moveleft);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
cmd->upmove += cl_upspeed->value * IN_ButtonState (&in_up);
|
|
|
|
cmd->upmove -= cl_upspeed->value * IN_ButtonState (&in_down);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (!(in_klook.state & inb_down)) {
|
|
|
|
cmd->forwardmove += cl_forwardspeed->value * IN_ButtonState (&in_forward);
|
|
|
|
cmd->forwardmove -= cl_backspeed->value * IN_ButtonState (&in_back);
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
2001-05-14 03:08:24 +00:00
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// adjust for speed key
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (in_speed.state & inb_down) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cmd->forwardmove *= cl_movespeedkey->value;
|
|
|
|
cmd->sidemove *= cl_movespeedkey->value;
|
|
|
|
cmd->upmove *= cl_movespeedkey->value;
|
|
|
|
}
|
2001-04-11 07:57:08 +00:00
|
|
|
|
|
|
|
if (freelook)
|
|
|
|
V_StopPitchDrift ();
|
|
|
|
|
2001-09-28 07:51:15 +00:00
|
|
|
// adjust for chase camera angles
|
2021-03-19 11:18:45 +00:00
|
|
|
/*FIXME:chase figure out just what this does and get it working
|
2011-06-19 00:49:39 +00:00
|
|
|
if (cl.chase
|
|
|
|
&& (chase_active->int_val == 2 || chase_active->int_val == 3)) {
|
|
|
|
vec3_t forward, right, up, f, r;
|
|
|
|
vec3_t dir = {0, 0, 0};
|
2004-02-03 05:16:22 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
dir[1] = r_data->refdef->viewangles[1] - cl.viewstate.angles[1];
|
2001-09-28 07:51:15 +00:00
|
|
|
AngleVectors (dir, forward, right, up);
|
2001-12-11 20:49:10 +00:00
|
|
|
VectorScale (forward, cmd->forwardmove, f);
|
2004-02-03 05:16:22 +00:00
|
|
|
VectorScale (right, cmd->sidemove, r);
|
2001-12-11 20:49:10 +00:00
|
|
|
cmd->forwardmove = f[0] + r[0];
|
2004-02-03 05:16:22 +00:00
|
|
|
cmd->sidemove = f[1] + r[1];
|
2001-12-11 20:49:10 +00:00
|
|
|
VectorScale (forward, viewdelta.position[2], f);
|
2004-02-03 05:16:22 +00:00
|
|
|
VectorScale (right, viewdelta.position[0], r);
|
|
|
|
viewdelta.position[2] = f[0] + r[0];
|
2001-12-11 20:49:10 +00:00
|
|
|
viewdelta.position[0] = (f[1] + r[1]) * -1;
|
2001-09-28 07:51:15 +00:00
|
|
|
}
|
2021-03-19 11:18:45 +00:00
|
|
|
*/
|
2001-09-28 07:51:15 +00:00
|
|
|
|
2021-11-23 13:04:17 +00:00
|
|
|
cmd->forwardmove -= IN_UpdateAxis (&viewdelta_position_forward) * m_forward->value;
|
|
|
|
cmd->sidemove += IN_UpdateAxis (&viewdelta_position_side) * m_side->value;
|
|
|
|
cmd->upmove -= IN_UpdateAxis (&viewdelta_position_up);
|
|
|
|
cl.viewstate.angles[PITCH] -= IN_UpdateAxis (&viewdelta_angles_pitch) * m_pitch->value;
|
|
|
|
cl.viewstate.angles[YAW] -= IN_UpdateAxis (&viewdelta_angles_yaw) * m_yaw->value;
|
|
|
|
cl.viewstate.angles[ROLL] -= IN_UpdateAxis (&viewdelta_angles_roll) * m_pitch->value;
|
2001-04-11 07:57:08 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
if (freelook && !(in_strafe.state & inb_down)) {
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH]
|
|
|
|
= bound (-70, cl.viewstate.angles[PITCH], 80);
|
2001-04-11 07:57:08 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_SendMove (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
byte data[128];
|
2001-12-12 21:56:09 +00:00
|
|
|
int bits;
|
2001-08-29 02:12:57 +00:00
|
|
|
sizebuf_t buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
buf.maxsize = 128;
|
|
|
|
buf.cursize = 0;
|
|
|
|
buf.data = data;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.cmd = *cmd;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// send the movement message
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&buf, clc_move);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2004-02-03 05:16:22 +00:00
|
|
|
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
write_angles (&buf, cl.viewstate.angles);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
MSG_WriteShort (&buf, cmd->forwardmove);
|
|
|
|
MSG_WriteShort (&buf, cmd->sidemove);
|
|
|
|
MSG_WriteShort (&buf, cmd->upmove);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// send button bits
|
2001-02-19 21:15:25 +00:00
|
|
|
bits = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
bits |= IN_ButtonPressed (&in_attack) << 0;
|
|
|
|
bits |= IN_ButtonPressed (&in_jump) << 1;
|
|
|
|
bits |= IN_ButtonPressed (&in_use) << 2;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&buf, bits);
|
|
|
|
|
|
|
|
MSG_WriteByte (&buf, in_impulse);
|
2001-02-19 21:15:25 +00:00
|
|
|
in_impulse = 0;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// deliver the message
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.demoplayback)
|
|
|
|
return;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// always dump the first two message, because it may contain leftover
|
|
|
|
// inputs from the last level
|
2001-02-19 21:15:25 +00:00
|
|
|
if (++cl.movemessages <= 2)
|
|
|
|
return;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("CL_SendMove: lost server connection\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Disconnect ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 06:27:44 +00:00
|
|
|
static int
|
|
|
|
cl_event_handler (const IE_event_t *ie_event, void *unused)
|
|
|
|
{
|
|
|
|
if (ie_event->type == ie_key) {
|
|
|
|
if (ie_event->key.code == QFK_ESCAPE) {
|
2021-11-28 13:42:01 +00:00
|
|
|
Con_SetState (con_menu);
|
2021-11-18 06:27:44 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return IN_Binding_HandleEvent (ie_event);
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2021-11-18 06:27:44 +00:00
|
|
|
CL_Input_Init (cbuf_t *cbuf)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2021-11-18 06:27:44 +00:00
|
|
|
cl_event_id = IE_Add_Handler (cl_event_handler, 0);
|
|
|
|
|
|
|
|
for (int i = 0; cl_in_axes[i]; i++) {
|
|
|
|
IN_RegisterAxis (cl_in_axes[i]);
|
|
|
|
}
|
2021-11-01 04:54:16 +00:00
|
|
|
for (int i = 0; cl_in_buttons[i]; i++) {
|
|
|
|
IN_RegisterButton (cl_in_buttons[i]);
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
}
|
2021-11-18 06:27:44 +00:00
|
|
|
cl_game_context = IMT_CreateContext ("key_game");
|
|
|
|
IMT_SetContextCbuf (cl_game_context, cbuf);
|
|
|
|
cl_demo_context = IMT_CreateContext ("key_demo");
|
|
|
|
IMT_SetContextCbuf (cl_demo_context, cbuf);
|
2021-03-19 18:56:16 +00:00
|
|
|
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
|
|
|
"Call a game function or QuakeC function.");
|
2021-11-25 03:46:54 +00:00
|
|
|
CL_Legacy_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2021-11-18 06:27:44 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CL_Input_Activate (void)
|
|
|
|
{
|
2021-11-25 16:59:18 +00:00
|
|
|
host_in_game = !cls.demoplayback;
|
|
|
|
IMT_SetContext (cls.demoplayback ? cl_demo_context : cl_game_context);
|
2021-11-18 06:27:44 +00:00
|
|
|
IE_Set_Focus (cl_event_id);
|
|
|
|
}
|