shithub: choc

Download patch

ref: 331aed42b4490388d0d60867a731b7b7e63e8f3e
parent: 5b967edaf6e407b03455631734ee2e33e88304c8
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue Apr 6 07:25:59 EDT 2021

add mouse button bindings for turning left/right

--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -354,7 +354,9 @@
     if (joyxmove < 0
 	|| joyxmove > 0  
 	|| gamekeydown[key_right]
-	|| gamekeydown[key_left]) 
+	|| gamekeydown[key_left]
+	|| mousebuttons[mousebturnright]
+	|| mousebuttons[mousebturnleft])
 	turnheld += ticdup; 
     else 
 	turnheld = 0; 
@@ -381,6 +383,10 @@
 	    side += sidemove[speed]; 
 	if (joyxmove < 0) 
 	    side -= sidemove[speed]; 
+	if (mousebuttons[mousebturnright])
+	    side += sidemove[speed];
+	if (mousebuttons[mousebturnleft])
+	    side -= sidemove[speed];
  
     } 
     else 
@@ -393,6 +399,10 @@
 	    cmd->angleturn -= angleturn[tspeed]; 
 	if (joyxmove < 0) 
 	    cmd->angleturn += angleturn[tspeed]; 
+	if (mousebuttons[mousebturnright])
+	    cmd->angleturn -= angleturn[tspeed];
+	if (mousebuttons[mousebturnleft])
+	    cmd->angleturn += angleturn[tspeed];
     } 
  
     if (gamekeydown[key_up]) 
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -320,7 +320,8 @@
 // use two stage accelerative turning on the keyboard and joystick
 //
     if (joyxmove < 0 || joyxmove > 0
-        || gamekeydown[key_right] || gamekeydown[key_left])
+        || gamekeydown[key_right] || gamekeydown[key_left]
+        || mousebuttons[mousebturnright] || mousebuttons[mousebturnleft])
         turnheld += ticdup;
     else
         turnheld = 0;
@@ -359,6 +360,10 @@
             side += sidemove[speed];
         if (joyxmove < 0)
             side -= sidemove[speed];
+        if (mousebuttons[mousebturnright])
+            side += sidemove[speed];
+        if (mousebuttons[mousebturnleft])
+            side -= sidemove[speed];
     }
     else
     {
@@ -369,6 +374,10 @@
         if (joyxmove > 0)
             cmd->angleturn -= angleturn[tspeed];
         if (joyxmove < 0)
+            cmd->angleturn += angleturn[tspeed];
+        if (mousebuttons[mousebturnright])
+            cmd->angleturn -= angleturn[tspeed];
+        if (mousebuttons[mousebturnleft])
             cmd->angleturn += angleturn[tspeed];
     }
 
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -238,7 +238,8 @@
 // use two stage accelerative turning on the keyboard and joystick
 //
     if (joyxmove < 0 || joyxmove > 0
-        || gamekeydown[key_right] || gamekeydown[key_left])
+        || gamekeydown[key_right] || gamekeydown[key_left]
+        || mousebuttons[mousebturnright] || mousebuttons[mousebturnleft])
         turnheld += ticdup;
     else
         turnheld = 0;
@@ -285,6 +286,14 @@
         {
             side -= sidemove[pClass][speed];
         }
+        if (mousebuttons[mousebturnright])
+        {
+            side += sidemove[pClass][speed];
+        }
+        if (mousebuttons[mousebturnleft])
+        {
+            side -= sidemove[pClass][speed];
+        }
     }
     else
     {
@@ -295,6 +304,10 @@
         if (joyxmove > 0)
             cmd->angleturn -= angleturn[tspeed];
         if (joyxmove < 0)
+            cmd->angleturn += angleturn[tspeed];
+        if (mousebuttons[mousebturnright])
+            cmd->angleturn -= angleturn[tspeed];
+        if (mousebuttons[mousebturnleft])
             cmd->angleturn += angleturn[tspeed];
     }
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1033,6 +1033,18 @@
     CONFIG_VARIABLE_INT(mouseb_straferight),
 
     //!
+    // Mouse button to turn left.
+    //
+
+    CONFIG_VARIABLE_INT(mouseb_turnleft),
+
+    //!
+    // Mouse button to turn right.
+    //
+
+    CONFIG_VARIABLE_INT(mouseb_turnright),
+
+    //!
     // Mouse button to "use" an object, eg. a door or switch.
     //
 
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -112,6 +112,8 @@
 
 int mousebstrafeleft = -1;
 int mousebstraferight = -1;
+int mousebturnleft = -1;
+int mousebturnright = -1;
 int mousebbackward = -1;
 int mousebuse = -1;
 
@@ -246,6 +248,8 @@
     M_BindIntVariable("joyb_straferight",    &joybstraferight);
     M_BindIntVariable("mouseb_strafeleft",   &mousebstrafeleft);
     M_BindIntVariable("mouseb_straferight",  &mousebstraferight);
+    M_BindIntVariable("mouseb_turnleft",     &mousebturnleft);
+    M_BindIntVariable("mouseb_turnright",    &mousebturnright);
     M_BindIntVariable("mouseb_use",          &mousebuse);
     M_BindIntVariable("mouseb_backward",     &mousebbackward);
     M_BindIntVariable("dclick_use",          &dclick_use);
--- a/src/m_controls.h
+++ b/src/m_controls.h
@@ -141,6 +141,8 @@
 
 extern int mousebstrafeleft;
 extern int mousebstraferight;
+extern int mousebturnleft;
+extern int mousebturnright;
 extern int mousebbackward;
 extern int mousebuse;
 
--- a/src/setup/mouse.c
+++ b/src/setup/mouse.c
@@ -48,7 +48,9 @@
     &mousebprevweapon,
     &mousebnextweapon,
     &mousebinvleft,
-    &mousebinvright
+    &mousebinvright,
+    &mousebturnleft,
+    &mousebturnright,
 };
 
 static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
@@ -102,8 +104,10 @@
     AddMouseControl(buttons_table, "Move backward", &mousebbackward);
     AddMouseControl(buttons_table, "Strafe right", &mousebstraferight);
     AddMouseControl(buttons_table, "Previous weapon", &mousebprevweapon);
-    AddMouseControl(buttons_table, "Strafe on", &mousebstrafe);
+    AddMouseControl(buttons_table, "Turn left", &mousebturnright);
     AddMouseControl(buttons_table, "Next weapon", &mousebnextweapon);
+    AddMouseControl(buttons_table, "Turn right", &mousebturnright);
+    AddMouseControl(buttons_table, "Strafe on", &mousebstrafe);
     
     if (gamemission == heretic)
     {
--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -405,7 +405,9 @@
     if (joyxmove < 0
         || joyxmove > 0  
         || gamekeydown[key_right]
-        || gamekeydown[key_left]) 
+        || gamekeydown[key_left]
+        || mousebuttons[mousebturnright]
+        || mousebuttons[mousebturnleft])
         turnheld += ticdup; 
     else 
         turnheld = 0; 
@@ -432,6 +434,10 @@
             side += sidemove[speed]; 
         if (joyxmove < 0) 
             side -= sidemove[speed]; 
+        if (mousebuttons[mousebturnright])
+            side += sidemove[speed];
+        if (mousebuttons[mousebturnleft])
+            side -= sidemove[speed];
 
     } 
     else 
@@ -444,6 +450,10 @@
             cmd->angleturn -= angleturn[tspeed]; 
         if (joyxmove < 0) 
             cmd->angleturn += angleturn[tspeed]; 
+        if (mousebuttons[mousebturnright])
+            cmd->angleturn -= angleturn[tspeed];
+        if (mousebuttons[mousebturnleft])
+            cmd->angleturn += angleturn[tspeed];
     } 
 
     if (gamekeydown[key_up])