shithub: choc

Download patch

ref: 74773f9a5bc7cbeb3e7807ce28229a7644416cd2
parent: e55356d93a1408ca9db9a8cc57ec243f9fc8f99a
parent: a46521d80d704dc4401a3a222b575a1a47021570
author: Simon Howard <fraggle@soulsphere.org>
date: Fri Apr 9 07:33:47 EDT 2021

Merge pull request #1366 from chocolate-doom/mouse_left_right

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; 
@@ -367,12 +369,12 @@
     // let movement keys cancel each other out
     if (strafe) 
     { 
-	if (gamekeydown[key_right]) 
+	if (gamekeydown[key_right] || mousebuttons[mousebturnright])
 	{
 	    // fprintf(stderr, "strafe right\n");
 	    side += sidemove[speed]; 
 	}
-	if (gamekeydown[key_left]) 
+	if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
 	{
 	    //	fprintf(stderr, "strafe left\n");
 	    side -= sidemove[speed]; 
@@ -385,9 +387,9 @@
     } 
     else 
     { 
-	if (gamekeydown[key_right]) 
+	if (gamekeydown[key_right] || mousebuttons[mousebturnright])
 	    cmd->angleturn -= angleturn[tspeed]; 
-	if (gamekeydown[key_left]) 
+	if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
 	    cmd->angleturn += angleturn[tspeed]; 
 	if (joyxmove > 0) 
 	    cmd->angleturn -= angleturn[tspeed]; 
--- 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;
@@ -351,9 +352,9 @@
 //
     if (strafe)
     {
-        if (gamekeydown[key_right])
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
             side += sidemove[speed];
-        if (gamekeydown[key_left])
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
             side -= sidemove[speed];
         if (joyxmove > 0)
             side += sidemove[speed];
@@ -362,9 +363,9 @@
     }
     else
     {
-        if (gamekeydown[key_right])
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
             cmd->angleturn -= angleturn[tspeed];
-        if (gamekeydown[key_left])
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
             cmd->angleturn += angleturn[tspeed];
         if (joyxmove > 0)
             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;
@@ -269,11 +270,11 @@
 //
     if (strafe)
     {
-        if (gamekeydown[key_right])
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
         {
             side += sidemove[pClass][speed];
         }
-        if (gamekeydown[key_left])
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
         {
             side -= sidemove[pClass][speed];
         }
@@ -288,9 +289,9 @@
     }
     else
     {
-        if (gamekeydown[key_right])
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
             cmd->angleturn -= angleturn[tspeed];
-        if (gamekeydown[key_left])
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
             cmd->angleturn += angleturn[tspeed];
         if (joyxmove > 0)
             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))
--- 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; 
@@ -418,12 +420,12 @@
     // let movement keys cancel each other out
     if (strafe) 
     { 
-        if (gamekeydown[key_right]) 
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
         {
             // fprintf(stderr, "strafe right\n");
             side += sidemove[speed]; 
         }
-        if (gamekeydown[key_left]) 
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
         {
             //	fprintf(stderr, "strafe left\n");
             side -= sidemove[speed]; 
@@ -436,9 +438,9 @@
     } 
     else 
     { 
-        if (gamekeydown[key_right]) 
+        if (gamekeydown[key_right] || mousebuttons[mousebturnright])
             cmd->angleturn -= angleturn[tspeed]; 
-        if (gamekeydown[key_left]) 
+        if (gamekeydown[key_left] || mousebuttons[mousebturnleft])
             cmd->angleturn += angleturn[tspeed]; 
         if (joyxmove > 0) 
             cmd->angleturn -= angleturn[tspeed];