From 4d609f06b810a6bc686aa783a2b716e3cd280f0e Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:22:48 +0100 Subject: [PATCH] InputSettings: Fix controller type counter to restore WPAD limit (#1118) --- src/gui/input/InputSettings2.cpp | 32 ++++---------------------------- src/gui/input/InputSettings2.h | 3 --- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/gui/input/InputSettings2.cpp b/src/gui/input/InputSettings2.cpp index 58c168a3..72bf4f7d 100644 --- a/src/gui/input/InputSettings2.cpp +++ b/src/gui/input/InputSettings2.cpp @@ -295,32 +295,6 @@ wxWindow* InputSettings2::initialize_page(size_t index) return page; } -std::pair InputSettings2::get_emulated_controller_types() const -{ - size_t vpad = 0, wpad = 0; - for(size_t i = 0; i < m_notebook->GetPageCount(); ++i) - { - auto* page = m_notebook->GetPage(i); - auto* page_data = (wxControllerPageData*)page->GetClientObject(); - if (!page_data) - continue; - - if (!page_data->ref().m_controller) // = disabled - continue; - - const auto api_type = page_data->ref().m_controller->type(); - if (api_type) - continue; - - if (api_type == EmulatedController::VPAD) - ++vpad; - else - ++wpad; - } - - return std::make_pair(vpad, wpad); -} - std::shared_ptr InputSettings2::get_active_controller() const { auto& page_data = get_current_page_data(); @@ -771,14 +745,16 @@ void InputSettings2::on_emulated_controller_dropdown(wxCommandEvent& event) wxWindowUpdateLocker lock(emulated_controllers); bool is_gamepad_selected = false; + bool is_wpad_selected = false; const auto selected = emulated_controllers->GetSelection(); const auto selected_value = emulated_controllers->GetStringSelection(); if(selected != wxNOT_FOUND) { is_gamepad_selected = selected_value == to_wxString(EmulatedController::type_to_string(EmulatedController::Type::VPAD)); + is_wpad_selected = !is_gamepad_selected && selected != 0; } - const auto [vpad_count, wpad_count] = get_emulated_controller_types(); + const auto [vpad_count, wpad_count] = InputManager::instance().get_controller_count(); emulated_controllers->Clear(); emulated_controllers->AppendString(_("Disabled")); @@ -786,7 +762,7 @@ void InputSettings2::on_emulated_controller_dropdown(wxCommandEvent& event) if (vpad_count < InputManager::kMaxVPADControllers || is_gamepad_selected) emulated_controllers->Append(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::VPAD))); - if (wpad_count < InputManager::kMaxWPADControllers || !is_gamepad_selected) + if (wpad_count < InputManager::kMaxWPADControllers || is_wpad_selected) { emulated_controllers->AppendString(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::Pro))); emulated_controllers->AppendString(to_wxString(EmulatedController::type_to_string(EmulatedController::Type::Classic))); diff --git a/src/gui/input/InputSettings2.h b/src/gui/input/InputSettings2.h index 01313653..1a3c8bb1 100644 --- a/src/gui/input/InputSettings2.h +++ b/src/gui/input/InputSettings2.h @@ -27,9 +27,6 @@ private: wxWindow* initialize_page(size_t index); - // count active controllers - std::pair get_emulated_controller_types() const; - // currently selected controller from active tab std::shared_ptr get_active_controller() const;