From 80701927e89a31c10b94e2fba27a6f75586d15e1 Mon Sep 17 00:00:00 2001
From: Leonard2 <hobbax3@gmail.com>
Date: Wed, 11 Oct 2017 17:22:22 +0200
Subject: [PATCH] Fixed: don't interpolate view movements if a key press didn't
 result in any changes.

---
 src/d_main.cpp |  4 ++--
 src/g_game.cpp | 14 ++++----------
 src/g_game.h   |  4 ++--
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/d_main.cpp b/src/d_main.cpp
index 923d510ec..90dbb99b4 100644
--- a/src/d_main.cpp
+++ b/src/d_main.cpp
@@ -328,12 +328,12 @@ void D_PostEvent (const event_t *ev)
 			int look = int(ev->y * m_pitch * mouse_sensitivity * 16.0);
 			if (invertmouse)
 				look = -look;
-			G_AddViewPitch (look);
+			G_AddViewPitch (look, true);
 			events[eventhead].y = 0;
 		}
 		if (!Button_Strafe.bDown && !lookstrafe)
 		{
-			G_AddViewAngle (int(ev->x * m_yaw * mouse_sensitivity * 8.0));
+			G_AddViewAngle (int(ev->x * m_yaw * mouse_sensitivity * 8.0), true);
 			events[eventhead].x = 0;
 		}
 		if ((events[eventhead].x | events[eventhead].y) == 0)
diff --git a/src/g_game.cpp b/src/g_game.cpp
index d3dd47f46..584cddfa1 100644
--- a/src/g_game.cpp
+++ b/src/g_game.cpp
@@ -608,24 +608,20 @@ void G_BuildTiccmd (ticcmd_t *cmd)
 		if (Button_Right.bDown)
 		{
 			G_AddViewAngle (angleturn[tspeed]);
-			LocalKeyboardTurner = true;
 		}
 		if (Button_Left.bDown)
 		{
 			G_AddViewAngle (-angleturn[tspeed]);
-			LocalKeyboardTurner = true;
 		}
 	}
 
 	if (Button_LookUp.bDown)
 	{
 		G_AddViewPitch (lookspeed[speed]);
-		LocalKeyboardTurner = true;
 	}
 	if (Button_LookDown.bDown)
 	{
 		G_AddViewPitch (-lookspeed[speed]);
-		LocalKeyboardTurner = true;
 	}
 
 	if (Button_MoveUp.bDown)
@@ -701,12 +697,10 @@ void G_BuildTiccmd (ticcmd_t *cmd)
 	if (joyaxes[JOYAXIS_Pitch] != 0)
 	{
 		G_AddViewPitch(joyint(joyaxes[JOYAXIS_Pitch] * 2048));
-		LocalKeyboardTurner = true;
 	}
 	if (joyaxes[JOYAXIS_Yaw] != 0)
 	{
 		G_AddViewAngle(joyint(-1280 * joyaxes[JOYAXIS_Yaw]));
-		LocalKeyboardTurner = true;
 	}
 
 	side -= joyint(sidemove[speed] * joyaxes[JOYAXIS_Side]);
@@ -794,7 +788,7 @@ void G_BuildTiccmd (ticcmd_t *cmd)
 //[Graf Zahl] This really helps if the mouse update rate can't be increased!
 CVAR (Bool,		smooth_mouse,	false,	CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
 
-void G_AddViewPitch (int look)
+void G_AddViewPitch (int look, bool mouse)
 {
 	if (gamestate == GS_TITLELEVEL)
 	{
@@ -837,11 +831,11 @@ void G_AddViewPitch (int look)
 	}
 	if (look != 0)
 	{
-		LocalKeyboardTurner = smooth_mouse;
+		LocalKeyboardTurner = (!mouse || smooth_mouse);
 	}
 }
 
-void G_AddViewAngle (int yaw)
+void G_AddViewAngle (int yaw, bool mouse)
 {
 	if (gamestate == GS_TITLELEVEL)
 	{
@@ -857,7 +851,7 @@ void G_AddViewAngle (int yaw)
 	LocalViewAngle -= yaw;
 	if (yaw != 0)
 	{
-		LocalKeyboardTurner = smooth_mouse;
+		LocalKeyboardTurner = (!mouse || smooth_mouse);
 	}
 }
 
diff --git a/src/g_game.h b/src/g_game.h
index 3a11e31f2..2ac019059 100644
--- a/src/g_game.h
+++ b/src/g_game.h
@@ -89,10 +89,10 @@ void G_DoReborn (int playernum, bool freshbot);
 void G_DoPlayerPop(int playernum);
 
 // Adds pitch to consoleplayer's viewpitch and clamps it
-void G_AddViewPitch (int look);
+void G_AddViewPitch (int look, bool mouse = false);
 
 // Adds to consoleplayer's viewangle if allowed
-void G_AddViewAngle (int yaw);
+void G_AddViewAngle (int yaw, bool mouse = false);
 
 #define BODYQUESIZE 	32
 class AActor;