From 8bb13bc4c25e21d94b095c42a12b0750399f2505 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 27 Aug 2020 17:29:40 +1000 Subject: [PATCH] - InputState: Exclude volume keys from setting `AnyKeyStatus` to true. --- source/common/console/keydef.h | 3 +++ source/core/inputstate.cpp | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source/common/console/keydef.h b/source/common/console/keydef.h index d85adefac..2cbdf621b 100644 --- a/source/common/console/keydef.h +++ b/source/common/console/keydef.h @@ -53,6 +53,9 @@ enum EKeyCodes KEY_PGUP = 0xc9, // DIK_PRIOR KEY_PGDN = 0xd1, // DIK_NEXT + KEY_VOLUMEDOWN = 0xAE, // DIK_VOLUMEDOWN + KEY_VOLUMEUP = 0xB0, // DIK_VOLUMEUP + KEY_FIRSTMOUSEBUTTON = 0x100, KEY_MOUSE1 = 0x100, KEY_MOUSE2 = 0x101, diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index d24afb35a..c4b7c71f8 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -86,14 +86,32 @@ void InputState::GetMouseDelta(ControlInfo * info) // //========================================================================== +static int exclKeys[] = { KEY_VOLUMEDOWN, KEY_VOLUMEUP }; + void InputState::AddEvent(const event_t *ev) { if (ev->type == EV_KeyDown || ev->type == EV_KeyUp) { int key = ev->data1; bool state = ev->type == EV_KeyDown; + bool ignore = false; KeyStatus[key] = (uint8_t)state; - if (state && !(key > KEY_LASTJOYBUTTON && key < KEY_PAD_LTHUMB_RIGHT)) + + // Check if key is to be excluded from setting AnyKeyStatus. + for (int i = 0; i < 2; i++) + { + if (exclKeys[i] == key) + { + ignore = true; + break; + } + } + if (key > KEY_LASTJOYBUTTON && key < KEY_PAD_LTHUMB_RIGHT) + { + ignore = true; + } + + if (state && !ignore) AnyKeyStatus = true; } }