mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-29 12:11:03 +00:00
- Recover two ESyncBit
values for other uses.
* By masking aiming+centering, we have look bits :)
This commit is contained in:
parent
bae18b3023
commit
46b5977a6a
5 changed files with 27 additions and 14 deletions
|
@ -198,7 +198,6 @@ void getInput(const double scaleAdjust, PlayerAngles* const plrAngles, InputPack
|
|||
|
||||
if (packet)
|
||||
{
|
||||
gi->reapplyInputBits(&inputBuffer);
|
||||
*packet = inputBuffer;
|
||||
clearLocalInputBuffer();
|
||||
}
|
||||
|
@ -217,20 +216,26 @@ void PlayerAngles::doPitchKeys(InputPacket* const input)
|
|||
if (input->horz)
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
|
||||
// Set up a myriad of bools.
|
||||
const auto aimingUp = (input->actions & SB_LOOK_UP) == SB_AIM_UP;
|
||||
const auto aimingDown = (input->actions & SB_LOOK_DOWN) == SB_AIM_DOWN;
|
||||
const auto lookingUp = (input->actions & SB_LOOK_UP) == SB_LOOK_UP;
|
||||
const auto lookingDown = (input->actions & SB_LOOK_DOWN) == SB_LOOK_DOWN;
|
||||
|
||||
// Process keyboard input.
|
||||
if (const auto aiming = !!(input->actions & SB_AIM_DOWN) - !!(input->actions & SB_AIM_UP))
|
||||
if (const auto aiming = aimingDown - aimingUp)
|
||||
{
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_AIMSPEED) * aiming);
|
||||
input->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
if (const auto looking = !!(input->actions & SB_LOOK_DOWN) - !!(input->actions & SB_LOOK_UP))
|
||||
if (const auto looking = lookingDown - lookingUp)
|
||||
{
|
||||
pActor->spr.Angles.Pitch += DAngle::fromDeg(getTicrateScale(PITCH_LOOKSPEED) * looking);
|
||||
input->actions |= SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
// Do return to centre.
|
||||
if ((input->actions & SB_CENTERVIEW) && !(input->actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||
if ((input->actions & SB_CENTERVIEW) && !(lookingUp || lookingDown))
|
||||
{
|
||||
const auto pitch = abs(pActor->spr.Angles.Pitch);
|
||||
const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.;
|
||||
|
|
|
@ -374,14 +374,22 @@ void ApplyGlobalInput(HIDInput* const hidInput, InputPacket* const inputBuffer)
|
|||
}
|
||||
else dpad_lock = 0;
|
||||
|
||||
gi->reapplyInputBits(inputBuffer);
|
||||
|
||||
inputBuffer->actions |= ActionsToSend;
|
||||
ActionsToSend = 0;
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Aim_Up) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->joyaxes[JOYAXIS_Forward] > 0))
|
||||
{
|
||||
inputBuffer->actions |= SB_AIM_UP;
|
||||
inputBuffer->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
if ((buttonMap.ButtonDown(gamefunc_Aim_Down) || (buttonMap.ButtonDown(gamefunc_Dpad_Aiming) && hidInput->joyaxes[JOYAXIS_Forward] < 0)))
|
||||
{
|
||||
inputBuffer->actions |= SB_AIM_DOWN;
|
||||
inputBuffer->actions &= ~SB_CENTERVIEW;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Dpad_Aiming))
|
||||
hidInput->joyaxes[JOYAXIS_Forward] = 0;
|
||||
|
|
|
@ -31,8 +31,8 @@ enum ESyncBits_ : uint32_t
|
|||
SB_AIM_DOWN = 1 << 22,
|
||||
SB_LOOK_LEFT = 1 << 23,
|
||||
SB_LOOK_RIGHT = 1 << 24,
|
||||
SB_LOOK_UP = 1 << 25,
|
||||
SB_LOOK_DOWN = 1 << 26,
|
||||
SB_LOOK_UP = SB_AIM_UP|SB_CENTERVIEW,
|
||||
SB_LOOK_DOWN = SB_AIM_DOWN|SB_CENTERVIEW,
|
||||
SB_RUN = 1 << 27,
|
||||
SB_JUMP = 1 << 28,
|
||||
SB_CROUCH = 1 << 29,
|
||||
|
|
|
@ -2973,19 +2973,19 @@ HORIZONLY:
|
|||
{
|
||||
playerCenterView(snum);
|
||||
}
|
||||
else if (actions & SB_LOOK_UP)
|
||||
else if ((actions & SB_LOOK_UP) == SB_LOOK_UP)
|
||||
{
|
||||
playerLookUp(snum, actions);
|
||||
}
|
||||
else if (actions & SB_LOOK_DOWN)
|
||||
else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN)
|
||||
{
|
||||
playerLookDown(snum, actions);
|
||||
}
|
||||
else if (actions & SB_AIM_UP)
|
||||
else if ((actions & SB_LOOK_UP) == SB_AIM_UP)
|
||||
{
|
||||
playerAimUp(snum, actions);
|
||||
}
|
||||
else if (actions & SB_AIM_DOWN)
|
||||
else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN)
|
||||
{ // aim_down
|
||||
playerAimDown(snum, actions);
|
||||
}
|
||||
|
|
|
@ -3694,19 +3694,19 @@ HORIZONLY:
|
|||
{
|
||||
playerCenterView(snum);
|
||||
}
|
||||
else if (actions & SB_LOOK_UP)
|
||||
else if ((actions & SB_LOOK_UP) == SB_LOOK_UP)
|
||||
{
|
||||
playerLookUp(snum, actions);
|
||||
}
|
||||
else if (actions & SB_LOOK_DOWN)
|
||||
else if ((actions & SB_LOOK_DOWN) == SB_LOOK_DOWN)
|
||||
{
|
||||
playerLookDown(snum, actions);
|
||||
}
|
||||
else if ((actions & SB_AIM_UP) && !p->OnMotorcycle)
|
||||
else if ((actions & SB_LOOK_UP) == SB_AIM_UP && !p->OnMotorcycle)
|
||||
{
|
||||
playerAimUp(snum, actions);
|
||||
}
|
||||
else if ((actions & SB_AIM_DOWN) && !p->OnMotorcycle)
|
||||
else if ((actions & SB_LOOK_DOWN) == SB_AIM_DOWN && !p->OnMotorcycle)
|
||||
{
|
||||
playerAimDown(snum, actions);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue