Fixed diagonal analog input being weakened

Using a keyboard and an analog stick should now give you similar
acceleration in all directions.
This commit is contained in:
TehRealSalt 2017-09-19 00:26:05 -04:00
parent ce0a49ede5
commit e020352c0c

View file

@ -981,7 +981,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
INT32 tspeed, forward, side, axis, i;
const INT32 speed = 1;
// these ones used for multiple conditions
boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove;
boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove;
player_t *player = &players[consoleplayer];
camera_t *thiscam = &camera;
@ -1002,6 +1002,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
turnright = PLAYER1INPUTDOWN(gc_turnright);
turnleft = PLAYER1INPUTDOWN(gc_turnleft);
straferkey = PLAYER1INPUTDOWN(gc_straferight);
strafelkey = PLAYER1INPUTDOWN(gc_strafeleft);
movefkey = PLAYER1INPUTDOWN(gc_forward);
movebkey = PLAYER1INPUTDOWN(gc_backward);
mouseaiming = (PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value;
analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle;
gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle;
@ -1090,9 +1096,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
// forward with key or button
axis = JoyAxis(AXISMOVE);
if (PLAYER1INPUTDOWN(gc_forward) || (gamepadjoystickmove && axis < 0))
if (movefkey || (gamepadjoystickmove && axis < 0))
forward = forwardmove[speed];
if (PLAYER1INPUTDOWN(gc_backward) || (gamepadjoystickmove && axis > 0))
if (movebkey || (gamepadjoystickmove && axis > 0))
forward -= forwardmove[speed];
if (analogjoystickmove && axis != 0)
@ -1100,9 +1106,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
// some people strafe left & right with mouse buttons
// those people are weird
if (PLAYER1INPUTDOWN(gc_straferight))
if (straferkey)
side += sidemove[speed];
if (PLAYER1INPUTDOWN(gc_strafeleft))
if (strafelkey)
side -= sidemove[speed];
if (PLAYER1INPUTDOWN(gc_weaponnext))
@ -1239,7 +1245,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics)
// No additional acceleration when moving forward/backward and strafing simultaneously.
// do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this.
if (!forcestrafe && forward && side)
// 9-18-2017: ALSO, only do this when using keys to move. Gamepad analog sticks get severely gimped by this
if (!forcestrafe && (((movefkey || movebkey) && side) || ((strafelkey || straferkey) && forward)))
{
forward = FixedMul(forward, 3*FRACUNIT/4);
side = FixedMul(side, 3*FRACUNIT/4);