From ba920ffdab723b5ae7175d528fbca476850b7cbf Mon Sep 17 00:00:00 2001 From: Noseey Date: Fri, 22 Nov 2024 00:57:07 +0100 Subject: [PATCH] =?UTF-8?q?180=C2=B0=20Turn=20only=20once=20per=20button?= =?UTF-8?q?=20press?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced state variable to only allow a 180° Turn once per button press (either mouse or keyboard). This improves the useability when binding it to a mouse key. --- src/doom/g_game.c | 13 ++++++++++--- src/heretic/g_game.c | 13 ++++++++++--- src/hexen/g_game.c | 13 ++++++++++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/doom/g_game.c b/src/doom/g_game.c index 66a81e6ff..9a8af8854 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -445,6 +445,7 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic) int look; player_t *const player = &players[consoleplayer]; static char playermessage[48]; + static boolean keyrevstate = false; // [crispy] // [crispy] For fast polling. G_PrepTiccmd(); @@ -506,9 +507,15 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - angle += ANG180 >> FRACBITS; - gamekeydown[key_reverse] = false; - mousebuttons[mousebreverse] = false; + if(!keyrevstate) + { + angle += ANG180 >> FRACBITS; + keyrevstate = true; + } + } + else + { + keyrevstate = false; } // [crispy] toggle "always run" diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 14f8c6794..c42fa3c33 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -405,6 +405,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) static unsigned int mbmlookctrl = 0; // [crispy] static unsigned int kbdlookctrl = 0; // [crispy] + static boolean keyrevstate = false; // [crispy] // haleyjd: removed externdriver crap @@ -466,9 +467,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - angle += ANG180 >> FRACBITS; - gamekeydown[key_reverse] = false; - mousebuttons[mousebreverse] = false; + if(!keyrevstate) + { + angle += ANG180 >> FRACBITS; + keyrevstate = true; + } + } + else + { + keyrevstate = false; } // [crispy] toggle "always run" diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index 8d59e4df0..fa8b03226 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -299,6 +299,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) static unsigned int mbmlookctrl = 0; // [crispy] static unsigned int kbdlookctrl = 0; // [crispy] + static boolean keyrevstate = false; // [crispy] // haleyjd: removed externdriver crap @@ -364,9 +365,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - angle += ANG180 >> FRACBITS; - gamekeydown[key_reverse] = false; - mousebuttons[mousebreverse] = false; + if(!keyrevstate) + { + angle += ANG180 >> FRACBITS; + keyrevstate = true; + } + } + else + { + keyrevstate = false; } // [crispy] toggle "always run"