Skip to content

Commit

Permalink
- generalized the special key handling for skipping cutscenes.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Apr 20, 2021
1 parent 0c5729b commit 9e40e49
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
11 changes: 11 additions & 0 deletions source/core/inputstate.h
Expand Up @@ -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;
}

12 changes: 4 additions & 8 deletions source/core/screenjob.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -230,6 +225,7 @@ class ScreenJobRunner
}

if (jobs[index].job->state != DScreenJob::running) return false;

return jobs[index].job->OnEvent(ev);
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/2d_d.cpp
Expand Up @@ -858,7 +858,7 @@ class DDukeLevelSummaryScreen : public DScreenJob

bool OnEvent(event_t* ev) override
{
if (ev->type == EV_KeyDown)
if (ev->type == EV_KeyDown && !specialKeyEvent(ev))
{
if ((displaystate & printStatsAll) != printStatsAll)
{
Expand Down
2 changes: 1 addition & 1 deletion source/games/duke/src/2d_r.cpp
Expand Up @@ -400,7 +400,7 @@ class DRRLevelSummaryScreen : public DScreenJob

bool OnEvent(event_t* ev) override
{
if (ev->type == EV_KeyDown)
if (ev->type == EV_KeyDown && !specialKeyEvent(ev))
{
if ((displaystate & printStatsAll) != printStatsAll)
{
Expand Down
6 changes: 3 additions & 3 deletions source/games/exhumed/src/2d.cpp
Expand Up @@ -808,7 +808,7 @@ class DMapScreen : public DScreenJob
}
return true;
}
state = skipped;
if (!specialKeyEvent(ev)) state = skipped;
return true;
}
return false;
Expand Down Expand Up @@ -1163,7 +1163,7 @@ class DLastLevelCinema : public DScreenJob

bool OnEvent(event_t* ev)
{
if (ev->type == EV_KeyDown) skiprequest = true;
if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true;
return true;
}

Expand Down Expand Up @@ -1278,7 +1278,7 @@ class DExCredits : public DScreenJob

bool OnEvent(event_t* ev)
{
if (ev->type == EV_KeyDown) skiprequest = true;
if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/2d.cpp
Expand Up @@ -389,7 +389,7 @@ class DSWLevelSummaryScreen : public DScreenJob

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)])
{
Expand Down

0 comments on commit 9e40e49

Please sign in to comment.