- generalized the special key handling for skipping cutscenes.

This commit is contained in:
Christoph Oelckers 2021-04-20 15:01:26 +02:00
parent 0c5729b0f6
commit 9e40e49c2c
6 changed files with 21 additions and 14 deletions

View file

@ -126,3 +126,14 @@ inline void resetForcedSyncInput()
{ {
gamesetinput = false; 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;
}

View file

@ -59,16 +59,11 @@ IMPLEMENT_CLASS(DImageScreen, true, false)
bool DSkippableScreenJob::OnEvent(event_t* evt) 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; state = skipped;
Skipped(); Skipped();
} }
}
return true; return true;
} }
@ -230,6 +225,7 @@ public:
} }
if (jobs[index].job->state != DScreenJob::running) return false; if (jobs[index].job->state != DScreenJob::running) return false;
return jobs[index].job->OnEvent(ev); return jobs[index].job->OnEvent(ev);
} }

View file

@ -858,7 +858,7 @@ public:
bool OnEvent(event_t* ev) override bool OnEvent(event_t* ev) override
{ {
if (ev->type == EV_KeyDown) if (ev->type == EV_KeyDown && !specialKeyEvent(ev))
{ {
if ((displaystate & printStatsAll) != printStatsAll) if ((displaystate & printStatsAll) != printStatsAll)
{ {

View file

@ -400,7 +400,7 @@ public:
bool OnEvent(event_t* ev) override bool OnEvent(event_t* ev) override
{ {
if (ev->type == EV_KeyDown) if (ev->type == EV_KeyDown && !specialKeyEvent(ev))
{ {
if ((displaystate & printStatsAll) != printStatsAll) if ((displaystate & printStatsAll) != printStatsAll)
{ {

View file

@ -808,7 +808,7 @@ public:
} }
return true; return true;
} }
state = skipped; if (!specialKeyEvent(ev)) state = skipped;
return true; return true;
} }
return false; return false;
@ -1163,7 +1163,7 @@ private:
bool OnEvent(event_t* ev) bool OnEvent(event_t* ev)
{ {
if (ev->type == EV_KeyDown) skiprequest = true; if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true;
return true; return true;
} }
@ -1278,7 +1278,7 @@ public:
bool OnEvent(event_t* ev) bool OnEvent(event_t* ev)
{ {
if (ev->type == EV_KeyDown) skiprequest = true; if (ev->type == EV_KeyDown && !specialKeyEvent(ev)) skiprequest = true;
return true; return true;
} }

View file

@ -389,7 +389,7 @@ private:
bool OnEvent(event_t* ev) override 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)]) if (State >= s_BonusRest && State < &s_BonusRest[countof(s_BonusRest)])
{ {