Disable turning with joystick while paused or menu open

Also fixes mouse movements accumulating while paused.

- If you're playing with a controller, you can still turn the player
  while the game is paused or a menu is open. It's pretty jank as you
  may be controlling the faded scene in the background behind a menu,
  and it might make someone think their inputs aren't being read by the
  menu or that the game isn't truly paused.
- If the game is paused (with the pause key specifically, so that the
  mouse is still captured), then mouse movements continue to accumulate
  while you're paused, potentially causing a very sudden disorienting
  jump when the game is eventually unpaused.
- If you're chatting, then you can still look around (with the mouse or
  controller), though you can't move or shoot. This can be confusing if
  you don't realize you're locked in a menu (as every other case you're
  locked in a menu stops you from looking around with the mouse).
This commit is contained in:
Chris Cowan 2023-03-05 01:58:39 -08:00 committed by Ozkan Sezer
parent 88d9a8f45d
commit 9d941b2d73
1 changed files with 7 additions and 0 deletions

View File

@ -666,6 +666,9 @@ void IN_JoyMove (usercmd_t *cmd)
if (!joy_active_controller) if (!joy_active_controller)
return; return;
if (cl.paused || key_dest != key_game)
return;
moveRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX]; moveRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX];
moveRaw.y = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY]; moveRaw.y = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY];
@ -717,6 +720,10 @@ void IN_MouseMove(usercmd_t *cmd)
total_dx = 0; total_dx = 0;
total_dy = 0; total_dy = 0;
// do pause check after resetting total_d* so mouse movements during pause don't accumulate
if (cl.paused || key_dest != key_game)
return;
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) )) if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) ))
cmd->sidemove += m_side.value * dmx; cmd->sidemove += m_side.value * dmx;
else else