From 9e40e49c2cb026f6871b3df8bbfacd25ab2eb765 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 Apr 2021 15:01:26 +0200 Subject: [PATCH] - generalized the special key handling for skipping cutscenes. --- source/core/inputstate.h | 11 +++++++++++ source/core/screenjob.cpp | 12 ++++-------- source/games/duke/src/2d_d.cpp | 2 +- source/games/duke/src/2d_r.cpp | 2 +- source/games/exhumed/src/2d.cpp | 6 +++--- source/games/sw/src/2d.cpp | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/source/core/inputstate.h b/source/core/inputstate.h index 01996f41a..dd457046e 100644 --- a/source/core/inputstate.h +++ b/source/core/inputstate.h @@ -126,3 +126,14 @@ inline void resetForcedSyncInput() { gamesetinput = false; } + +inline bool specialKeyEvent(event_t* ev) +{ + if (ev->type == EV_KeyDown || ev->type == EV_KeyUp) + { + int key = ev->data1; + if (key == KEY_VOLUMEDOWN || key == KEY_VOLUMEUP || (key > KEY_LASTJOYBUTTON && key < KEY_PAD_LTHUMB_RIGHT)) return true; + } + return false; +} + diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 87cd92b79..f2417dc5b 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -59,15 +59,10 @@ IMPLEMENT_CLASS(DImageScreen, true, false) bool DSkippableScreenJob::OnEvent(event_t* evt) { - if (evt->type == EV_KeyDown) + if (evt->type == EV_KeyDown && !specialKeyEvent(evt)) { - auto& key = evt->data1; - bool ignoredkeys = key == KEY_VOLUMEDOWN || key == KEY_VOLUMEUP || (key > KEY_LASTJOYBUTTON && key < KEY_PAD_LTHUMB_RIGHT); - if (!ignoredkeys) - { - state = skipped; - Skipped(); - } + state = skipped; + Skipped(); } return true; } @@ -230,6 +225,7 @@ public: } if (jobs[index].job->state != DScreenJob::running) return false; + return jobs[index].job->OnEvent(ev); } diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 34e6d8a97..c26c7ad14 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -858,7 +858,7 @@ public: bool OnEvent(event_t* ev) override { - if (ev->type == EV_KeyDown) + if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) { if ((displaystate & printStatsAll) != printStatsAll) { diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index caf2440a5..25d52ac8a 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -400,7 +400,7 @@ public: bool OnEvent(event_t* ev) override { - if (ev->type == EV_KeyDown) + if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) { if ((displaystate & printStatsAll) != printStatsAll) { diff --git a/source/games/exhumed/src/2d.cpp b/source/games/exhumed/src/2d.cpp index 8606ab507..2acd24315 100644 --- a/source/games/exhumed/src/2d.cpp +++ b/source/games/exhumed/src/2d.cpp @@ -808,7 +808,7 @@ public: } return true; } - state = skipped; + if (!specialKeyEvent(ev)) state = skipped; return true; } return false; @@ -1163,7 +1163,7 @@ private: bool OnEvent(event_t* ev) { - if (ev->type == EV_KeyDown) skiprequest = true; + if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true; return true; } @@ -1278,7 +1278,7 @@ public: bool OnEvent(event_t* ev) { - if (ev->type == EV_KeyDown) skiprequest = true; + if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true; return true; } diff --git a/source/games/sw/src/2d.cpp b/source/games/sw/src/2d.cpp index ce85b1bbf..9c982f0c6 100644 --- a/source/games/sw/src/2d.cpp +++ b/source/games/sw/src/2d.cpp @@ -389,7 +389,7 @@ private: bool OnEvent(event_t* ev) override { - if (ev->type == EV_KeyDown) + if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) { if (State >= s_BonusRest && State < &s_BonusRest[countof(s_BonusRest)]) {