shithub: riscv

Download patch

ref: 418131d326ab033789a25c0c5cddd5aa776e8f27
parent: 21ae833386940c7414ecaaf1012c0ec87f0088e5
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Aug 19 12:48:02 EDT 2022

games/doom: add "m_forward" cvar to disable vertical motion move; actually implement use_mouse

--- a/sys/src/games/doom/g_game.c
+++ b/sys/src/games/doom/g_game.c
@@ -157,6 +157,7 @@
 int             mousebfire; 
 int             mousebstrafe; 
 int             mousebforward; 
+int             m_forward;
  
 int             joybfire; 
 int             joybstrafe; 
@@ -186,6 +187,7 @@
 // mouse values are used once 
 int             mousex;
 int		mousey;         
+extern int usemouse;
 
 int             dclicktime;
 int		dclickstate;
@@ -399,7 +401,8 @@
 	} 
     } 
  
-    forward += mousey; 
+    if (m_forward)
+        forward += mousey; 
     if (strafe) 
 	side += mousex*2; 
     else 
@@ -563,6 +566,8 @@
 	return false;   // always let key up events filter down 
 		 
       case ev_mouse: 
+	if (!usemouse)
+	    return true;
 	mousebuttons[0] = ev->data1 & 1; 
 	mousebuttons[1] = ev->data1 & 2; 
 	mousebuttons[2] = ev->data1 & 4; 
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -11,6 +11,7 @@
 
 static int resized;
 static int mouseactive;
+extern int usemouse;
 
 static Rectangle grabout;
 static Point center;
@@ -160,7 +161,7 @@
 	static char nocurs[2*4+2*2*16];
 	static int fd = -1;
 
-	if(mouseactive == on)
+	if(mouseactive == on || !usemouse)
 		return;
 	if(mouseactive = on){
 		if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0)
--- a/sys/src/games/doom/m_misc.c
+++ b/sys/src/games/doom/m_misc.c
@@ -163,6 +163,7 @@
 extern int	mousebfire;
 extern int	mousebstrafe;
 extern int	mousebforward;
+extern int  m_forward;
 
 extern int	joybfire;
 extern int	joybstrafe;
@@ -218,6 +219,7 @@
     {"mouseb_fire",&mousebfire,0},
     {"mouseb_strafe",&mousebstrafe,1},
     {"mouseb_forward",&mousebforward,2},
+    {"m_forward",&m_forward, 1},
 
     {"use_joystick",&usejoystick, 0},
     {"joyb_fire",&joybfire,0},