From 20686814a3abe5903c4ffa4fcbc5c1e4fc68f73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 22 Oct 2026 08:55:47 +0200 Subject: [PATCH] ControlMapping: Fix Autoconfigure in portrait, and Escape on the analog limiter - In portrait the settings pane is a popup, so it got the list's dialogFinished and the pad was never autoconfigured. Use a callback. - Escape was meant to cancel mapping the analog speed limiter (3cb4207369), but since the combo mapping rewrite it got mapped to it instead. Co-Authored-By: Claude Opus 5.5 (1M context) --- UI/ControlMappingScreen.cpp | 19 +++++++++---------- UI/ControlMappingScreen.h | 2 -- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 0c491b8905..7523041d8d 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -308,20 +308,16 @@ void ControlMappingScreen::OnAutoConfigure(UI::EventParams ¶ms) { } auto km = GetI18NCategory(I18NCat::KEYMAPPING); auto di = GetI18NCategory(I18NCat::DIALOG); - UI::ListPopupScreen *autoConfList = new UI::ListPopupScreen(km->T("Autoconfigure for device"), items, -1); + // Uses a callback, since in portrait the settings are in a popup, which would get dialogFinished instead of us. + UI::ListPopupScreen *autoConfList = new UI::ListPopupScreen(km->T("Autoconfigure for device"), items, -1, [items](int index) { + KeyMap::AutoConfForPad(items[index]); + }); autoConfList->SetNotification(NoticeLevel::WARN, di->T("This will overwrite the existing configuration")); if (params.v) autoConfList->SetPopupOrigin(params.v); screenManager()->push(autoConfList); } -void ControlMappingScreen::dialogFinished(const Screen *dialog, DialogResult result) { - if (result == DR_OK && !strcmp(dialog->tag(), "listpopup")) { - UI::ListPopupScreen *popup = (UI::ListPopupScreen *)dialog; - KeyMap::AutoConfForPad(popup->GetChoiceString()); - } -} - void KeyMappingNewKeyDialog::CreatePopupContents(UI::ViewGroup *parent) { using namespace UI; @@ -351,8 +347,11 @@ bool KeyMappingNewKeyDialog::key(const KeyInput &key) { return true; } - if (pspBtn_ == VIRTKEY_SPEED_ANALOG && !UI::IsEscapeKey(key)) { - // Only map analog values to this mapping. + if (pspBtn_ == VIRTKEY_SPEED_ANALOG) { + // Only map analog values to this mapping. Escape cancels. + if (UI::IsEscapeKey(key)) { + TriggerFinish(DR_CANCEL); + } return true; } diff --git a/UI/ControlMappingScreen.h b/UI/ControlMappingScreen.h index 6c7a4579ae..ab4744ec80 100644 --- a/UI/ControlMappingScreen.h +++ b/UI/ControlMappingScreen.h @@ -57,8 +57,6 @@ protected: private: void OnAutoConfigure(UI::EventParams ¶ms); - void dialogFinished(const Screen *dialog, DialogResult result) override; - std::vector mappers_; int keyMapGeneration_ = -1;