From c51bcd458cd7c565f21d7987acca36d74d6230b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 22 Oct 2026 00:01:34 +0200 Subject: [PATCH] Input: Let the key mapping dialog see volume keys, mapped or not The volume key filter in NativeKey left unmapped volume keys to the OS, so they never reached the dialog and couldn't be mapped. A new InputMode::AllKeys lets a screen ask for them; the dialog consumes them so the volume doesn't change while mapping. Co-Authored-By: Claude Opus 5.5 (1M context) --- Common/UI/Screen.h | 1 + UI/ControlMappingScreen.h | 4 ++++ UI/NativeApp.cpp | 15 +++++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) 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;