diff --git a/Common/UI/Screen.h b/Common/UI/Screen.h index 336b6b6555..9848db8f67 100644 --- a/Common/UI/Screen.h +++ b/Common/UI/Screen.h @@ -94,6 +94,7 @@ enum class InputMode { Mouse = 2, Other = 4, ImDebuggerToggle = 8, // ugly hack. debugger and pause goes through. + AllKeys = 16, // The screen gets keys that are normally left to the OS, like volume. For key mapping. }; ENUM_CLASS_BITOPS(InputMode); diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index 6c7a4579ae..20652b7b23 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -72,6 +72,10 @@ public: const char *tag() const override { return "KeyMappingNewKey"; } + InputMode PassInputToMapper() const override { + return PopupScreen::PassInputToMapper() | InputMode::AllKeys; + } + bool key(const KeyInput &key) override; void axis(const AxisInput &axis) override; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index c087499e55..b1cfcfa1b7 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1639,15 +1639,18 @@ bool NativeKey(const KeyInput &key) { // Leave volume keys to the OS, unless they're mapped (to L/R for example). Then they also reach the menus, // and in game we consume them, repeats included, so the OS doesn't change the volume as well. - bool mappedVolumeKey = false; + // The key mapping dialog gets them all (to be able to map them), and consumes them too. + bool volumeKey = false; + bool consumeVolumeKey = false; switch (key.keyCode) { case NKCODE_VOLUME_DOWN: case NKCODE_VOLUME_UP: case NKCODE_VOLUME_MUTE: - if (!KeyMap::InputMappingToPspButton(InputMapping(key.deviceId, key.keyCode), nullptr)) { + if (!(inputMode & InputMode::AllKeys) && !KeyMap::InputMappingToPspButton(InputMapping(key.deviceId, key.keyCode), nullptr)) { return false; } - mappedVolumeKey = true; + volumeKey = true; + consumeVolumeKey = inputMode & (InputMode::Other | InputMode::AllKeys); break; default: break; @@ -1719,7 +1722,7 @@ bool NativeKey(const KeyInput &key) { retval = false; break; case UI::KeyEventResult::IGNORE_KEY: - return mappedVolumeKey && (inputMode & InputMode::Other); + return consumeVolumeKey; } // Queue up the key event for synchronous processing in the UI. @@ -1736,8 +1739,8 @@ bool NativeKey(const KeyInput &key) { // Tell the caller that we handled the key. retval = true; } - if (mappedVolumeKey) { - retval = inputMode & InputMode::Other; + if (volumeKey) { + retval = consumeVolumeKey; } return retval;