From e75448b56cdf9edae0e30da18ea5e26b390cdd1a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 18 Dec 2022 12:56:34 +0100 Subject: [PATCH] - fixed ESC pressing on Duke's monitors. This got busted by an update from GZDoom. --- source/common/engine/d_event.cpp | 16 +++++++++------- source/common/engine/i_interface.h | 1 + source/core/gamecontrol.cpp | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/source/common/engine/d_event.cpp b/source/common/engine/d_event.cpp index b64aa6365..130c65622 100644 --- a/source/common/engine/d_event.cpp +++ b/source/common/engine/d_event.cpp @@ -44,8 +44,6 @@ #include "gamestate.h" #include "i_interface.h" -bool G_Responder(event_t* ev); - int eventhead; int eventtail; event_t events[MAXEVENTS]; @@ -86,12 +84,16 @@ void D_ProcessEvents (void) if (ev->type == EV_DeviceChange) UpdateJoystickMenu(I_UpdateDeviceList()); - if (gamestate != GS_INTRO) // GS_INTRO blocks the UI. + // allow the game to intercept Escape before dispatching it. + if (ev->type != EV_KeyDown || ev->data1 != KEY_ESCAPE || !sysCallbacks.WantEscape()) { - if (C_Responder(ev)) - continue; // console ate the event - if (M_Responder(ev)) - continue; // menu ate the event + if (gamestate != GS_INTRO) // GS_INTRO blocks the UI. + { + if (C_Responder(ev)) + continue; // console ate the event + if (M_Responder(ev)) + continue; // menu ate the event + } } if (sysCallbacks.G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1); diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index c391e21dc..48cd2b95d 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -46,6 +46,7 @@ struct SystemCallbacks void (*LanguageChanged)(const char*); bool (*OkForLocalization)(FTextureID, const char*); FConfigFile* (*GetConfig)(); + bool (*WantEscape)(); }; extern SystemCallbacks sysCallbacks; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 84753d9d4..4c1cc9fd5 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -543,6 +543,11 @@ static void System_SetTransition(int type) nextwipe = type; } +bool WantEscape() +{ + return gi->WantEscape(); +} + void I_StartupJoysticks(); @@ -592,6 +597,7 @@ int GameMain() nullptr, nullptr, []() ->FConfigFile* { return GameConfig; }, + WantEscape, }; try