From e9906c633afe69a5c9e3598f9d46a568c75267b0 Mon Sep 17 00:00:00 2001 From: Noseey Date: Thu, 21 Nov 2024 23:10:50 +0100 Subject: [PATCH 1/3] Adding Quick-Reverse Key and Mouse for Hexen and Heretic Adding Quick-Reverse Key and Mouse Input for Hexen and Heretic by copying the implementation from Doom. --- src/heretic/g_game.c | 8 ++++++++ src/hexen/g_game.c | 8 ++++++++ src/m_config.c | 4 ++-- src/setup/keyboard.c | 1 + src/setup/mouse.c | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 75c8d18601..14f8c67945 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -463,6 +463,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) lspeed = 2; } + // [crispy] add quick 180° reverse + if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) + { + angle += ANG180 >> FRACBITS; + gamekeydown[key_reverse] = false; + mousebuttons[mousebreverse] = false; + } + // [crispy] toggle "always run" if (gamekeydown[key_toggleautorun]) { diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index 6adb44f461..8d59e4df0c 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -361,6 +361,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) lspeed = 2; // 5; } + // [crispy] add quick 180° reverse + if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) + { + angle += ANG180 >> FRACBITS; + gamekeydown[key_reverse] = false; + mousebuttons[mousebreverse] = false; + } + // [crispy] toggle "always run" if (gamekeydown[key_toggleautorun]) { diff --git a/src/m_config.c b/src/m_config.c index 1bdff289b5..698e213355 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -508,7 +508,7 @@ static default_t doom_defaults_list[] = CONFIG_VARIABLE_INT(mouseb_mouselook), //! - // @game doom + // @game doom heretic hexen // // Quick 180° reverse. // @@ -2251,7 +2251,7 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_KEY(key_multi_msgplayer8), //! - // @game doom + // @game doom heretic hexen // Quick 180° reverse. // diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 88b0525c16..32e2cd49e5 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -246,6 +246,7 @@ static void ConfigExtraKeys(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) AddKeyControl(table, "Strafe Right (alt.)", &key_alt_straferight); AddKeyControl(table, "Toggle always run", &key_toggleautorun); AddKeyControl(table, "Toggle vert. mouse", &key_togglenovert); + AddKeyControl(table, "Quick Reverse", &key_reverse); } if (gamemission == heretic || gamemission == hexen) diff --git a/src/setup/mouse.c b/src/setup/mouse.c index 9dfdc5c73c..6fbdc0393d 100644 --- a/src/setup/mouse.c +++ b/src/setup/mouse.c @@ -160,6 +160,7 @@ static void ConfigExtraButtons(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) if (gamemission == heretic || gamemission == hexen) { + AddMouseControl(buttons_table, "Quick Reverse", &mousebreverse); AddMouseControl(buttons_table, "Mouselook", &mousebmouselook); AddMouseControl(buttons_table, "Inventory left", &mousebinvleft); AddMouseControl(buttons_table, "Inventory right", &mousebinvright); From ba920ffdab723b5ae7175d528fbca476850b7cbf Mon Sep 17 00:00:00 2001 From: Noseey Date: Fri, 22 Nov 2024 00:57:07 +0100 Subject: [PATCH 2/3] =?UTF-8?q?180=C2=B0=20Turn=20only=20once=20per=20butt?= =?UTF-8?q?on=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 66a81e6ffd..9a8af88540 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 14f8c67945..c42fa3c33d 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 8d59e4df0c..fa8b03226b 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" From 40081f8b4411cef04a6b3f5d97337c70eea9c553 Mon Sep 17 00:00:00 2001 From: Noseey Date: Sat, 23 Nov 2024 12:54:23 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"180=C2=B0=20Turn=20only=20once=20?= =?UTF-8?q?per=20button=20press"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ba920ffdab723b5ae7175d528fbca476850b7cbf. --- src/doom/g_game.c | 13 +++---------- src/heretic/g_game.c | 13 +++---------- src/hexen/g_game.c | 13 +++---------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/doom/g_game.c b/src/doom/g_game.c index 9a8af88540..66a81e6ffd 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -445,7 +445,6 @@ 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(); @@ -507,15 +506,9 @@ void G_BuildTiccmd (ticcmd_t* cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - if(!keyrevstate) - { - angle += ANG180 >> FRACBITS; - keyrevstate = true; - } - } - else - { - keyrevstate = false; + angle += ANG180 >> FRACBITS; + gamekeydown[key_reverse] = false; + mousebuttons[mousebreverse] = false; } // [crispy] toggle "always run" diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index c42fa3c33d..14f8c67945 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -405,7 +405,6 @@ 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 @@ -467,15 +466,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - if(!keyrevstate) - { - angle += ANG180 >> FRACBITS; - keyrevstate = true; - } - } - else - { - keyrevstate = false; + angle += ANG180 >> FRACBITS; + gamekeydown[key_reverse] = false; + mousebuttons[mousebreverse] = false; } // [crispy] toggle "always run" diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index fa8b03226b..8d59e4df0c 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -299,7 +299,6 @@ 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 @@ -365,15 +364,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, int maketic) // [crispy] add quick 180° reverse if (gamekeydown[key_reverse] || mousebuttons[mousebreverse]) { - if(!keyrevstate) - { - angle += ANG180 >> FRACBITS; - keyrevstate = true; - } - } - else - { - keyrevstate = false; + angle += ANG180 >> FRACBITS; + gamekeydown[key_reverse] = false; + mousebuttons[mousebreverse] = false; } // [crispy] toggle "always run"