- use an array to store the buttons.
This puts a lot less knowledge about the game's features into the low level code.
This commit is contained in:
parent
0e7480b4ed
commit
8dacdf2951
13 changed files with 405 additions and 251 deletions
|
|
@ -80,6 +80,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
#include "c_buttons.h"
|
||||
#include "d_buttons.h"
|
||||
|
||||
|
||||
static FRandom pr_dmspawn ("DMSpawn");
|
||||
|
|
@ -578,15 +579,15 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
|
||||
cmd->consistancy = consistancy[consoleplayer][(maketic/ticdup)%BACKUPTICS];
|
||||
|
||||
strafe = Button_Strafe.bDown;
|
||||
speed = Button_Speed.bDown ^ (int)cl_run;
|
||||
strafe = buttonMap.ButtonDown(Button_Strafe);
|
||||
speed = buttonMap.ButtonDown(Button_Speed) ^ (int)cl_run;
|
||||
|
||||
forward = side = fly = 0;
|
||||
|
||||
// [RH] only use two stage accelerative turning on the keyboard
|
||||
// and not the joystick, since we treat the joystick as
|
||||
// the analog device it is.
|
||||
if (Button_Left.bDown || Button_Right.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Left) || buttonMap.ButtonDown(Button_Right))
|
||||
turnheld += ticdup;
|
||||
else
|
||||
turnheld = 0;
|
||||
|
|
@ -594,9 +595,9 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
// let movement keys cancel each other out
|
||||
if (strafe)
|
||||
{
|
||||
if (Button_Right.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Right))
|
||||
side += sidemove[speed];
|
||||
if (Button_Left.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Left))
|
||||
side -= sidemove[speed];
|
||||
}
|
||||
else
|
||||
|
|
@ -606,77 +607,77 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
if (turnheld < SLOWTURNTICS)
|
||||
tspeed += 2; // slow turn
|
||||
|
||||
if (Button_Right.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Right))
|
||||
{
|
||||
G_AddViewAngle (*angleturn[tspeed]);
|
||||
}
|
||||
if (Button_Left.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Left))
|
||||
{
|
||||
G_AddViewAngle (-*angleturn[tspeed]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Button_LookUp.bDown)
|
||||
if (buttonMap.ButtonDown(Button_LookUp))
|
||||
{
|
||||
G_AddViewPitch (lookspeed[speed]);
|
||||
}
|
||||
if (Button_LookDown.bDown)
|
||||
if (buttonMap.ButtonDown(Button_LookDown))
|
||||
{
|
||||
G_AddViewPitch (-lookspeed[speed]);
|
||||
}
|
||||
|
||||
if (Button_MoveUp.bDown)
|
||||
if (buttonMap.ButtonDown(Button_MoveUp))
|
||||
fly += flyspeed[speed];
|
||||
if (Button_MoveDown.bDown)
|
||||
if (buttonMap.ButtonDown(Button_MoveDown))
|
||||
fly -= flyspeed[speed];
|
||||
|
||||
if (Button_Klook.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Klook))
|
||||
{
|
||||
if (Button_Forward.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Forward))
|
||||
G_AddViewPitch (lookspeed[speed]);
|
||||
if (Button_Back.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Back))
|
||||
G_AddViewPitch (-lookspeed[speed]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Button_Forward.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Forward))
|
||||
forward += forwardmove[speed];
|
||||
if (Button_Back.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Back))
|
||||
forward -= forwardmove[speed];
|
||||
}
|
||||
|
||||
if (Button_MoveRight.bDown)
|
||||
if (buttonMap.ButtonDown(Button_MoveRight))
|
||||
side += sidemove[speed];
|
||||
if (Button_MoveLeft.bDown)
|
||||
if (buttonMap.ButtonDown(Button_MoveLeft))
|
||||
side -= sidemove[speed];
|
||||
|
||||
// buttons
|
||||
if (Button_Attack.bDown) cmd->ucmd.buttons |= BT_ATTACK;
|
||||
if (Button_AltAttack.bDown) cmd->ucmd.buttons |= BT_ALTATTACK;
|
||||
if (Button_Use.bDown) cmd->ucmd.buttons |= BT_USE;
|
||||
if (Button_Jump.bDown) cmd->ucmd.buttons |= BT_JUMP;
|
||||
if (Button_Crouch.bDown) cmd->ucmd.buttons |= BT_CROUCH;
|
||||
if (Button_Zoom.bDown) cmd->ucmd.buttons |= BT_ZOOM;
|
||||
if (Button_Reload.bDown) cmd->ucmd.buttons |= BT_RELOAD;
|
||||
if (buttonMap.ButtonDown(Button_Attack)) cmd->ucmd.buttons |= BT_ATTACK;
|
||||
if (buttonMap.ButtonDown(Button_AltAttack)) cmd->ucmd.buttons |= BT_ALTATTACK;
|
||||
if (buttonMap.ButtonDown(Button_Use)) cmd->ucmd.buttons |= BT_USE;
|
||||
if (buttonMap.ButtonDown(Button_Jump)) cmd->ucmd.buttons |= BT_JUMP;
|
||||
if (buttonMap.ButtonDown(Button_Crouch)) cmd->ucmd.buttons |= BT_CROUCH;
|
||||
if (buttonMap.ButtonDown(Button_Zoom)) cmd->ucmd.buttons |= BT_ZOOM;
|
||||
if (buttonMap.ButtonDown(Button_Reload)) cmd->ucmd.buttons |= BT_RELOAD;
|
||||
|
||||
if (Button_User1.bDown) cmd->ucmd.buttons |= BT_USER1;
|
||||
if (Button_User2.bDown) cmd->ucmd.buttons |= BT_USER2;
|
||||
if (Button_User3.bDown) cmd->ucmd.buttons |= BT_USER3;
|
||||
if (Button_User4.bDown) cmd->ucmd.buttons |= BT_USER4;
|
||||
if (buttonMap.ButtonDown(Button_User1)) cmd->ucmd.buttons |= BT_USER1;
|
||||
if (buttonMap.ButtonDown(Button_User2)) cmd->ucmd.buttons |= BT_USER2;
|
||||
if (buttonMap.ButtonDown(Button_User3)) cmd->ucmd.buttons |= BT_USER3;
|
||||
if (buttonMap.ButtonDown(Button_User4)) cmd->ucmd.buttons |= BT_USER4;
|
||||
|
||||
if (Button_Speed.bDown) cmd->ucmd.buttons |= BT_SPEED;
|
||||
if (Button_Strafe.bDown) cmd->ucmd.buttons |= BT_STRAFE;
|
||||
if (Button_MoveRight.bDown) cmd->ucmd.buttons |= BT_MOVERIGHT;
|
||||
if (Button_MoveLeft.bDown) cmd->ucmd.buttons |= BT_MOVELEFT;
|
||||
if (Button_LookDown.bDown) cmd->ucmd.buttons |= BT_LOOKDOWN;
|
||||
if (Button_LookUp.bDown) cmd->ucmd.buttons |= BT_LOOKUP;
|
||||
if (Button_Back.bDown) cmd->ucmd.buttons |= BT_BACK;
|
||||
if (Button_Forward.bDown) cmd->ucmd.buttons |= BT_FORWARD;
|
||||
if (Button_Right.bDown) cmd->ucmd.buttons |= BT_RIGHT;
|
||||
if (Button_Left.bDown) cmd->ucmd.buttons |= BT_LEFT;
|
||||
if (Button_MoveDown.bDown) cmd->ucmd.buttons |= BT_MOVEDOWN;
|
||||
if (Button_MoveUp.bDown) cmd->ucmd.buttons |= BT_MOVEUP;
|
||||
if (Button_ShowScores.bDown) cmd->ucmd.buttons |= BT_SHOWSCORES;
|
||||
if (buttonMap.ButtonDown(Button_Speed)) cmd->ucmd.buttons |= BT_SPEED;
|
||||
if (buttonMap.ButtonDown(Button_Strafe)) cmd->ucmd.buttons |= BT_STRAFE;
|
||||
if (buttonMap.ButtonDown(Button_MoveRight)) cmd->ucmd.buttons |= BT_MOVERIGHT;
|
||||
if (buttonMap.ButtonDown(Button_MoveLeft)) cmd->ucmd.buttons |= BT_MOVELEFT;
|
||||
if (buttonMap.ButtonDown(Button_LookDown)) cmd->ucmd.buttons |= BT_LOOKDOWN;
|
||||
if (buttonMap.ButtonDown(Button_LookUp)) cmd->ucmd.buttons |= BT_LOOKUP;
|
||||
if (buttonMap.ButtonDown(Button_Back)) cmd->ucmd.buttons |= BT_BACK;
|
||||
if (buttonMap.ButtonDown(Button_Forward)) cmd->ucmd.buttons |= BT_FORWARD;
|
||||
if (buttonMap.ButtonDown(Button_Right)) cmd->ucmd.buttons |= BT_RIGHT;
|
||||
if (buttonMap.ButtonDown(Button_Left)) cmd->ucmd.buttons |= BT_LEFT;
|
||||
if (buttonMap.ButtonDown(Button_MoveDown)) cmd->ucmd.buttons |= BT_MOVEDOWN;
|
||||
if (buttonMap.ButtonDown(Button_MoveUp)) cmd->ucmd.buttons |= BT_MOVEUP;
|
||||
if (buttonMap.ButtonDown(Button_ShowScores)) cmd->ucmd.buttons |= BT_SHOWSCORES;
|
||||
|
||||
// Handle joysticks/game controllers.
|
||||
float joyaxes[NUM_JOYAXIS];
|
||||
|
|
@ -684,12 +685,12 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
I_GetAxes(joyaxes);
|
||||
|
||||
// Remap some axes depending on button state.
|
||||
if (Button_Strafe.bDown || (Button_Mlook.bDown && lookstrafe))
|
||||
if (buttonMap.ButtonDown(Button_Strafe) || (buttonMap.ButtonDown(Button_Mlook) && lookstrafe))
|
||||
{
|
||||
joyaxes[JOYAXIS_Side] = joyaxes[JOYAXIS_Yaw];
|
||||
joyaxes[JOYAXIS_Yaw] = 0;
|
||||
}
|
||||
if (Button_Mlook.bDown)
|
||||
if (buttonMap.ButtonDown(Button_Mlook))
|
||||
{
|
||||
joyaxes[JOYAXIS_Pitch] = joyaxes[JOYAXIS_Forward];
|
||||
joyaxes[JOYAXIS_Forward] = 0;
|
||||
|
|
@ -709,7 +710,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
|||
fly += joyint(joyaxes[JOYAXIS_Up] * 2048);
|
||||
|
||||
// Handle mice.
|
||||
if (!Button_Mlook.bDown && !freelook)
|
||||
if (!buttonMap.ButtonDown(Button_Mlook) && !freelook)
|
||||
{
|
||||
forward += (int)((float)mousey * m_forward);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue