diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt index 16ddc53540..ff66dada5a 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -50,7 +50,7 @@ set(SRCS Config/LogWidget.cpp Config/Mapping/GCKeyboardEmu.cpp Config/Mapping/GCPadEmu.cpp - Config/Mapping/GCPadWiiU.cpp + Config/Mapping/GCPadWiiUConfigDialog.cpp Config/Mapping/Hotkey3D.cpp Config/Mapping/HotkeyGeneral.cpp Config/Mapping/HotkeyGraphics.cpp diff --git a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp index ed8e08a91f..ea54ea880d 100644 --- a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp @@ -28,6 +28,7 @@ #include "Core/IOS/IOS.h" #include "Core/IOS/USB/Bluetooth/BTReal.h" #include "Core/NetPlayProto.h" +#include "DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.h" #include "DolphinQt2/Config/Mapping/MappingWindow.h" #include "DolphinQt2/Settings.h" #include "UICommon/UICommon.h" @@ -78,12 +79,6 @@ ControllersWindow::ControllersWindow(QWidget* parent) : QDialog(parent) CreateMainLayout(); LoadSettings(); ConnectWidgets(); - - for (size_t i = 0; i < m_gc_mappings.size(); i++) - m_gc_mappings[i] = new MappingWindow(this, static_cast(i)); - - for (size_t i = 0; i < m_wiimote_mappings.size(); i++) - m_wiimote_mappings[i] = new MappingWindow(this, static_cast(i)); } void ControllersWindow::CreateGamecubeLayout() @@ -423,8 +418,8 @@ void ControllersWindow::OnGCPadConfigure() type = MappingWindow::Type::MAPPING_GCPAD; break; case 2: // GameCube Adapter for Wii U - type = MappingWindow::Type::MAPPING_GCPAD_WIIU; - break; + GCPadWiiUConfigDialog(static_cast(index), this).exec(); + return; case 3: // Steering Wheel type = MappingWindow::Type::MAPPING_GC_STEERINGWHEEL; break; @@ -440,8 +435,8 @@ void ControllersWindow::OnGCPadConfigure() default: return; } - m_gc_mappings[index]->ChangeMappingType(type); - m_gc_mappings[index]->exec(); + + MappingWindow(this, type, static_cast(index)).exec(); } void ControllersWindow::OnWiimoteConfigure() @@ -468,8 +463,8 @@ void ControllersWindow::OnWiimoteConfigure() default: return; } - m_wiimote_mappings[index]->ChangeMappingType(type); - m_wiimote_mappings[index]->exec(); + + MappingWindow(this, type, static_cast(index)).exec(); } void ControllersWindow::UnimplementedButton() diff --git a/Source/Core/DolphinQt2/Config/ControllersWindow.h b/Source/Core/DolphinQt2/Config/ControllersWindow.h index 171e44ca3c..3a1def39ad 100644 --- a/Source/Core/DolphinQt2/Config/ControllersWindow.h +++ b/Source/Core/DolphinQt2/Config/ControllersWindow.h @@ -51,7 +51,6 @@ private: QDialogButtonBox* m_button_box; // Gamecube - std::array m_gc_mappings; QGroupBox* m_gc_box; QGridLayout* m_gc_layout; std::array m_gc_controller_boxes; @@ -59,7 +58,6 @@ private: std::array m_gc_groups; // Wii Remote - std::array m_wiimote_mappings; QGroupBox* m_wiimote_box; QGridLayout* m_wiimote_layout; std::array m_wiimote_labels; diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp deleted file mode 100644 index 11193b8bbd..0000000000 --- a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include -#include -#include - -#include "DolphinQt2/Config/Mapping/GCPadWiiU.h" - -#include "Core/ConfigManager.h" -#include "InputCommon/GCAdapter.h" - -GCPadWiiU::GCPadWiiU(MappingWindow* window) : MappingWidget(window) -{ - CreateLayout(); - ConnectWidgets(); - - LoadSettings(); -} - -void GCPadWiiU::CreateLayout() -{ - const bool detected = GCAdapter::IsDetected(); - m_layout = new QVBoxLayout(); - m_status_label = new QLabel(detected ? tr("Adapter Detected") : tr("No Adapter Detected")); - m_rumble = new QCheckBox(tr("Enable Rumble")); - m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos")); - - m_layout->addWidget(m_status_label); - m_layout->addWidget(m_rumble); - m_layout->addWidget(m_simulate_bongos); - - if (!detected) - { - m_rumble->setEnabled(false); - m_simulate_bongos->setEnabled(false); - } - - setLayout(m_layout); -} - -void GCPadWiiU::ConnectWidgets() -{ - connect(m_rumble, &QCheckBox::toggled, this, &GCPadWiiU::SaveSettings); - connect(m_simulate_bongos, &QCheckBox::toggled, this, &GCPadWiiU::SaveSettings); -} - -void GCPadWiiU::LoadSettings() -{ - m_rumble->setChecked(SConfig::GetInstance().m_AdapterRumble[GetPort()]); - m_simulate_bongos->setChecked(SConfig::GetInstance().m_AdapterKonga[GetPort()]); -} - -void GCPadWiiU::SaveSettings() -{ - SConfig::GetInstance().m_AdapterRumble[GetPort()] = m_rumble->isChecked(); - SConfig::GetInstance().m_AdapterKonga[GetPort()] = m_simulate_bongos->isChecked(); -} - -InputConfig* GCPadWiiU::GetConfig() -{ - return nullptr; -} diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.cpp b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.cpp new file mode 100644 index 0000000000..1b20728690 --- /dev/null +++ b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.cpp @@ -0,0 +1,66 @@ +// Copyright 2017 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include +#include +#include + +#include "DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.h" + +#include "Core/ConfigManager.h" +#include "InputCommon/GCAdapter.h" + +GCPadWiiUConfigDialog::GCPadWiiUConfigDialog(int port, QWidget* parent) + : QDialog(parent), m_port{port} +{ + CreateLayout(); + ConnectWidgets(); + + LoadSettings(); +} + +void GCPadWiiUConfigDialog::CreateLayout() +{ + setWindowTitle(tr("GameCube Adapter for Wii U at Port %1").arg(m_port + 1)); + + const bool detected = GCAdapter::IsDetected(); + m_layout = new QVBoxLayout(); + m_status_label = new QLabel(detected ? tr("Adapter Detected") : tr("No Adapter Detected")); + m_rumble = new QCheckBox(tr("Enable Rumble")); + m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos")); + m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok); + + m_layout->addWidget(m_status_label); + m_layout->addWidget(m_rumble); + m_layout->addWidget(m_simulate_bongos); + m_layout->addWidget(m_button_box); + + if (!detected) + { + m_rumble->setEnabled(false); + m_simulate_bongos->setEnabled(false); + } + + setLayout(m_layout); +} + +void GCPadWiiUConfigDialog::ConnectWidgets() +{ + connect(m_rumble, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings); + connect(m_simulate_bongos, &QCheckBox::toggled, this, &GCPadWiiUConfigDialog::SaveSettings); + connect(m_button_box, &QDialogButtonBox::accepted, this, &GCPadWiiUConfigDialog::accept); +} + +void GCPadWiiUConfigDialog::LoadSettings() +{ + m_rumble->setChecked(SConfig::GetInstance().m_AdapterRumble[m_port]); + m_simulate_bongos->setChecked(SConfig::GetInstance().m_AdapterKonga[m_port]); +} + +void GCPadWiiUConfigDialog::SaveSettings() +{ + SConfig::GetInstance().m_AdapterRumble[m_port] = m_rumble->isChecked(); + SConfig::GetInstance().m_AdapterKonga[m_port] = m_simulate_bongos->isChecked(); +} diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.h b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.h similarity index 59% rename from Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.h rename to Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.h index 5c3cbbe9ac..851b50a6fa 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.h +++ b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiUConfigDialog.h @@ -4,28 +4,30 @@ #pragma once -#include "DolphinQt2/Config/Mapping/MappingWidget.h" +#include class QCheckBox; class QLabel; +class QDialogButtonBox; class QVBoxLayout; -class GCPadWiiU final : public MappingWidget +class GCPadWiiUConfigDialog final : public QDialog { public: - explicit GCPadWiiU(MappingWindow* window); - - InputConfig* GetConfig() override; + explicit GCPadWiiUConfigDialog(int port, QWidget* parent = nullptr); private: - void LoadSettings() override; - void SaveSettings() override; + void LoadSettings(); + void SaveSettings(); void CreateLayout(); void ConnectWidgets(); + int m_port; + QVBoxLayout* m_layout; QLabel* m_status_label; + QDialogButtonBox* m_button_box; // Checkboxes QCheckBox* m_rumble; diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index 7e83e0e4ae..446680cdd5 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -20,7 +20,6 @@ #include "Core/Core.h" #include "DolphinQt2/Config/Mapping/GCKeyboardEmu.h" #include "DolphinQt2/Config/Mapping/GCPadEmu.h" -#include "DolphinQt2/Config/Mapping/GCPadWiiU.h" #include "DolphinQt2/Config/Mapping/Hotkey3D.h" #include "DolphinQt2/Config/Mapping/HotkeyGeneral.h" #include "DolphinQt2/Config/Mapping/HotkeyGraphics.h" @@ -32,12 +31,12 @@ #include "DolphinQt2/Config/Mapping/WiimoteEmuMotionControl.h" #include "DolphinQt2/Settings.h" #include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/Device.h" #include "InputCommon/InputConfig.h" -#include "InputCommon/ControllerInterface/ControllerInterface.h" - -MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m_port(port_num) +MappingWindow::MappingWindow(QWidget* parent, Type type, int port_num) + : QDialog(parent), m_port(port_num) { setWindowTitle(tr("Port %1").arg(port_num + 1)); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -47,6 +46,7 @@ MappingWindow::MappingWindow(QWidget* parent, int port_num) : QDialog(parent), m CreateResetLayout(); CreateMainLayout(); ConnectWidgets(); + SetMappingType(type); } void MappingWindow::CreateDevicesLayout() @@ -237,15 +237,8 @@ void MappingWindow::RefreshDevices() }); } -void MappingWindow::ChangeMappingType(MappingWindow::Type type) +void MappingWindow::SetMappingType(MappingWindow::Type type) { - if (m_mapping_type == type) - return; - - ClearWidgets(); - - m_controller = nullptr; - MappingWidget* widget; switch (type) @@ -263,11 +256,6 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) setWindowTitle(tr("GameCube Controller at Port %1").arg(GetPort() + 1)); AddWidget(tr("GameCube Controller"), widget); break; - case Type::MAPPING_GCPAD_WIIU: - widget = new GCPadWiiU(this); - setWindowTitle(tr("GameCube Adapter for Wii U at Port %1").arg(GetPort() + 1)); - AddWidget(tr("GameCube Adapter for Wii U"), widget); - break; case Type::MAPPING_WIIMOTE_EMU: case Type::MAPPING_WIIMOTE_HYBRID: { @@ -297,36 +285,22 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) widget->LoadSettings(); - m_profiles_combo->clear(); - m_config = widget->GetConfig(); - if (m_config) + m_controller = m_config->GetController(GetPort()); + m_profiles_combo->addItem(QStringLiteral("")); + + const std::string profiles_path = + File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + m_config->GetProfileName(); + for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"})) { - m_controller = m_config->GetController(GetPort()); - m_profiles_combo->addItem(QStringLiteral("")); - - const std::string profiles_path = - File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + m_config->GetProfileName(); - for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"})) - { - std::string basename; - SplitPath(filename, nullptr, &basename, nullptr); - m_profiles_combo->addItem(QString::fromStdString(basename), QString::fromStdString(filename)); - } + std::string basename; + SplitPath(filename, nullptr, &basename, nullptr); + m_profiles_combo->addItem(QString::fromStdString(basename), QString::fromStdString(filename)); } - SetLayoutComplex(type != Type::MAPPING_GCPAD_WIIU); - if (m_controller != nullptr) RefreshDevices(); - - m_mapping_type = type; -} - -void MappingWindow::ClearWidgets() -{ - m_tab_widget->clear(); } void MappingWindow::AddWidget(const QString& name, QWidget* widget) @@ -334,15 +308,6 @@ void MappingWindow::AddWidget(const QString& name, QWidget* widget) m_tab_widget->addTab(widget, name); } -void MappingWindow::SetLayoutComplex(bool is_complex) -{ - m_reset_box->setHidden(!is_complex); - m_profiles_box->setHidden(!is_complex); - m_devices_box->setHidden(!is_complex); - - m_is_complex = is_complex; -} - int MappingWindow::GetPort() const { return m_port; diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h index 3a7a308433..fee581c175 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.h @@ -37,7 +37,6 @@ public: MAPPING_GC_DANCEMAT, MAPPING_GC_KEYBOARD, MAPPING_GCPAD, - MAPPING_GCPAD_WIIU, MAPPING_GC_STEERINGWHEEL, // Wii MAPPING_WIIMOTE_EMU, @@ -46,8 +45,7 @@ public: MAPPING_HOTKEYS }; - explicit MappingWindow(QWidget* parent, int port_num); - void ChangeMappingType(Type type); + explicit MappingWindow(QWidget* parent, Type type, int port_num); int GetPort() const; const ciface::Core::DeviceQualifier& GetDeviceQualifier() const; @@ -59,15 +57,14 @@ signals: void ClearFields(); private: + void SetMappingType(Type type); void CreateDevicesLayout(); void CreateProfilesLayout(); void CreateResetLayout(); void CreateMainLayout(); void ConnectWidgets(); - void SetLayoutComplex(bool is_complex); void AddWidget(const QString& name, QWidget* widget); - void ClearWidgets(); void RefreshDevices(); @@ -108,7 +105,6 @@ private: Type m_mapping_type; const int m_port; - bool m_is_complex; InputConfig* m_config; ciface::Core::DeviceQualifier m_devq; }; diff --git a/Source/Core/DolphinQt2/DolphinQt2.vcxproj b/Source/Core/DolphinQt2/DolphinQt2.vcxproj index 8d55c59e73..8ac0466b49 100644 --- a/Source/Core/DolphinQt2/DolphinQt2.vcxproj +++ b/Source/Core/DolphinQt2/DolphinQt2.vcxproj @@ -177,7 +177,7 @@ - + diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index e92f794f6f..3c7d265aea 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -73,6 +73,8 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW setUnifiedTitleAndToolBarOnMac(true); setAcceptDrops(true); + InitControllers(); + CreateComponents(); ConnectGameList(); @@ -81,7 +83,6 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW ConnectStack(); ConnectMenuBar(); - InitControllers(); InitCoreCallbacks(); NetPlayInit(); @@ -154,7 +155,7 @@ void MainWindow::CreateComponents() m_stack = new QStackedWidget(this); m_controllers_window = new ControllersWindow(this); m_settings_window = new SettingsWindow(this); - m_hotkey_window = new MappingWindow(this, 0); + m_hotkey_window = new MappingWindow(this, MappingWindow::Type::MAPPING_HOTKEYS, 0); m_log_widget = new LogWidget(this); m_log_config_widget = new LogConfigWidget(this); @@ -570,7 +571,6 @@ void MainWindow::ShowAboutDialog() void MainWindow::ShowHotkeyDialog() { - m_hotkey_window->ChangeMappingType(MappingWindow::Type::MAPPING_HOTKEYS); m_hotkey_window->show(); m_hotkey_window->raise(); m_hotkey_window->activateWindow();