2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
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 the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "compat.h"
|
|
|
|
#include "baselayer.h"
|
2020-02-16 20:31:29 +00:00
|
|
|
#include "mmulti.h"
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "common_game.h"
|
|
|
|
#include "blood.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "controls.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "levels.h"
|
|
|
|
#include "map2d.h"
|
|
|
|
#include "view.h"
|
2019-11-03 19:24:50 +00:00
|
|
|
#include "d_event.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-05-27 15:22:58 +00:00
|
|
|
GINPUT gInput, gNetInput;
|
2019-09-19 22:42:45 +00:00
|
|
|
bool bSilentAim = false;
|
|
|
|
|
|
|
|
int iTurnCount = 0;
|
|
|
|
|
|
|
|
void ctrlInit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ctrlTerm(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t mouseyaxismode = -1;
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
int32_t GetTime(void)
|
|
|
|
{
|
|
|
|
return (int32_t)totalclock;
|
|
|
|
}
|
2019-10-22 21:31:46 +00:00
|
|
|
|
2019-11-03 11:32:58 +00:00
|
|
|
void GameInterface::set_hud_layout(int layout)
|
2019-10-22 21:31:46 +00:00
|
|
|
{
|
2020-01-22 12:53:26 +00:00
|
|
|
layout = clamp(7 - layout, 0, 7); // need to reverse the order because menu sliders always have low values to the left.
|
|
|
|
viewResizeView(layout);
|
2019-10-22 21:31:46 +00:00
|
|
|
}
|
|
|
|
|
2019-11-03 11:32:58 +00:00
|
|
|
void GameInterface::set_hud_scale(int scale)
|
2019-10-22 21:31:46 +00:00
|
|
|
{
|
|
|
|
// Not implemented, only needed as a placeholder. Maybe implement it after all? The hud is a bit large at its default size.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
fix16_t gViewLook, gViewAngle;
|
|
|
|
float gViewAngleAdjust;
|
|
|
|
float gViewLookAdjust;
|
|
|
|
int gViewLookRecenter;
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
void ctrlGetInput(void)
|
|
|
|
{
|
2020-05-29 01:20:40 +00:00
|
|
|
int prevPauseState = paused;
|
2019-09-19 22:42:45 +00:00
|
|
|
ControlInfo info;
|
|
|
|
|
2020-05-29 01:20:40 +00:00
|
|
|
static double lastInputTicks;
|
|
|
|
auto const currentHiTicks = timerGetHiTicks();
|
|
|
|
double const elapsedInputTicks = currentHiTicks - lastInputTicks;
|
|
|
|
|
|
|
|
lastInputTicks = currentHiTicks;
|
|
|
|
|
|
|
|
auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); };
|
|
|
|
|
2019-10-19 15:20:06 +00:00
|
|
|
if (!gGameStarted || gInputMode != kInputGame)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput = {};
|
2019-09-19 22:42:45 +00:00
|
|
|
CONTROL_GetInput(&info);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-29 01:20:40 +00:00
|
|
|
updatePauseStatus();
|
|
|
|
if (paused != prevPauseState)
|
|
|
|
{
|
|
|
|
gInput.keyFlags.pause = 1;
|
|
|
|
}
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2020-05-29 01:20:40 +00:00
|
|
|
if (paused)
|
|
|
|
return;
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2020-05-29 01:20:40 +00:00
|
|
|
GINPUT input = {};
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2019-11-03 19:24:50 +00:00
|
|
|
D_ProcessEvents();
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
|
|
|
if (!mouseaim) gInput.keyFlags.lookCenter = 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-02-16 20:31:29 +00:00
|
|
|
if (numplayers == 1)
|
|
|
|
{
|
|
|
|
gProfile[myconnectindex].nAutoAim = cl_autoaim;
|
|
|
|
gProfile[myconnectindex].nWeaponSwitch = cl_weaponswitch;
|
|
|
|
}
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
CONTROL_GetInput(&info);
|
|
|
|
|
|
|
|
if (gQuitRequest)
|
|
|
|
gInput.keyFlags.quit = 1;
|
|
|
|
|
2020-04-11 22:10:39 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Map))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-04-11 22:10:39 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Map);
|
2019-09-19 22:42:45 +00:00
|
|
|
viewToggle(gViewMode);
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
|
2019-09-19 22:42:45 +00:00
|
|
|
gFollowMap = !gFollowMap;
|
|
|
|
gViewMap.FollowMode(gFollowMap);
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (gViewMode == 3)
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Shrink_Screen);
|
2019-10-22 21:31:46 +00:00
|
|
|
G_ChangeHudLayout(-1);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gViewMode == 2 || gViewMode == 4)
|
|
|
|
{
|
|
|
|
gZoom = ClipLow(gZoom - (gZoom >> 4), 64);
|
|
|
|
gViewMap.nZoom = gZoom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (gViewMode == 3)
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Enlarge_Screen);
|
2019-10-22 21:31:46 +00:00
|
|
|
G_ChangeHudLayout(1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
if (gViewMode == 2 || gViewMode == 4)
|
|
|
|
{
|
|
|
|
gZoom = ClipHigh(gZoom + (gZoom >> 4), 4096);
|
|
|
|
gViewMap.nZoom = gZoom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
|
2019-10-21 21:29:48 +00:00
|
|
|
cl_crosshair = !cl_crosshair;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 01:28:41 +00:00
|
|
|
if (gPlayer[myconnectindex].nextWeapon == 0)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-05-29 01:28:41 +00:00
|
|
|
if (buttonMap.ButtonPressed(gamefunc_Next_Weapon))
|
|
|
|
{
|
|
|
|
buttonMap.ClearButton(gamefunc_Next_Weapon);
|
|
|
|
gInput.keyFlags.nextWeapon = 1;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-05-29 01:28:41 +00:00
|
|
|
if (buttonMap.ButtonPressed(gamefunc_Previous_Weapon))
|
|
|
|
{
|
|
|
|
buttonMap.ClearButton(gamefunc_Previous_Weapon);
|
|
|
|
gInput.keyFlags.prevWeapon = 1;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Show_Opponents_Weapon))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Show_Opponents_Weapon);
|
2019-10-27 09:17:46 +00:00
|
|
|
cl_showweapon = (cl_showweapon + 1) & 3;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Jump))
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.buttonFlags.jump = 1;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Crouch))
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.buttonFlags.crouch = 1;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Fire))
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.buttonFlags.shoot = 1;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Alt_Fire))
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.buttonFlags.shoot2 = 1;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Open))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Open);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.action = 1;
|
|
|
|
}
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput.buttonFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Look_Up);
|
|
|
|
gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Look_Down);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Look_Up) || buttonMap.ButtonDown(gamefunc_Look_Down))
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.lookCenter = 1;
|
|
|
|
else
|
|
|
|
{
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput.buttonFlags.lookUp |= buttonMap.ButtonDown(gamefunc_Aim_Up);
|
|
|
|
gInput.buttonFlags.lookDown |= buttonMap.ButtonDown(gamefunc_Aim_Down);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 21:22:51 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Center_View))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-09 21:22:51 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Center_View);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.lookCenter = 1;
|
|
|
|
}
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput.keyFlags.spin180 |= buttonMap.ButtonDown(gamefunc_TurnAround);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Inventory_Left))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Inventory_Left);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.prevItem = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Inventory_Right))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Inventory_Right);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.nextItem = 1;
|
|
|
|
}
|
|
|
|
|
2020-04-11 22:10:39 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Inventory))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-04-11 22:10:39 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Inventory);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.useItem = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_BeastVision))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_BeastVision);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.useFlags.useBeastVision = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_CrystalBall))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_CrystalBall);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.useFlags.useCrystalBall = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_JumpBoots))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_JumpBoots);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.useFlags.useJumpBoots = 1;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_MedKit))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_MedKit);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.useFlags.useMedKit = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Weapon_1 + i);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.newWeapon = 1 + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_ProximityBombs))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_ProximityBombs);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.newWeapon = 11;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_RemoteBombs))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_RemoteBombs);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.newWeapon = 12;
|
|
|
|
}
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Holster_Weapon))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Holster_Weapon);
|
2019-09-19 22:42:45 +00:00
|
|
|
gInput.keyFlags.holsterWeapon = 1;
|
|
|
|
}
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
int const run = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
|
|
|
int const run2 = false; // What??? buttonMap.ButtonDown(gamefunc_Run);
|
|
|
|
int const keyMove = (1 + run) << 10;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput.syncFlags.run |= run;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
if (gInput.forward < keyMove && gInput.forward > -keyMove)
|
|
|
|
{
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
2020-06-24 13:11:42 +00:00
|
|
|
input.forward += keyMove;
|
2020-01-30 13:05:34 +00:00
|
|
|
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
2020-06-24 13:11:42 +00:00
|
|
|
input.forward -= keyMove;
|
2020-01-30 13:05:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gInput.strafe < keyMove && gInput.strafe > -keyMove)
|
|
|
|
{
|
2020-03-30 22:22:55 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
|
2020-01-30 13:05:34 +00:00
|
|
|
input.strafe += keyMove;
|
2020-03-30 22:22:55 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe_Right))
|
2020-01-30 13:05:34 +00:00
|
|
|
input.strafe -= keyMove;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
char turnLeft = 0, turnRight = 0;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-30 13:05:34 +00:00
|
|
|
if (gInput.strafe < keyMove && gInput.strafe > -keyMove)
|
|
|
|
{
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
|
|
|
input.strafe += keyMove;
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
|
|
|
input.strafe -= keyMove;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
2019-09-19 22:42:45 +00:00
|
|
|
turnLeft = 1;
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
2019-09-19 22:42:45 +00:00
|
|
|
turnRight = 1;
|
|
|
|
}
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
static int32_t turnHeldTime;
|
|
|
|
static int32_t lastInputClock; // MED
|
|
|
|
int32_t const elapsedTics = (int32_t)totalclock - lastInputClock;
|
|
|
|
|
2020-06-24 13:11:42 +00:00
|
|
|
// Blood's q16mlook scaling is different from the other games, therefore use the below constant to attenuate
|
|
|
|
// the speed to match the other games.
|
|
|
|
float const mlookScale = 3.25f;
|
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
lastInputClock = (int32_t) totalclock;
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
if (turnLeft || turnRight)
|
2020-01-30 13:05:34 +00:00
|
|
|
turnHeldTime += elapsedTics;
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-01-30 13:05:34 +00:00
|
|
|
turnHeldTime = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
if (turnLeft)
|
2020-04-13 07:54:47 +00:00
|
|
|
input.q16turn = fix16_ssub(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
|
2019-09-19 22:42:45 +00:00
|
|
|
if (turnRight)
|
2020-04-13 07:54:47 +00:00
|
|
|
input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(ClipHigh(12 * turnHeldTime, gTurnSpeed)>>2)));
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-30 13:05:34 +00:00
|
|
|
if ((run2 || run) && turnHeldTime > 24)
|
|
|
|
input.q16turn <<= 1;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe))
|
2020-06-24 13:11:42 +00:00
|
|
|
{
|
|
|
|
static int strafeyaw;
|
|
|
|
|
|
|
|
input.strafe = -(info.mousex + strafeyaw) >> 3;
|
|
|
|
strafeyaw = (info.mousex + strafeyaw) % 8;
|
|
|
|
|
|
|
|
input.strafe -= scaleAdjustmentToInterval(info.dyaw * keyMove);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2020-06-24 13:11:42 +00:00
|
|
|
{
|
2020-03-31 21:30:54 +00:00
|
|
|
input.q16turn = fix16_sadd(input.q16turn, fix16_sdiv(fix16_from_int(info.mousex), fix16_from_int(32)));
|
2020-06-24 13:11:42 +00:00
|
|
|
input.q16turn = fix16_sadd(input.q16turn, fix16_from_dbl(scaleAdjustmentToInterval(info.dyaw)));
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-06-24 13:11:42 +00:00
|
|
|
input.strafe -= scaleAdjustmentToInterval(info.dx * keyMove);
|
|
|
|
input.forward -= scaleAdjustmentToInterval(info.dz * keyMove);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
if (mouseaim)
|
2020-06-24 13:11:42 +00:00
|
|
|
input.q16mlook = fix16_sadd(input.q16mlook, fix16_sdiv(fix16_from_int(info.mousey), fix16_from_float(mlookScale * 64.f)));
|
2019-08-16 04:31:07 +00:00
|
|
|
else
|
2020-01-30 13:05:34 +00:00
|
|
|
input.forward -= info.mousey;
|
2019-10-22 22:59:01 +00:00
|
|
|
if (!in_mouseflip)
|
2020-01-30 13:05:34 +00:00
|
|
|
input.q16mlook = -input.q16mlook;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-06-24 13:11:42 +00:00
|
|
|
input.q16mlook = fix16_ssub(input.q16mlook, fix16_from_dbl(scaleAdjustmentToInterval(info.dpitch / mlookScale)));
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
if (!gViewMap.bFollowMode && gViewMode == 4)
|
|
|
|
{
|
2020-01-30 13:05:34 +00:00
|
|
|
gViewMap.turn += input.q16turn<<2;
|
|
|
|
gViewMap.forward += input.forward;
|
|
|
|
gViewMap.strafe += input.strafe;
|
|
|
|
input.q16turn = 0;
|
|
|
|
input.forward = 0;
|
|
|
|
input.strafe = 0;
|
|
|
|
}
|
|
|
|
gInput.forward = clamp(gInput.forward + input.forward, -2048, 2048);
|
|
|
|
gInput.strafe = clamp(gInput.strafe + input.strafe, -2048, 2048);
|
|
|
|
gInput.q16turn = fix16_sadd(gInput.q16turn, input.q16turn);
|
2020-03-31 21:30:54 +00:00
|
|
|
gInput.q16mlook = fix16_clamp(fix16_sadd(gInput.q16mlook, input.q16mlook), fix16_from_int(-127)>>2, fix16_from_int(127)>>2);
|
2020-05-29 01:20:40 +00:00
|
|
|
if (gMe && gMe->pXSprite->health != 0 && !paused)
|
2020-01-30 13:05:34 +00:00
|
|
|
{
|
2020-04-01 11:55:36 +00:00
|
|
|
int upAngle = 289;
|
|
|
|
int downAngle = -347;
|
|
|
|
double lookStepUp = 4.0*upAngle/60.0;
|
|
|
|
double lookStepDown = -4.0*downAngle/60.0;
|
2020-04-13 07:54:47 +00:00
|
|
|
gViewAngle = (gViewAngle + input.q16turn + fix16_from_dbl(scaleAdjustmentToInterval(gViewAngleAdjust))) & 0x7ffffff;
|
2020-01-30 13:05:34 +00:00
|
|
|
if (gViewLookRecenter)
|
|
|
|
{
|
|
|
|
if (gViewLook < 0)
|
2020-04-13 07:54:47 +00:00
|
|
|
gViewLook = fix16_min(gViewLook+fix16_from_dbl(scaleAdjustmentToInterval(lookStepDown)), fix16_from_int(0));
|
2020-01-30 13:05:34 +00:00
|
|
|
if (gViewLook > 0)
|
2020-04-13 07:54:47 +00:00
|
|
|
gViewLook = fix16_max(gViewLook-fix16_from_dbl(scaleAdjustmentToInterval(lookStepUp)), fix16_from_int(0));
|
2020-01-30 13:05:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-13 07:54:47 +00:00
|
|
|
gViewLook = fix16_clamp(gViewLook+fix16_from_dbl(scaleAdjustmentToInterval(gViewLookAdjust)), fix16_from_int(downAngle), fix16_from_int(upAngle));
|
2020-01-30 13:05:34 +00:00
|
|
|
}
|
2020-03-31 21:30:54 +00:00
|
|
|
gViewLook = fix16_clamp(gViewLook+(input.q16mlook << 3), fix16_from_int(downAngle), fix16_from_int(upAngle));
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
2019-12-24 12:21:36 +00:00
|
|
|
#if 0
|
|
|
|
if (gGameStarted && gInputMode != kInputMessage
|
|
|
|
&& buttonMap.ButtonDown(gamefunc_SendMessage))
|
|
|
|
{
|
|
|
|
buttonMap.ClearButton(gamefunc_SendMessage);
|
|
|
|
inputState.keyFlushScans();
|
|
|
|
gInputMode = kInputMessage;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|