Skip to content

Commit

Permalink
Qt: Implement mapping windows
Browse files Browse the repository at this point in the history
  • Loading branch information
spycrab committed May 14, 2017
1 parent faae898 commit d4f952a
Show file tree
Hide file tree
Showing 16 changed files with 881 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Source/Core/DolphinQt2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ set(SRCS
Config/ControllersWindow.cpp
Config/FilesystemWidget.cpp
Config/InfoWidget.cpp
Config/Mapping/GCPadEmu.cpp
Config/Mapping/GCPadWiiU.cpp
Config/Mapping/MappingButton.cpp
Config/Mapping/MappingWidget.cpp
Config/Mapping/MappingWindow.cpp
Config/PathDialog.cpp
Config/PropertiesDialog.cpp
Config/SettingsWindow.cpp
Expand Down
34 changes: 30 additions & 4 deletions Source/Core/DolphinQt2/Config/ControllersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Core/IOS/IOS.h"
#include "Core/IOS/USB/Bluetooth/BTReal.h"
#include "Core/NetPlayProto.h"
#include "DolphinQt2/Config/Mapping/MappingWindow.h"
#include "DolphinQt2/Settings.h"
#include "UICommon/UICommon.h"

Expand Down Expand Up @@ -79,6 +80,12 @@ ControllersWindow::ControllersWindow(QWidget* 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 + 1));

for (size_t i = 0; i < m_wiimote_mappings.size(); i++)
m_wiimote_mappings[i] = new MappingWindow(this, static_cast<int>(i + 1));
}

void ControllersWindow::CreateGamecubeLayout()
Expand Down Expand Up @@ -388,20 +395,34 @@ void ControllersWindow::OnGCPadConfigure()
break;
}

int type = 0;

switch (m_gc_controller_boxes[index]->currentIndex())
{
case 0: // None
case 6: // GBA
return;
case 1: // Standard Controller
type = MappingWindow::MAPPING_GCPAD;
break;
case 2: // GameCube Adapter for Wii U
type = MappingWindow::MAPPING_GCPAD_WIIU;
break;
case 3: // Steering Wheel
type = MappingWindow::MAPPING_GC_STEERINGWHEEL;
break;
case 4: // Dance Mat
type = MappingWindow::MAPPING_GC_DANCEMAT;
break;
case 5: // DK Bongos
type = MappingWindow::MAPPING_GC_BONGOS;
break;
case 7: // Keyboard
UnimplementedButton();
return;
type = MappingWindow::MAPPING_GC_KEYBOARD;
break;
}
m_gc_mappings[index]->ChangeMappingType(type);
m_gc_mappings[index]->exec();
}

void ControllersWindow::OnWiimoteConfigure()
Expand All @@ -413,16 +434,21 @@ void ControllersWindow::OnWiimoteConfigure()
break;
}

int type = 0;
switch (m_wiimote_boxes[index]->currentIndex())
{
case 0: // None
case 2: // Real Wii Remote
return;
case 1: // Emulated Wii Remote
type = MappingWindow::MAPPING_WIIMOTE_EMU;
break;
case 3: // Hybrid Wii Remote
UnimplementedButton();
return;
type = MappingWindow::MAPPING_WIIMOTE_HYBRID;
break;
}
m_wiimote_mappings[index]->ChangeMappingType(type);
m_wiimote_mappings[index]->exec();
}

void ControllersWindow::UnimplementedButton()
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/DolphinQt2/Config/ControllersWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <array>

class MappingWindow;
class QDialogButtonBox;
class QCheckBox;
class QComboBox;
Expand Down Expand Up @@ -55,6 +56,7 @@ class ControllersWindow final : public QDialog
QDialogButtonBox* m_button_box;

// Gamecube
std::array<MappingWindow*, 4> m_gc_mappings;
QGroupBox* m_gc_box;
QLabel* m_gc_label;
QFormLayout* m_gc_layout;
Expand All @@ -63,6 +65,7 @@ class ControllersWindow final : public QDialog
std::array<QHBoxLayout*, 4> m_gc_groups;

// Wii Remote
std::array<MappingWindow*, 4> m_wiimote_mappings;
QGroupBox* m_wiimote_box;
QLabel* m_wii_label;
QFormLayout* m_wiimote_layout;
Expand Down
60 changes: 60 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>

#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"

#include "DolphinQt2/Config/Mapping/GCPadEmu.h"

GCPadEmu::GCPadEmu(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
// ConnectWidgets();
}

void GCPadEmu::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();

auto* hbox_layout = new QVBoxLayout();
hbox_layout->addWidget(
CreateGroupBox(tr("Triggers"), Pad::GetGroup(GetPort(), PadGroup::Triggers)));
hbox_layout->addWidget(CreateGroupBox(tr("Rumble"), Pad::GetGroup(GetPort(), PadGroup::Rumble)));

m_main_layout->addWidget(
CreateGroupBox(tr("Buttons"), Pad::GetGroup(GetPort(), PadGroup::Buttons)));
m_main_layout->addWidget(
CreateGroupBox(tr("Control Stick"), Pad::GetGroup(GetPort(), PadGroup::MainStick)));
m_main_layout->addWidget(
CreateGroupBox(tr("C-Stick"), Pad::GetGroup(GetPort(), PadGroup::CStick)));
m_main_layout->addWidget(CreateGroupBox(tr("D-Pad"), Pad::GetGroup(GetPort(), PadGroup::DPad)));
m_main_layout->addItem(hbox_layout);

setLayout(m_main_layout);
}

void GCPadEmu::OnLoadProfile(const QString& profile)
{
// TODO Implement this
}

void GCPadEmu::OnSaveProfile(const QString& profile)
{
// TODO Implement this
}

void GCPadEmu::OnClearFields()
{
// TODO Implement this
}

void GCPadEmu::OnDefaultFields()
{
// TODO Implement this
}
61 changes: 61 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/GCPadEmu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;

class GCPadEmu final : public MappingWidget
{
public:
explicit GCPadEmu(MappingWindow* window);

protected:
void OnSaveProfile(const QString& profile) override;
void OnLoadProfile(const QString& profile) override;
void OnClearFields() override;
void OnDefaultFields() override;

private:
void CreateButtonsLayout();
void CreateControlstickLayout();
void CreateCStickLayout();
void CreateTriggersLayout();
void CreateDPadLayout();
void CreateMainLayout();
void ConnectWidgets();

// Main
QHBoxLayout* m_main_layout;

// Buttons
QGroupBox* m_buttons_box;
QFormLayout* m_buttons_layout;
// TODO Add missing settings

// Control Stick
QGroupBox* m_controlstick_box;
QFormLayout* m_controlstick_layout;
// TODO Add missing settings

// C Stick
QGroupBox* m_cstick_box;
QFormLayout* m_cstick_layout;
// TODO Add missing settings

// Triggers
QGroupBox* m_triggers_box;
QFormLayout* m_triggers_layout;
// TODO Add missing settings

// D-Pad
QGroupBox* m_dpad_box;
QFormLayout* m_dpad_layout;
// TODO Add missing settings
};
75 changes: 75 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <QCheckBox>
#include <QLabel>
#include <QVBoxLayout>

#include "DolphinQt2/Settings.h"
#include "InputCommon/GCAdapter.h"

#include "DolphinQt2/Config/Mapping/GCPadWiiU.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(Settings().IsGCAdapterRumbleEnabled(GetPort()));
m_simulate_bongos->setChecked(Settings().IsGCAdapterSimulatingDKBongos(GetPort()));
}

void GCPadWiiU::SaveSettings()
{
Settings().SetGCAdapterRumbleEnabled(GetPort(), m_rumble->isChecked());
Settings().SetGCAdapterSimulatingDKBongos(GetPort(), m_simulate_bongos->isChecked());
}

void GCPadWiiU::OnLoadProfile(const QString& profile)
{
}

void GCPadWiiU::OnSaveProfile(const QString& profile)
{
}

void GCPadWiiU::OnClearFields()
{
}

void GCPadWiiU::OnDefaultFields()
{
}
34 changes: 34 additions & 0 deletions Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt2/Config/Mapping/MappingWidget.h"

class QCheckBox;
class QLabel;
class QVBoxLayout;

class GCPadWiiU final : public MappingWidget
{
public:
explicit GCPadWiiU(MappingWindow* window);

protected:
void OnSaveProfile(const QString& profile) override;
void OnLoadProfile(const QString& profile) override;
void OnClearFields() override;
void OnDefaultFields() override;

private:
void LoadSettings();
void SaveSettings();
void CreateLayout();
void ConnectWidgets();

QVBoxLayout* m_layout;
QLabel* m_status_label;

// Checkboxes
QCheckBox* m_rumble;
QCheckBox* m_simulate_bongos;
};

0 comments on commit d4f952a

Please sign in to comment.