Merge pull request #6168 from ligfx/movegccwiiu

Qt: make GCPadWiiU a standalone dialog
This commit is contained in:
Leo Lam 2017-11-11 12:14:55 +01:00 committed by GitHub
commit 338bffd1e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 103 additions and 145 deletions

View File

@ -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

View File

@ -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<int>(i));
for (size_t i = 0; i < m_wiimote_mappings.size(); i++)
m_wiimote_mappings[i] = new MappingWindow(this, static_cast<int>(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<int>(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<int>(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<int>(index)).exec();
}
void ControllersWindow::UnimplementedButton()

View File

@ -51,7 +51,6 @@ private:
QDialogButtonBox* m_button_box;
// Gamecube
std::array<MappingWindow*, 4> m_gc_mappings;
QGroupBox* m_gc_box;
QGridLayout* m_gc_layout;
std::array<QComboBox*, 4> m_gc_controller_boxes;
@ -59,7 +58,6 @@ private:
std::array<QHBoxLayout*, 4> m_gc_groups;
// Wii Remote
std::array<MappingWindow*, 4> m_wiimote_mappings;
QGroupBox* m_wiimote_box;
QGridLayout* m_wiimote_layout;
std::array<QLabel*, 4> m_wiimote_labels;

View File

@ -1,64 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>
#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;
}

View File

@ -0,0 +1,66 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QVBoxLayout>
#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();
}

View File

@ -4,28 +4,30 @@
#pragma once
#include "DolphinQt2/Config/Mapping/MappingWidget.h"
#include <QDialog>
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;

View File

@ -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,12 +285,8 @@ 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(""));
@ -314,19 +298,9 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type)
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;

View File

@ -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;
};

View File

@ -177,7 +177,7 @@
<ClCompile Include="Config\InfoWidget.cpp" />
<ClCompile Include="Config\Mapping\GCKeyboardEmu.cpp" />
<ClCompile Include="Config\Mapping\GCPadEmu.cpp" />
<ClCompile Include="Config\Mapping\GCPadWiiU.cpp" />
<ClCompile Include="Config\Mapping\GCPadWiiUConfigDialog.cpp" />
<ClCompile Include="Config\Mapping\Hotkey3D.cpp" />
<ClCompile Include="Config\Mapping\HotkeyGeneral.cpp" />
<ClCompile Include="Config\Mapping\HotkeyGraphics.cpp" />

View File

@ -73,6 +73,8 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
setUnifiedTitleAndToolBarOnMac(true);
setAcceptDrops(true);
InitControllers();
CreateComponents();
ConnectGameList();
@ -81,7 +83,6 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> 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();