code: plan9front

Download patch

ref: 02ec9f06e426c6b19d4d9368dbe959845aef6928
parent: 846debd082dcb0ac7b0297c6d68a0aa382f95de5
author: qwx <qwx@sciops.net>
date: Mon Aug 22 18:13:57 EDT 2022

games/doom: fix glitchy mouse movement

use all mouse deltas during a tic instead of just the last one, to
prevent extremely annoying stutters and jumps in mouse movement;
adjust filtering/sensitivity, without additional knobs

--- a/sys/src/games/doom/g_game.c
+++ b/sys/src/games/doom/g_game.c
@@ -508,8 +508,8 @@
 	mousebuttons[0] = ev->data1 & 1; 
 	mousebuttons[1] = ev->data1 & 2; 
 	mousebuttons[2] = ev->data1 & 4; 
-	mousex = ev->data2*(mouseSensitivity+5)/10; 
-	mousey = ev->data3*(mouseSensitivity+5)/10; 
+	mousex += ev->data2*0.5*(mouseSensitivity+1); 
+	mousey += ev->data3*0.5*(mouseSensitivity+1); 
 	return true;    // eat events 
  
       case ev_joystick: 
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -395,8 +395,8 @@
 			
 			e.type = ev_mouse;
 			e.data1 = m.buttons;
-			e.data2 = 10*(m.xy.x - om.xy.x);
-			e.data3 = 10*(om.xy.y - m.xy.y);
+			e.data2 = m.xy.x - om.xy.x;
+			e.data3 = om.xy.y - m.xy.y;
 			D_PostEvent(&e);
 			om = m;
 
--- a/sys/src/games/doom/m_menu.c
+++ b/sys/src/games/doom/m_menu.c
@@ -945,7 +945,7 @@
 		       W_CacheLumpName(msgNames[showMessages],PU_CACHE));
 
     M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1),
-		 10,mouseSensitivity);
+		 9,mouseSensitivity);
 	
     M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),
 		 9,screenSize);
@@ -1099,7 +1099,7 @@
 	    mouseSensitivity--;
 	break;
       case 1:
-	if (mouseSensitivity < 9)
+	if (mouseSensitivity < 8)
 	    mouseSensitivity++;
 	break;
     }