Move DolphinQt2 to DolphinQt

This commit is contained in:
spycrab
2018-07-07 00:40:15 +02:00
parent 059880bb16
commit 13ba24c5a6
233 changed files with 392 additions and 392 deletions

View File

@ -0,0 +1,59 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "DolphinQt/Config/Mapping/GCKeyboardEmu.h"
#include "InputCommon/InputConfig.h"
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCKeyboardEmu.h"
GCKeyboardEmu::GCKeyboardEmu(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void GCKeyboardEmu::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb0x)));
m_main_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb1x)));
m_main_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb2x)));
m_main_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb3x)));
m_main_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb4x)));
auto* vbox_layout = new QVBoxLayout();
vbox_layout->addWidget(
CreateGroupBox(QStringLiteral(""), Keyboard::GetGroup(GetPort(), KeyboardGroup::Kb5x)));
m_main_layout->addLayout(vbox_layout);
setLayout(m_main_layout);
}
void GCKeyboardEmu::LoadSettings()
{
Keyboard::LoadConfig();
}
void GCKeyboardEmu::SaveSettings()
{
Keyboard::GetConfig()->SaveConfig();
}
InputConfig* GCKeyboardEmu::GetConfig()
{
return Keyboard::GetConfig();
}

View File

@ -0,0 +1,31 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;
class GCKeyboardEmu final : public MappingWidget
{
Q_OBJECT
public:
explicit GCKeyboardEmu(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,45 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "DolphinQt/Config/Mapping/GCMicrophone.h"
#include "InputCommon/InputConfig.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
GCMicrophone::GCMicrophone(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void GCMicrophone::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Microphone"), Pad::GetGroup(GetPort(), PadGroup::Mic)));
setLayout(m_main_layout);
}
void GCMicrophone::LoadSettings()
{
Pad::LoadConfig();
}
void GCMicrophone::SaveSettings()
{
Pad::GetConfig()->SaveConfig();
}
InputConfig* GCMicrophone::GetConfig()
{
return Pad::GetConfig();
}

View File

@ -0,0 +1,30 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;
class GCMicrophone final : public MappingWidget
{
Q_OBJECT
public:
explicit GCMicrophone(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,63 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/GCPadEmu.h"
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/InputConfig.h"
GCPadEmu::GCPadEmu(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void GCPadEmu::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
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)));
auto* hbox_layout = new QVBoxLayout();
m_main_layout->addLayout(hbox_layout);
hbox_layout->addWidget(
CreateGroupBox(tr("Triggers"), Pad::GetGroup(GetPort(), PadGroup::Triggers)));
hbox_layout->addWidget(CreateGroupBox(tr("Rumble"), Pad::GetGroup(GetPort(), PadGroup::Rumble)));
hbox_layout->addWidget(
CreateGroupBox(tr("Options"), Pad::GetGroup(GetPort(), PadGroup::Options)));
setLayout(m_main_layout);
}
void GCPadEmu::LoadSettings()
{
Pad::LoadConfig();
}
void GCPadEmu::SaveSettings()
{
Pad::GetConfig()->SaveConfig();
}
InputConfig* GCPadEmu::GetConfig()
{
return Pad::GetConfig();
}

View File

@ -0,0 +1,30 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;
class GCPadEmu final : public MappingWidget
{
Q_OBJECT
public:
explicit GCPadEmu(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,69 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/GCPadWiiUConfigDialog.h"
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QVBoxLayout>
#include "Core/ConfigManager.h"
#include "InputCommon/GCAdapter.h"
GCPadWiiUConfigDialog::GCPadWiiUConfigDialog(int port, QWidget* parent)
: QDialog(parent), m_port{port}
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
CreateLayout();
LoadSettings();
ConnectWidgets();
}
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

@ -0,0 +1,36 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QDialog>
class QCheckBox;
class QLabel;
class QDialogButtonBox;
class QVBoxLayout;
class GCPadWiiUConfigDialog final : public QDialog
{
Q_OBJECT
public:
explicit GCPadWiiUConfigDialog(int port, QWidget* parent = nullptr);
private:
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;
QCheckBox* m_simulate_bongos;
};

View File

@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/Hotkey3D.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include "Core/HotkeyManager.h"
Hotkey3D::Hotkey3D(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void Hotkey3D::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("3D"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_TOGGLE)));
m_main_layout->addWidget(
CreateGroupBox(tr("3D Depth"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_DEPTH)));
setLayout(m_main_layout);
}
InputConfig* Hotkey3D::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void Hotkey3D::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void Hotkey3D::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class Hotkey3D final : public MappingWidget
{
Q_OBJECT
public:
explicit Hotkey3D(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,47 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyDebugging.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyDebugging::HotkeyDebugging(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyDebugging::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Stepping"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_STEPPING)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Program Counter"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_PC)));
vbox->addWidget(
CreateGroupBox(tr("Breakpoint"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_BREAKPOINT)));
m_main_layout->addLayout(vbox);
setLayout(m_main_layout);
}
InputConfig* HotkeyDebugging::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyDebugging::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyDebugging::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyDebugging final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyDebugging(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,47 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyGeneral.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyGeneral::HotkeyGeneral(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyGeneral::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("General"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Volume"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME)));
vbox->addWidget(
CreateGroupBox(tr("Emulation Speed"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED)));
m_main_layout->addLayout(vbox);
setLayout(m_main_layout);
}
InputConfig* HotkeyGeneral::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyGeneral::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyGeneral::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyGeneral final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyGeneral(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,48 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyGraphics.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyGraphics::HotkeyGraphics(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyGraphics::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(tr("Graphics Toggles"),
HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES)));
vbox->addWidget(
CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR)));
m_main_layout->addLayout(vbox);
setLayout(m_main_layout);
}
InputConfig* HotkeyGraphics::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyGraphics::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyGraphics::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyGraphics final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyGraphics(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyStates.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyStates::HotkeyStates(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyStates::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Save"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SAVE_STATE)));
m_main_layout->addWidget(
CreateGroupBox(tr("Load"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_STATE)));
setLayout(m_main_layout);
}
InputConfig* HotkeyStates::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyStates::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyStates::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyStates final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyStates(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,44 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyStatesOther.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyStatesOther::HotkeyStatesOther(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyStatesOther::CreateMainLayout()
{
auto* layout = new QHBoxLayout;
layout->addWidget(
CreateGroupBox(tr("Select Last State"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_SELECT_STATE)));
layout->addWidget(CreateGroupBox(tr("Load Last State"),
HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_LAST_STATE)));
layout->addWidget(
CreateGroupBox(tr("Other State Hotkeys"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_STATE_MISC)));
setLayout(layout);
}
InputConfig* HotkeyStatesOther::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyStatesOther::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyStatesOther::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,23 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyStatesOther final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyStatesOther(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
};

View File

@ -0,0 +1,42 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyTAS.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyTAS::HotkeyTAS(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyTAS::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(
CreateGroupBox(tr("Frame Advance"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FRAME_ADVANCE)));
m_main_layout->addWidget(
CreateGroupBox(tr("Movie"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_MOVIE)));
setLayout(m_main_layout);
}
InputConfig* HotkeyTAS::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyTAS::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyTAS::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyTAS final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyTAS(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,39 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/HotkeyWii.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include "Core/HotkeyManager.h"
HotkeyWii::HotkeyWii(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void HotkeyWii::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(CreateGroupBox(tr("Wii"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_WII)));
setLayout(m_main_layout);
}
InputConfig* HotkeyWii::GetConfig()
{
return HotkeyManagerEmu::GetConfig();
}
void HotkeyWii::LoadSettings()
{
HotkeyManagerEmu::LoadConfig();
}
void HotkeyWii::SaveSettings()
{
HotkeyManagerEmu::GetConfig()->SaveConfig();
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QHBoxLayout;
class HotkeyWii final : public MappingWidget
{
Q_OBJECT
public:
explicit HotkeyWii(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};

View File

@ -0,0 +1,262 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/IOWindow.h"
#include <thread>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <QVBoxLayout>
#include "Core/Core.h"
#include "DolphinQt/Config/Mapping/MappingCommon.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
constexpr int SLIDER_TICK_COUNT = 100;
IOWindow::IOWindow(QWidget* parent, ControllerEmu::EmulatedController* controller,
ControlReference* ref, IOWindow::Type type)
: QDialog(parent), m_reference(ref), m_controller(controller), m_type(type)
{
CreateMainLayout();
ConnectWidgets();
setWindowTitle(type == IOWindow::Type::Input ? tr("Configure Input") : tr("Configure Output"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
Update();
}
void IOWindow::CreateMainLayout()
{
m_main_layout = new QVBoxLayout();
m_devices_combo = new QComboBox();
m_option_list = new QListWidget();
m_select_button = new QPushButton(tr("Select"));
m_detect_button = new QPushButton(tr("Detect"));
m_or_button = new QPushButton(tr("| OR"));
m_and_button = new QPushButton(tr("&& AND"));
m_add_button = new QPushButton(tr("+ ADD"));
m_not_button = new QPushButton(tr("! NOT"));
m_test_button = new QPushButton(tr("Test"));
m_expression_text = new QPlainTextEdit();
m_button_box = new QDialogButtonBox();
m_clear_button = new QPushButton(tr("Clear"));
m_apply_button = new QPushButton(tr("Apply"));
m_range_slider = new QSlider(Qt::Horizontal);
m_range_spinbox = new QSpinBox();
// Devices
m_main_layout->addWidget(m_devices_combo);
// Range
auto* range_hbox = new QHBoxLayout();
range_hbox->addWidget(new QLabel(tr("Range")));
range_hbox->addWidget(m_range_slider);
range_hbox->addWidget(m_range_spinbox);
m_range_slider->setMinimum(-500);
m_range_slider->setMaximum(500);
m_range_spinbox->setMinimum(-500);
m_range_spinbox->setMaximum(500);
m_main_layout->addLayout(range_hbox);
// Options (Buttons, Outputs) and action buttons
for (QPushButton* button : {m_select_button, m_detect_button, m_or_button, m_and_button,
m_add_button, m_not_button, m_test_button})
{
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
auto* hbox = new QHBoxLayout();
auto* button_vbox = new QVBoxLayout();
hbox->addWidget(m_option_list, 8);
hbox->addLayout(button_vbox, 1);
button_vbox->addWidget(m_select_button);
button_vbox->addWidget(m_type == Type::Input ? m_detect_button : m_test_button);
button_vbox->addWidget(m_or_button);
if (m_type == Type::Input)
{
button_vbox->addWidget(m_and_button);
button_vbox->addWidget(m_add_button);
button_vbox->addWidget(m_not_button);
}
m_main_layout->addLayout(hbox, 2);
m_main_layout->addWidget(m_expression_text, 1);
// Button Box
m_main_layout->addWidget(m_button_box);
m_button_box->addButton(m_clear_button, QDialogButtonBox::ActionRole);
m_button_box->addButton(m_apply_button, QDialogButtonBox::ActionRole);
m_button_box->addButton(QDialogButtonBox::Ok);
setLayout(m_main_layout);
}
void IOWindow::Update()
{
m_expression_text->setPlainText(QString::fromStdString(m_reference->GetExpression()));
m_range_spinbox->setValue(m_reference->range * SLIDER_TICK_COUNT);
m_range_slider->setValue(m_reference->range * SLIDER_TICK_COUNT);
m_devq = m_controller->GetDefaultDevice();
UpdateDeviceList();
UpdateOptionList();
}
void IOWindow::ConnectWidgets()
{
connect(m_select_button, &QPushButton::clicked, [this] { AppendSelectedOption(""); });
connect(m_add_button, &QPushButton::clicked, [this] { AppendSelectedOption(" + "); });
connect(m_and_button, &QPushButton::clicked, [this] { AppendSelectedOption(" & "); });
connect(m_or_button, &QPushButton::clicked, [this] { AppendSelectedOption(" | "); });
connect(m_not_button, &QPushButton::clicked, [this] { AppendSelectedOption("!"); });
connect(m_type == IOWindow::Type::Input ? m_detect_button : m_test_button, &QPushButton::clicked,
this, &IOWindow::OnDetectButtonPressed);
connect(m_button_box, &QDialogButtonBox::clicked, this, &IOWindow::OnDialogButtonPressed);
connect(m_devices_combo, &QComboBox::currentTextChanged, this, &IOWindow::OnDeviceChanged);
connect(m_range_spinbox, static_cast<void (QSpinBox::*)(int value)>(&QSpinBox::valueChanged),
this, &IOWindow::OnRangeChanged);
connect(m_range_slider, static_cast<void (QSlider::*)(int value)>(&QSlider::valueChanged), this,
&IOWindow::OnRangeChanged);
}
void IOWindow::AppendSelectedOption(const std::string& prefix)
{
if (m_option_list->currentItem() == nullptr)
return;
m_expression_text->insertPlainText(
QString::fromStdString(prefix) +
MappingCommon::GetExpressionForControl(m_option_list->currentItem()->text(), m_devq,
m_controller->GetDefaultDevice()));
}
void IOWindow::OnDeviceChanged(const QString& device)
{
m_devq.FromString(device.toStdString());
UpdateOptionList();
}
void IOWindow::OnDialogButtonPressed(QAbstractButton* button)
{
if (button == m_clear_button)
{
m_expression_text->clear();
return;
}
m_reference->SetExpression(m_expression_text->toPlainText().toStdString());
if (button != m_apply_button)
accept();
}
void IOWindow::OnDetectButtonPressed()
{
installEventFilter(BlockUserInputFilter::Instance());
grabKeyboard();
grabMouse();
std::thread([this] {
auto* btn = m_type == IOWindow::Type::Input ? m_detect_button : m_test_button;
const auto old_label = btn->text();
btn->setText(QStringLiteral("..."));
const auto expr = MappingCommon::DetectExpression(
m_reference, g_controller_interface.FindDevice(m_devq).get(), m_devq);
btn->setText(old_label);
if (!expr.isEmpty())
{
const auto list = m_option_list->findItems(expr, Qt::MatchFixedString);
if (list.size() > 0)
m_option_list->setCurrentItem(list[0]);
}
releaseMouse();
releaseKeyboard();
removeEventFilter(BlockUserInputFilter::Instance());
})
.detach();
}
void IOWindow::OnRangeChanged(int value)
{
m_reference->range = static_cast<double>(value) / SLIDER_TICK_COUNT;
m_range_spinbox->setValue(m_reference->range * SLIDER_TICK_COUNT);
m_range_slider->setValue(m_reference->range * SLIDER_TICK_COUNT);
}
void IOWindow::UpdateOptionList()
{
m_option_list->clear();
const auto device = g_controller_interface.FindDevice(m_devq);
if (device == nullptr)
return;
if (m_reference->IsInput())
{
for (const auto* input : device->Inputs())
{
m_option_list->addItem(QString::fromStdString(input->GetName()));
}
}
else
{
for (const auto* output : device->Outputs())
{
m_option_list->addItem(QString::fromStdString(output->GetName()));
}
}
}
void IOWindow::UpdateDeviceList()
{
m_devices_combo->clear();
Core::RunAsCPUThread([&] {
g_controller_interface.RefreshDevices();
m_controller->UpdateReferences(g_controller_interface);
// Adding default device regardless if it's currently connected or not
const auto default_device = m_controller->GetDefaultDevice().ToString();
m_devices_combo->addItem(QString::fromStdString(default_device));
for (const auto& name : g_controller_interface.GetAllDeviceStrings())
{
if (name != default_device)
m_devices_combo->addItem(QString::fromStdString(name));
}
m_devices_combo->setCurrentIndex(0);
});
}

View File

@ -0,0 +1,96 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QDialog>
#include <QString>
#include "Common/Flag.h"
#include "InputCommon/ControllerInterface/Device.h"
class ControlReference;
class QAbstractButton;
class QComboBox;
class QDialogButtonBox;
class QListWidget;
class QVBoxLayout;
class QWidget;
class QPlainTextEdit;
class QPushButton;
class QSlider;
class QSpinBox;
namespace ControllerEmu
{
class EmulatedController;
}
class IOWindow final : public QDialog
{
Q_OBJECT
public:
enum class Type
{
Input,
Output
};
explicit IOWindow(QWidget* parent, ControllerEmu::EmulatedController* m_controller,
ControlReference* ref, Type type);
private:
void CreateMainLayout();
void ConnectWidgets();
void Update();
void OnDialogButtonPressed(QAbstractButton* button);
void OnDeviceChanged(const QString& device);
void OnDetectButtonPressed();
void OnRangeChanged(int range);
void AppendSelectedOption(const std::string& prefix);
void UpdateOptionList();
void UpdateDeviceList();
// Main Layout
QVBoxLayout* m_main_layout;
// Devices
QComboBox* m_devices_combo;
// Options
QListWidget* m_option_list;
// Range
QSlider* m_range_slider;
QSpinBox* m_range_spinbox;
// Shared actions
QPushButton* m_select_button;
QPushButton* m_or_button;
// Input actions
QPushButton* m_detect_button;
QPushButton* m_and_button;
QPushButton* m_not_button;
QPushButton* m_add_button;
// Output actions
QPushButton* m_test_button;
// Textarea
QPlainTextEdit* m_expression_text;
// Buttonbox
QDialogButtonBox* m_button_box;
QPushButton* m_clear_button;
QPushButton* m_apply_button;
ControlReference* m_reference;
ControllerEmu::EmulatedController* m_controller;
ciface::Core::DeviceQualifier m_devq;
Type m_type;
};

View File

@ -0,0 +1,39 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingBool.h"
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
: QCheckBox(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting)
{
Update();
Connect();
}
void MappingBool::Connect()
{
connect(this, &QCheckBox::stateChanged, this, [this](int value) {
m_setting->SetValue(value);
m_parent->SaveSettings();
m_parent->GetController()->UpdateReferences(g_controller_interface);
});
}
void MappingBool::Clear()
{
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingBool::Update()
{
setChecked(m_setting->GetValue());
}

View File

@ -0,0 +1,29 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QCheckBox>
class MappingWidget;
namespace ControllerEmu
{
class BooleanSetting;
};
class MappingBool : public QCheckBox
{
public:
MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
void Clear();
void Update();
private:
void Connect();
MappingWidget* m_parent;
ControllerEmu::BooleanSetting* m_setting;
};

View File

@ -0,0 +1,235 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <future>
#include <thread>
#include <utility>
#include <QApplication>
#include <QFontMetrics>
#include <QMouseEvent>
#include <QRegExp>
#include <QString>
#include <QTimer>
#include "DolphinQt/Config/Mapping/MappingButton.h"
#include "Common/Thread.h"
#include "Core/Core.h"
#include "DolphinQt/Config/Mapping/IOWindow.h"
#include "DolphinQt/Config/Mapping/MappingCommon.h"
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/QtUtils/BlockUserInputFilter.h"
#include "DolphinQt/Settings.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Device.h"
constexpr int SLIDER_TICK_COUNT = 100;
constexpr int VERTICAL_PADDING = 2;
static QString EscapeAmpersand(QString&& string)
{
return string.replace(QStringLiteral("&"), QStringLiteral("&&"));
}
bool MappingButton::IsInput() const
{
return m_reference->IsInput();
}
MappingButton::MappingButton(MappingWidget* widget, ControlReference* ref, bool indicator)
: ElidedButton(EscapeAmpersand(QString::fromStdString(ref->GetExpression()))), m_parent(widget),
m_reference(ref)
{
// Force all mapping buttons to use stay at a minimal height
int height = QFontMetrics(qApp->font()).height() + 2 * VERTICAL_PADDING;
setMinimumHeight(height);
// macOS needs some wiggle room to always get round buttons
setMaximumHeight(height + 8);
// Make sure that long entries don't throw our layout out of whack
setMaximumWidth(115);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
Connect();
setToolTip(
tr("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
if (!m_reference->IsInput() || !indicator)
return;
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, [this] {
if (!isActiveWindow())
return;
Settings::Instance().SetControllerStateNeeded(true);
if (Core::GetState() == Core::State::Uninitialized || Core::GetState() == Core::State::Paused)
g_controller_interface.UpdateInput();
auto state = m_reference->State();
QFont f = m_parent->font();
QPalette p = m_parent->palette();
if (state != 0)
{
f.setBold(true);
p.setColor(QPalette::ButtonText, Qt::red);
}
setFont(f);
setPalette(p);
Settings::Instance().SetControllerStateNeeded(false);
});
m_timer->start(1000 / 30);
}
void MappingButton::Connect()
{
connect(this, &MappingButton::pressed, this, &MappingButton::Detect);
}
void MappingButton::Detect()
{
if (m_parent->GetDevice() == nullptr || !m_reference->IsInput())
return;
installEventFilter(BlockUserInputFilter::Instance());
grabKeyboard();
// Make sure that we don't block event handling
std::thread thread([this] {
setText(QStringLiteral("..."));
// Avoid that the button press itself is registered as an event
Common::SleepCurrentThread(100);
std::vector<std::future<std::pair<QString, QString>>> futures;
QString expr;
if (m_parent->GetParent()->IsMappingAllDevices())
{
for (const std::string& device_str : g_controller_interface.GetAllDeviceStrings())
{
ciface::Core::DeviceQualifier devq;
devq.FromString(device_str);
auto dev = g_controller_interface.FindDevice(devq);
auto future = std::async(std::launch::async, [this, devq, dev, device_str] {
return std::make_pair(
QString::fromStdString(device_str),
MappingCommon::DetectExpression(m_reference, dev.get(),
m_parent->GetController()->GetDefaultDevice()));
});
futures.push_back(std::move(future));
}
bool done = false;
while (!done)
{
for (auto& future : futures)
{
const auto status = future.wait_for(std::chrono::milliseconds(10));
if (status == std::future_status::ready)
{
const auto pair = future.get();
done = true;
if (pair.second.isEmpty())
break;
expr = QStringLiteral("`%1:%2`")
.arg(pair.first)
.arg(pair.second.startsWith(QLatin1Char('`')) ? pair.second.mid(1) :
pair.second);
break;
}
}
}
}
else
{
const auto dev = m_parent->GetDevice();
expr = MappingCommon::DetectExpression(m_reference, dev.get(),
m_parent->GetController()->GetDefaultDevice());
}
releaseKeyboard();
removeEventFilter(BlockUserInputFilter::Instance());
if (!expr.isEmpty())
{
m_reference->SetExpression(expr.toStdString());
m_parent->SaveSettings();
Update();
m_parent->GetController()->UpdateReferences(g_controller_interface);
if (m_parent->IsIterativeInput())
m_parent->NextButton(this);
}
else
{
OnButtonTimeout();
}
});
thread.detach();
}
void MappingButton::OnButtonTimeout()
{
setText(EscapeAmpersand(QString::fromStdString(m_reference->GetExpression())));
}
void MappingButton::Clear()
{
m_reference->SetExpression("");
m_reference->range = 100.0 / SLIDER_TICK_COUNT;
m_parent->SaveSettings();
Update();
}
void MappingButton::Update()
{
const auto lock = ControllerEmu::EmulatedController::GetStateLock();
m_reference->UpdateReference(g_controller_interface,
m_parent->GetController()->GetDefaultDevice());
setText(EscapeAmpersand(QString::fromStdString(m_reference->GetExpression())));
}
void MappingButton::mouseReleaseEvent(QMouseEvent* event)
{
switch (event->button())
{
case Qt::MouseButton::LeftButton:
if (m_reference->IsInput())
QPushButton::mouseReleaseEvent(event);
else
emit AdvancedPressed();
return;
case Qt::MouseButton::MidButton:
Clear();
return;
case Qt::MouseButton::RightButton:
emit AdvancedPressed();
return;
default:
return;
}
}

View File

@ -0,0 +1,39 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "Common/Flag.h"
#include "DolphinQt/QtUtils/ElidedButton.h"
class ControlReference;
class MappingWidget;
class QEvent;
class QMouseEvent;
class QTimer;
class MappingButton : public ElidedButton
{
Q_OBJECT
public:
MappingButton(MappingWidget* widget, ControlReference* ref, bool indicator);
void Clear();
void Update();
void Detect();
bool IsInput() const;
signals:
void AdvancedPressed();
private:
void mouseReleaseEvent(QMouseEvent* event) override;
void OnButtonTimeout();
void Connect();
MappingWidget* m_parent;
ControlReference* m_reference;
QTimer* m_timer;
};

View File

@ -0,0 +1,49 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingCommon.h"
#include <QRegExp>
#include <QString>
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerInterface/Device.h"
namespace MappingCommon
{
QString GetExpressionForControl(const QString& control_name,
const ciface::Core::DeviceQualifier& control_device,
const ciface::Core::DeviceQualifier& default_device)
{
QString expr;
// non-default device
if (control_device != default_device)
{
expr += QString::fromStdString(control_device.ToString());
expr += QStringLiteral(":");
}
// append the control name
expr += control_name;
QRegExp reg(QStringLiteral("[a-zA-Z]+"));
if (!reg.exactMatch(expr))
expr = QStringLiteral("`%1`").arg(expr);
return expr;
}
QString DetectExpression(ControlReference* reference, ciface::Core::Device* device,
const ciface::Core::DeviceQualifier& default_device)
{
ciface::Core::Device::Control* const ctrl = reference->Detect(5000, device);
if (ctrl)
{
return MappingCommon::GetExpressionForControl(QString::fromStdString(ctrl->GetName()),
default_device, default_device);
}
return QStringLiteral("");
}
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
class QString;
class ControlReference;
namespace ciface
{
namespace Core
{
class Device;
class DeviceQualifier;
}
}
namespace MappingCommon
{
QString GetExpressionForControl(const QString& control_name,
const ciface::Core::DeviceQualifier& control_device,
const ciface::Core::DeviceQualifier& default_device);
QString DetectExpression(ControlReference* reference, ciface::Core::Device* device,
const ciface::Core::DeviceQualifier& default_device);
}

View File

@ -0,0 +1,292 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
#include <array>
#include <cmath>
#include <QPainter>
#include <QTimer>
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerInterface/Device.h"
#include "DolphinQt/Settings.h"
MappingIndicator::MappingIndicator(ControllerEmu::ControlGroup* group) : m_group(group)
{
setMinimumHeight(128);
switch (m_group->type)
{
case ControllerEmu::GroupType::Cursor:
BindCursorControls(false);
break;
case ControllerEmu::GroupType::Stick:
BindStickControls();
break;
case ControllerEmu::GroupType::Tilt:
BindCursorControls(true);
break;
case ControllerEmu::GroupType::MixedTriggers:
BindMixedTriggersControls();
break;
default:
break;
}
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this, [this] { repaint(); });
m_timer->start(1000 / 30);
}
void MappingIndicator::BindCursorControls(bool tilt)
{
m_cursor_up = m_group->controls[0]->control_ref.get();
m_cursor_down = m_group->controls[1]->control_ref.get();
m_cursor_left = m_group->controls[2]->control_ref.get();
m_cursor_right = m_group->controls[3]->control_ref.get();
if (!tilt)
{
m_cursor_forward = m_group->controls[4]->control_ref.get();
m_cursor_backward = m_group->controls[5]->control_ref.get();
m_cursor_center = m_group->numeric_settings[0].get();
m_cursor_width = m_group->numeric_settings[1].get();
m_cursor_height = m_group->numeric_settings[2].get();
m_cursor_deadzone = m_group->numeric_settings[3].get();
}
else
{
m_cursor_deadzone = m_group->numeric_settings[0].get();
}
}
void MappingIndicator::BindStickControls()
{
m_stick_up = m_group->controls[0]->control_ref.get();
m_stick_down = m_group->controls[1]->control_ref.get();
m_stick_left = m_group->controls[2]->control_ref.get();
m_stick_right = m_group->controls[3]->control_ref.get();
m_stick_modifier = m_group->controls[4]->control_ref.get();
m_stick_radius = m_group->numeric_settings[0].get();
m_stick_deadzone = m_group->numeric_settings[1].get();
}
void MappingIndicator::BindMixedTriggersControls()
{
m_mixed_triggers_l_button = m_group->controls[0]->control_ref.get();
m_mixed_triggers_r_button = m_group->controls[1]->control_ref.get();
m_mixed_triggers_l_analog = m_group->controls[2]->control_ref.get();
m_mixed_triggers_r_analog = m_group->controls[3]->control_ref.get();
m_mixed_triggers_threshold = m_group->numeric_settings[0].get();
}
static ControlState PollControlState(ControlReference* ref)
{
Settings::Instance().SetControllerStateNeeded(true);
auto state = ref->State();
Settings::Instance().SetControllerStateNeeded(false);
if (state != 0)
return state;
else
return 0;
}
void MappingIndicator::DrawCursor(bool tilt)
{
float centerx = width() / 2., centery = height() / 2.;
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
float width = 64, height = 64;
float deadzone = m_cursor_deadzone->GetValue() * 48;
if (!tilt)
{
float depth = centery - PollControlState(m_cursor_forward) * this->height() / 2.5 +
PollControlState(m_cursor_backward) * this->height() / 2.5;
p.fillRect(0, depth, this->width(), 4, Qt::gray);
width *= m_cursor_width->GetValue();
height *= m_cursor_height->GetValue();
}
float curx = centerx - 4 - std::min(PollControlState(m_cursor_left), 0.5) * width +
std::min(PollControlState(m_cursor_right), 0.5) * width,
cury = centery - 4 - std::min(PollControlState(m_cursor_up), 0.5) * height +
std::min(PollControlState(m_cursor_down), 0.5) * height;
// Draw background
p.setBrush(Qt::white);
p.setPen(Qt::black);
p.drawRect(centerx - (width / 2), centery - (height / 2), width, height);
// Draw deadzone
p.setBrush(Qt::lightGray);
p.drawEllipse(centerx - (deadzone / 2), centery - (deadzone / 2), deadzone, deadzone);
// Draw cursor
p.fillRect(curx, cury, 8, 8, Qt::red);
}
void MappingIndicator::DrawStick()
{
float centerx = width() / 2., centery = height() / 2.;
bool c_stick = m_group->name == "C-Stick";
bool classic_controller = m_group->name == "Left Stick" || m_group->name == "Right Stick";
float ratio = 1;
if (c_stick)
ratio = 1.;
else if (classic_controller)
ratio = 0.9f;
// Polled values
float mod = PollControlState(m_stick_modifier) ? 0.5 : 1;
float radius = m_stick_radius->GetValue();
float curx = -PollControlState(m_stick_left) + PollControlState(m_stick_right),
cury = -PollControlState(m_stick_up) + PollControlState(m_stick_down);
// The maximum deadzone value covers 50% of the stick area
float deadzone = m_stick_deadzone->GetValue() / 2.;
// Size parameters
float max_size = (height() / 2.5) / ratio;
float stick_size = (height() / 3.) / ratio;
// Emulated cursor position
float virt_curx, virt_cury;
if (std::abs(curx) < deadzone && std::abs(cury) < deadzone)
{
virt_curx = virt_cury = 0;
}
else
{
virt_curx = curx * mod;
virt_cury = cury * mod;
}
// Coordinates for an octagon
std::array<QPointF, 8> radius_octagon = {{
QPointF(centerx, centery + stick_size), // Bottom
QPointF(centerx + stick_size / sqrt(2), centery + stick_size / sqrt(2)), // Bottom Right
QPointF(centerx + stick_size, centery), // Right
QPointF(centerx + stick_size / sqrt(2), centery - stick_size / sqrt(2)), // Top Right
QPointF(centerx, centery - stick_size), // Top
QPointF(centerx - stick_size / sqrt(2), centery - stick_size / sqrt(2)), // Top Left
QPointF(centerx - stick_size, centery), // Left
QPointF(centerx - stick_size / sqrt(2), centery + stick_size / sqrt(2)) // Bottom Left
}};
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
// Draw maximum values
p.setBrush(Qt::white);
p.setPen(Qt::black);
p.drawRect(centerx - max_size, centery - max_size, max_size * 2, max_size * 2);
// Draw radius
p.setBrush(c_stick ? Qt::yellow : Qt::darkGray);
p.drawPolygon(radius_octagon.data(), static_cast<int>(radius_octagon.size()));
// Draw deadzone
p.setBrush(c_stick ? Qt::darkYellow : Qt::lightGray);
p.drawEllipse(centerx - deadzone * stick_size, centery - deadzone * stick_size,
deadzone * stick_size * 2, deadzone * stick_size * 2);
// Draw stick
p.setBrush(Qt::black);
p.drawEllipse(centerx - 4 + curx * max_size, centery - 4 + cury * max_size, 8, 8);
// Draw virtual stick
p.setBrush(Qt::red);
p.drawEllipse(centerx - 4 + virt_curx * max_size * radius,
centery - 4 + virt_cury * max_size * radius, 8, 8);
}
void MappingIndicator::DrawMixedTriggers()
{
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::TextAntialiasing, true);
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
// Polled values
double r_analog = PollControlState(m_mixed_triggers_r_analog);
double r_button = PollControlState(m_mixed_triggers_r_button);
double l_analog = PollControlState(m_mixed_triggers_l_analog);
double l_button = PollControlState(m_mixed_triggers_l_button);
double threshold = m_mixed_triggers_threshold->GetValue();
double r_bar_percent = r_analog;
double l_bar_percent = l_analog;
if ((r_button && r_button != r_analog) || (r_button == r_analog && r_analog > threshold))
r_bar_percent = 1;
else
r_bar_percent *= 0.8;
if ((l_button && l_button != l_analog) || (l_button == l_analog && l_analog > threshold))
l_bar_percent = 1;
else
l_bar_percent *= 0.8;
p.fillRect(0, 0, width(), 64, Qt::black);
p.fillRect(0, 0, l_bar_percent * width(), 32, Qt::red);
p.fillRect(0, 32, r_bar_percent * width(), 32, Qt::red);
p.setPen(Qt::white);
p.drawLine(width() * 0.8, 0, width() * 0.8, 63);
p.drawLine(0, 32, width(), 32);
p.setPen(Qt::green);
p.drawLine(width() * 0.8 * threshold, 0, width() * 0.8 * threshold, 63);
p.setBrush(Qt::black);
p.setPen(Qt::white);
p.drawText(width() * 0.225, 20, tr("L-Analog"));
p.drawText(width() * 0.8 + 16, 20, tr("L"));
p.drawText(width() * 0.225, 52, tr("R-Analog"));
p.drawText(width() * 0.8 + 16, 52, tr("R"));
}
void MappingIndicator::paintEvent(QPaintEvent*)
{
switch (m_group->type)
{
case ControllerEmu::GroupType::Cursor:
DrawCursor(false);
break;
case ControllerEmu::GroupType::Tilt:
DrawCursor(true);
break;
case ControllerEmu::GroupType::Stick:
DrawStick();
break;
case ControllerEmu::GroupType::MixedTriggers:
DrawMixedTriggers();
break;
default:
break;
}
}

View File

@ -0,0 +1,70 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QWidget>
namespace ControllerEmu
{
class Control;
class ControlGroup;
class NumericSetting;
}
class QPaintEvent;
class QTimer;
class ControlReference;
class MappingIndicator : public QWidget
{
public:
explicit MappingIndicator(ControllerEmu::ControlGroup* group);
private:
void BindCursorControls(bool tilt);
void BindStickControls();
void BindMixedTriggersControls();
void DrawCursor(bool tilt);
void DrawStick();
void DrawMixedTriggers();
void paintEvent(QPaintEvent*) override;
ControllerEmu::ControlGroup* m_group;
// Stick settings
ControlReference* m_stick_up;
ControlReference* m_stick_down;
ControlReference* m_stick_left;
ControlReference* m_stick_right;
ControlReference* m_stick_modifier;
ControllerEmu::NumericSetting* m_stick_radius;
ControllerEmu::NumericSetting* m_stick_deadzone;
// Cursor settings
ControlReference* m_cursor_up;
ControlReference* m_cursor_down;
ControlReference* m_cursor_left;
ControlReference* m_cursor_right;
ControlReference* m_cursor_forward;
ControlReference* m_cursor_backward;
ControllerEmu::NumericSetting* m_cursor_center;
ControllerEmu::NumericSetting* m_cursor_width;
ControllerEmu::NumericSetting* m_cursor_height;
ControllerEmu::NumericSetting* m_cursor_deadzone;
// Triggers settings
ControlReference* m_mixed_triggers_r_analog;
ControlReference* m_mixed_triggers_r_button;
ControlReference* m_mixed_triggers_l_analog;
ControlReference* m_mixed_triggers_l_button;
ControllerEmu::NumericSetting* m_mixed_triggers_threshold;
QTimer* m_timer;
};

View File

@ -0,0 +1,41 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
MappingNumeric::MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* setting)
: m_parent(widget), m_setting(setting)
{
setRange(setting->m_low, setting->m_high);
Update();
Connect();
}
void MappingNumeric::Connect()
{
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](int value) {
m_setting->SetValue(static_cast<double>(value) / 100);
m_parent->SaveSettings();
m_parent->GetController()->UpdateReferences(g_controller_interface);
});
}
void MappingNumeric::Clear()
{
m_setting->SetValue(m_setting->m_default_value);
m_parent->SaveSettings();
Update();
}
void MappingNumeric::Update()
{
setValue(m_setting->GetValue() * 100);
}

View File

@ -0,0 +1,30 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QSpinBox>
#include <QString>
class MappingWidget;
namespace ControllerEmu
{
class NumericSetting;
}
class MappingNumeric : public QSpinBox
{
public:
MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* ref);
void Clear();
void Update();
private:
void Connect();
MappingWidget* m_parent;
ControllerEmu::NumericSetting* m_setting;
};

View File

@ -0,0 +1,39 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingRadio.h"
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
MappingRadio::MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
: QRadioButton(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting)
{
Update();
Connect();
}
void MappingRadio::Connect()
{
connect(this, &QRadioButton::toggled, this, [this](int value) {
m_setting->SetValue(value);
m_parent->SaveSettings();
m_parent->GetController()->UpdateReferences(g_controller_interface);
});
}
void MappingRadio::Clear()
{
m_setting->SetValue(false);
m_parent->SaveSettings();
Update();
}
void MappingRadio::Update()
{
setChecked(m_setting->GetValue());
}

View File

@ -0,0 +1,29 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QRadioButton>
class MappingWidget;
namespace ControllerEmu
{
class BooleanSetting;
};
class MappingRadio : public QRadioButton
{
public:
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
void Clear();
void Update();
private:
void Connect();
MappingWidget* m_parent;
ControllerEmu::BooleanSetting* m_setting;
};

View File

@ -0,0 +1,179 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include <QFormLayout>
#include <QGroupBox>
#include <QPushButton>
#include "DolphinQt/Config/Mapping/IOWindow.h"
#include "DolphinQt/Config/Mapping/MappingBool.h"
#include "DolphinQt/Config/Mapping/MappingButton.h"
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
#include "DolphinQt/Config/Mapping/MappingRadio.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
MappingWidget::MappingWidget(MappingWindow* window) : m_parent(window)
{
connect(window, &MappingWindow::ClearFields, this, &MappingWidget::OnClearFields);
connect(window, &MappingWindow::Update, this, &MappingWidget::Update);
connect(window, &MappingWindow::Save, this, &MappingWidget::SaveSettings);
}
MappingWindow* MappingWidget::GetParent() const
{
return m_parent;
}
bool MappingWidget::IsIterativeInput() const
{
return m_parent->IsIterativeInput();
}
void MappingWidget::NextButton(MappingButton* button)
{
auto iterator = std::find(m_buttons.begin(), m_buttons.end(), button);
if (iterator == m_buttons.end())
return;
if (++iterator == m_buttons.end())
return;
MappingButton* next = *iterator;
if (next->IsInput() && next->isVisible())
next->Detect();
else
NextButton(next);
}
std::shared_ptr<ciface::Core::Device> MappingWidget::GetDevice() const
{
return m_parent->GetDevice();
}
int MappingWidget::GetPort() const
{
return m_parent->GetPort();
}
QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::ControlGroup* group)
{
QGroupBox* group_box = new QGroupBox(name);
QFormLayout* form_layout = new QFormLayout();
group_box->setLayout(form_layout);
bool need_indicator = group->type == ControllerEmu::GroupType::Cursor ||
group->type == ControllerEmu::GroupType::Stick ||
group->type == ControllerEmu::GroupType::Tilt ||
group->type == ControllerEmu::GroupType::MixedTriggers;
for (auto& control : group->controls)
{
auto* button = new MappingButton(this, control->control_ref.get(), !need_indicator);
button->setMinimumWidth(100);
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
const bool translate = control->translate == ControllerEmu::Translate;
const QString translated_name =
translate ? tr(control->ui_name.c_str()) : QString::fromStdString(control->ui_name);
form_layout->addRow(translated_name, button);
auto* control_ref = control->control_ref.get();
connect(button, &MappingButton::AdvancedPressed, [this, button, control_ref] {
if (m_parent->GetDevice() == nullptr)
return;
IOWindow io(this, m_parent->GetController(), control_ref,
control_ref->IsInput() ? IOWindow::Type::Input : IOWindow::Type::Output);
io.exec();
SaveSettings();
button->Update();
});
m_buttons.push_back(button);
}
for (auto& numeric : group->numeric_settings)
{
auto* spinbox = new MappingNumeric(this, numeric.get());
form_layout->addRow(tr(numeric->m_name.c_str()), spinbox);
m_numerics.push_back(spinbox);
}
for (auto& boolean : group->boolean_settings)
{
if (!boolean->IsExclusive())
continue;
auto* checkbox = new MappingRadio(this, boolean.get());
form_layout->addRow(checkbox);
m_radio.push_back(checkbox);
}
for (auto& boolean : group->boolean_settings)
{
if (boolean->IsExclusive())
continue;
auto* checkbox = new MappingBool(this, boolean.get());
form_layout->addRow(checkbox);
m_bools.push_back(checkbox);
}
if (need_indicator)
form_layout->addRow(new MappingIndicator(group));
return group_box;
}
void MappingWidget::OnClearFields()
{
for (auto* button : m_buttons)
button->Clear();
for (auto* spinbox : m_numerics)
spinbox->Clear();
for (auto* checkbox : m_bools)
checkbox->Clear();
for (auto* radio : m_radio)
radio->Clear();
}
void MappingWidget::Update()
{
for (auto* button : m_buttons)
button->Update();
for (auto* spinbox : m_numerics)
spinbox->Update();
for (auto* checkbox : m_bools)
checkbox->Update();
for (auto* radio : m_radio)
radio->Update();
SaveSettings();
}
ControllerEmu::EmulatedController* MappingWidget::GetController() const
{
return m_parent->GetController();
}

View File

@ -0,0 +1,71 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <vector>
#include <QString>
#include <QWidget>
class ControlGroupBox;
class InputConfig;
class IOWindow;
class MappingBool;
class MappingButton;
class MappingNumeric;
class MappingWindow;
class MappingRadio;
class QGroupBox;
namespace ControllerEmu
{
class Control;
class ControlGroup;
class EmulatedController;
} // namespace ControllerEmu
namespace ciface
{
namespace Core
{
class Device;
}
} // namespace ciface
class MappingWidget : public QWidget
{
Q_OBJECT
public:
explicit MappingWidget(MappingWindow* window);
ControllerEmu::EmulatedController* GetController() const;
std::shared_ptr<ciface::Core::Device> GetDevice() const;
MappingWindow* GetParent() const;
bool IsIterativeInput() const;
void NextButton(MappingButton* button);
virtual void LoadSettings() = 0;
virtual void SaveSettings() = 0;
virtual InputConfig* GetConfig() = 0;
void Update();
protected:
int GetPort() const;
QGroupBox* CreateGroupBox(const QString& name, ControllerEmu::ControlGroup* group);
private:
void OnClearFields();
MappingWindow* m_parent;
bool m_first = true;
std::vector<MappingBool*> m_bools;
std::vector<MappingRadio*> m_radio;
std::vector<MappingButton*> m_buttons;
std::vector<MappingNumeric*> m_numerics;
};

View File

@ -0,0 +1,374 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include <QCheckBox>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QMessageBox>
#include <QPushButton>
#include <QTabWidget>
#include <QVBoxLayout>
#include "Common/FileSearch.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/StringUtil.h"
#include "Core/Core.h"
#include "DolphinQt/Config/Mapping/GCKeyboardEmu.h"
#include "DolphinQt/Config/Mapping/GCMicrophone.h"
#include "DolphinQt/Config/Mapping/GCPadEmu.h"
#include "DolphinQt/Config/Mapping/Hotkey3D.h"
#include "DolphinQt/Config/Mapping/HotkeyDebugging.h"
#include "DolphinQt/Config/Mapping/HotkeyGeneral.h"
#include "DolphinQt/Config/Mapping/HotkeyGraphics.h"
#include "DolphinQt/Config/Mapping/HotkeyStates.h"
#include "DolphinQt/Config/Mapping/HotkeyStatesOther.h"
#include "DolphinQt/Config/Mapping/HotkeyTAS.h"
#include "DolphinQt/Config/Mapping/HotkeyWii.h"
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
#include "DolphinQt/Config/Mapping/WiimoteEmuGeneral.h"
#include "DolphinQt/Config/Mapping/WiimoteEmuMotionControl.h"
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
#include "DolphinQt/Settings.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/Device.h"
#include "InputCommon/InputConfig.h"
constexpr const char* PROFILES_DIR = "Profiles/";
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);
CreateDevicesLayout();
CreateProfilesLayout();
CreateResetLayout();
CreateMainLayout();
ConnectWidgets();
SetMappingType(type);
}
void MappingWindow::CreateDevicesLayout()
{
m_devices_layout = new QHBoxLayout();
m_devices_box = new QGroupBox(tr("Device"));
m_devices_combo = new QComboBox();
m_devices_refresh = new QPushButton(tr("Refresh"));
m_devices_refresh->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_devices_layout->addWidget(m_devices_combo);
m_devices_layout->addWidget(m_devices_refresh);
m_devices_box->setLayout(m_devices_layout);
}
void MappingWindow::CreateProfilesLayout()
{
m_profiles_layout = new QHBoxLayout();
m_profiles_box = new QGroupBox(tr("Profile"));
m_profiles_combo = new QComboBox();
m_profiles_load = new QPushButton(tr("Load"));
m_profiles_save = new QPushButton(tr("Save"));
m_profiles_delete = new QPushButton(tr("Delete"));
auto* button_layout = new QHBoxLayout();
m_profiles_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_profiles_combo->setEditable(true);
m_profiles_layout->addWidget(m_profiles_combo);
button_layout->addWidget(m_profiles_load);
button_layout->addWidget(m_profiles_save);
button_layout->addWidget(m_profiles_delete);
m_profiles_layout->addLayout(button_layout);
m_profiles_box->setLayout(m_profiles_layout);
}
void MappingWindow::CreateResetLayout()
{
m_reset_layout = new QHBoxLayout();
m_reset_box = new QGroupBox(tr("Reset"));
m_reset_clear = new QPushButton(tr("Clear"));
m_reset_default = new QPushButton(tr("Default"));
m_reset_box->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_reset_layout->addWidget(m_reset_default);
m_reset_layout->addWidget(m_reset_clear);
m_reset_box->setLayout(m_reset_layout);
}
void MappingWindow::CreateMainLayout()
{
m_main_layout = new QVBoxLayout();
m_config_layout = new QHBoxLayout();
m_iterative_input = new QCheckBox(tr("Iterative Input"));
m_tab_widget = new QTabWidget();
m_button_box = new QDialogButtonBox(QDialogButtonBox::Close);
m_iterative_input->setToolTip(tr("Automatically progress one button after another during "
"configuration. Useful for first-time setup."));
m_config_layout->addWidget(m_devices_box);
m_config_layout->addWidget(m_reset_box);
m_config_layout->addWidget(m_profiles_box);
m_main_layout->addLayout(m_config_layout);
m_main_layout->addWidget(m_iterative_input);
m_main_layout->addWidget(m_tab_widget);
m_main_layout->addWidget(m_button_box);
setLayout(m_main_layout);
}
void MappingWindow::ConnectWidgets()
{
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(m_devices_refresh, &QPushButton::clicked, this, &MappingWindow::RefreshDevices);
connect(m_devices_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MappingWindow::OnDeviceChanged);
connect(m_reset_clear, &QPushButton::clicked, this, [this] { emit ClearFields(); });
connect(m_reset_default, &QPushButton::clicked, this, &MappingWindow::OnDefaultFieldsPressed);
connect(m_profiles_save, &QPushButton::clicked, this, &MappingWindow::OnSaveProfilePressed);
connect(m_profiles_load, &QPushButton::clicked, this, &MappingWindow::OnLoadProfilePressed);
connect(m_profiles_delete, &QPushButton::clicked, this, &MappingWindow::OnDeleteProfilePressed);
}
void MappingWindow::OnDeleteProfilePressed()
{
const QString profile_name = m_profiles_combo->currentText();
const QString profile_path = m_profiles_combo->currentData().toString();
if (!File::Exists(profile_path.toStdString()))
{
QMessageBox error(this);
error.setIcon(QMessageBox::Critical);
error.setWindowTitle(tr("Error"));
error.setText(tr("The profile '%1' does not exist").arg(profile_name));
error.exec();
return;
}
QMessageBox confirm(this);
confirm.setIcon(QMessageBox::Warning);
confirm.setWindowTitle(tr("Confirm"));
confirm.setText(tr("Are you sure that you want to delete '%1'?").arg(profile_name));
confirm.setInformativeText(tr("This cannot be undone!"));
confirm.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
if (confirm.exec() != QMessageBox::Yes)
{
return;
}
m_profiles_combo->removeItem(m_profiles_combo->currentIndex());
File::Delete(profile_path.toStdString());
QMessageBox result(this);
result.setIcon(QMessageBox::Information);
result.setWindowTitle(tr("Success"));
result.setText(tr("Successfully deleted '%1'.").arg(profile_name));
}
void MappingWindow::OnLoadProfilePressed()
{
const QString profile_path = m_profiles_combo->currentData().toString();
if (m_profiles_combo->currentIndex() == 0)
return;
IniFile ini;
ini.Load(profile_path.toStdString());
m_controller->LoadConfig(ini.GetOrCreateSection("Profile"));
m_controller->UpdateReferences(g_controller_interface);
emit Update();
RefreshDevices();
}
void MappingWindow::OnSaveProfilePressed()
{
const QString profile_name = m_profiles_combo->currentText();
const std::string profile_path = File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR +
m_config->GetProfileName() + "/" + profile_name.toStdString() +
".ini";
if (profile_name.isEmpty())
return;
File::CreateFullPath(profile_path);
IniFile ini;
m_controller->SaveConfig(ini.GetOrCreateSection("Profile"));
ini.Save(profile_path);
if (m_profiles_combo->currentIndex() == 0 || m_profiles_combo->findText(profile_name) == -1)
{
m_profiles_combo->addItem(profile_name, QString::fromStdString(profile_path));
m_profiles_combo->setCurrentIndex(m_profiles_combo->count() - 1);
}
}
void MappingWindow::OnDeviceChanged(int index)
{
if (IsMappingAllDevices())
return;
const auto device = m_devices_combo->currentText().toStdString();
m_controller->SetDefaultDevice(device);
}
bool MappingWindow::IsMappingAllDevices() const
{
return m_devices_combo->currentIndex() == m_devices_combo->count() - 1;
}
void MappingWindow::RefreshDevices()
{
m_devices_combo->clear();
Core::RunAsCPUThread([&] {
g_controller_interface.RefreshDevices();
m_controller->UpdateReferences(g_controller_interface);
const auto default_device = m_controller->GetDefaultDevice().ToString();
if (!default_device.empty())
m_devices_combo->addItem(QString::fromStdString(default_device));
for (const auto& name : g_controller_interface.GetAllDeviceStrings())
{
if (name != default_device)
m_devices_combo->addItem(QString::fromStdString(name));
}
m_devices_combo->addItem(tr("All devices"));
m_devices_combo->setCurrentIndex(0);
});
}
void MappingWindow::SetMappingType(MappingWindow::Type type)
{
MappingWidget* widget;
switch (type)
{
case Type::MAPPING_GC_KEYBOARD:
widget = new GCKeyboardEmu(this);
AddWidget(tr("GameCube Keyboard"), widget);
setWindowTitle(tr("GameCube Keyboard at Port %1").arg(GetPort() + 1));
break;
case Type::MAPPING_GC_BONGOS:
case Type::MAPPING_GC_STEERINGWHEEL:
case Type::MAPPING_GC_DANCEMAT:
case Type::MAPPING_GCPAD:
widget = new GCPadEmu(this);
setWindowTitle(tr("GameCube Controller at Port %1").arg(GetPort() + 1));
AddWidget(tr("GameCube Controller"), widget);
break;
case Type::MAPPING_GC_MICROPHONE:
widget = new GCMicrophone(this);
setWindowTitle(tr("GameCube Microphone Slot %1")
.arg(GetPort() == 0 ? QStringLiteral("A") : QStringLiteral("B")));
AddWidget(tr("Microphone"), widget);
break;
case Type::MAPPING_WIIMOTE_EMU:
{
auto* extension = new WiimoteEmuExtension(this);
widget = new WiimoteEmuGeneral(this, extension);
setWindowTitle(tr("Wii Remote %1").arg(GetPort() + 1));
AddWidget(tr("General and Options"), widget);
AddWidget(tr("Motion Controls and IR"), new WiimoteEmuMotionControl(this));
AddWidget(tr("Extension"), extension);
break;
}
case Type::MAPPING_HOTKEYS:
{
widget = new HotkeyGeneral(this);
AddWidget(tr("General"), widget);
AddWidget(tr("TAS Tools"), new HotkeyTAS(this));
AddWidget(tr("Debugging"), new HotkeyDebugging(this));
AddWidget(tr("Wii and Wii Remote"), new HotkeyWii(this));
AddWidget(tr("Graphics"), new HotkeyGraphics(this));
AddWidget(tr("3D"), new Hotkey3D(this));
AddWidget(tr("Save and Load State"), new HotkeyStates(this));
AddWidget(tr("Other State Management"), new HotkeyStatesOther(this));
setWindowTitle(tr("Hotkey Settings"));
break;
}
default:
return;
}
widget->LoadSettings();
m_config = widget->GetConfig();
m_controller = m_config->GetController(GetPort());
m_profiles_combo->addItem(QStringLiteral(""));
const std::string profiles_path =
File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR + 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));
}
RefreshDevices();
}
void MappingWindow::AddWidget(const QString& name, QWidget* widget)
{
m_tab_widget->addTab(GetWrappedWidget(widget, this, 150, 205), name);
}
int MappingWindow::GetPort() const
{
return m_port;
}
ControllerEmu::EmulatedController* MappingWindow::GetController() const
{
return m_controller;
}
std::shared_ptr<ciface::Core::Device> MappingWindow::GetDevice() const
{
return g_controller_interface.FindDevice(GetController()->GetDefaultDevice());
}
void MappingWindow::OnDefaultFieldsPressed()
{
m_controller->LoadDefaults(g_controller_interface);
m_controller->UpdateReferences(g_controller_interface);
emit Update();
emit Save();
}
bool MappingWindow::IsIterativeInput() const
{
return m_iterative_input->isChecked();
}

View File

@ -0,0 +1,113 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QDialog>
#include <QString>
#include <memory>
#include "InputCommon/ControllerInterface/Device.h"
namespace ControllerEmu
{
class EmulatedController;
}
class InputConfig;
class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QEvent;
class QHBoxLayout;
class QGroupBox;
class QVBoxLayout;
class QPushButton;
class QTabWidget;
class QWidget;
class MappingWindow final : public QDialog
{
Q_OBJECT
public:
enum class Type
{
// GameCube
MAPPING_GC_BONGOS,
MAPPING_GC_DANCEMAT,
MAPPING_GC_KEYBOARD,
MAPPING_GCPAD,
MAPPING_GC_STEERINGWHEEL,
MAPPING_GC_MICROPHONE,
// Wii
MAPPING_WIIMOTE_EMU,
// Hotkeys
MAPPING_HOTKEYS
};
explicit MappingWindow(QWidget* parent, Type type, int port_num);
int GetPort() const;
std::shared_ptr<ciface::Core::Device> GetDevice() const;
ControllerEmu::EmulatedController* GetController() const;
bool IsIterativeInput() const;
bool IsMappingAllDevices() const;
signals:
void Update();
void ClearFields();
void Save();
private:
void SetMappingType(Type type);
void CreateDevicesLayout();
void CreateProfilesLayout();
void CreateResetLayout();
void CreateMainLayout();
void ConnectWidgets();
void AddWidget(const QString& name, QWidget* widget);
void RefreshDevices();
void OnDeleteProfilePressed();
void OnLoadProfilePressed();
void OnSaveProfilePressed();
void OnDefaultFieldsPressed();
void OnDeviceChanged(int index);
ControllerEmu::EmulatedController* m_controller = nullptr;
// Main
QCheckBox* m_iterative_input;
QVBoxLayout* m_main_layout;
QHBoxLayout* m_config_layout;
QDialogButtonBox* m_button_box;
// Devices
QGroupBox* m_devices_box;
QHBoxLayout* m_devices_layout;
QComboBox* m_devices_combo;
QPushButton* m_devices_refresh;
// Profiles
QGroupBox* m_profiles_box;
QHBoxLayout* m_profiles_layout;
QComboBox* m_profiles_combo;
QPushButton* m_profiles_load;
QPushButton* m_profiles_save;
QPushButton* m_profiles_delete;
// Reset
QGroupBox* m_reset_box;
QHBoxLayout* m_reset_layout;
QPushButton* m_reset_default;
QPushButton* m_reset_clear;
QTabWidget* m_tab_widget;
Type m_mapping_type;
const int m_port;
InputConfig* m_config;
};

View File

@ -0,0 +1,196 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "InputCommon/InputConfig.h"
WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(window)
{
CreateClassicLayout();
CreateDrumsLayout();
CreateGuitarLayout();
CreateNoneLayout();
CreateNunchukLayout();
CreateTurntableLayout();
CreateMainLayout();
ChangeExtensionType(Type::NONE);
}
void WiimoteEmuExtension::CreateClassicLayout()
{
auto* hbox = new QHBoxLayout();
m_classic_box = new QGroupBox(tr("Classic Controller"), this);
hbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Buttons)));
hbox->addWidget(CreateGroupBox(
tr("Left Stick"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::LeftStick)));
hbox->addWidget(
CreateGroupBox(tr("Right Stick"),
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::RightStick)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("D-Pad"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::DPad)));
vbox->addWidget(CreateGroupBox(
tr("Triggers"), Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Triggers)));
hbox->addLayout(vbox);
m_classic_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateDrumsLayout()
{
auto* hbox = new QHBoxLayout();
m_drums_box = new QGroupBox(tr("Drums"), this);
hbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Buttons)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(
CreateGroupBox(tr("Pads"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Pads)));
vbox->addWidget(CreateGroupBox(tr("Stick"),
Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Stick)));
hbox->addLayout(vbox);
m_drums_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateNoneLayout()
{
m_none_box = new QGroupBox(this);
auto* hbox = new QHBoxLayout();
auto* label = new QLabel(tr("No extension selected."));
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
hbox->addWidget(label);
m_none_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateNunchukLayout()
{
auto* hbox = new QHBoxLayout();
m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this);
hbox->addWidget(CreateGroupBox(
tr("Stick"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Stick)));
hbox->addWidget(CreateGroupBox(
tr("Tilt"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Tilt)));
hbox->addWidget(CreateGroupBox(
tr("Swing"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Swing)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Buttons)));
vbox->addWidget(CreateGroupBox(
tr("Shake"), Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Shake)));
hbox->addLayout(vbox);
m_nunchuk_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateGuitarLayout()
{
auto* hbox = new QHBoxLayout();
m_guitar_box = new QGroupBox(tr("Guitar"), this);
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Buttons)));
vbox->addWidget(CreateGroupBox(
tr("Stick"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Stick)));
vbox->addWidget(CreateGroupBox(
tr("Slider Bar"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::SliderBar)));
hbox->addLayout(vbox);
auto* vbox2 = new QVBoxLayout();
vbox2->addWidget(CreateGroupBox(
tr("Strum"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Strum)));
vbox2->addWidget(CreateGroupBox(
tr("Frets"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Frets)));
vbox2->addWidget(CreateGroupBox(
tr("Whammy"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Whammy)));
hbox->addLayout(vbox2);
m_guitar_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateTurntableLayout()
{
auto* hbox = new QHBoxLayout();
m_turntable_box = new QGroupBox(tr("Turntable"), this);
hbox->addWidget(CreateGroupBox(
tr("Stick"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Stick)));
hbox->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Buttons)));
auto* vbox = new QVBoxLayout();
vbox->addWidget(CreateGroupBox(
tr("Effect"), Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::EffectDial)));
vbox->addWidget(
// i18n: "Table" refers to a turntable
CreateGroupBox(tr("Left Table"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::LeftTable)));
vbox->addWidget(CreateGroupBox(
// i18n: "Table" refers to a turntable
tr("Right Table"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::RightTable)));
vbox->addWidget(
CreateGroupBox(tr("Crossfade"),
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Crossfade)));
hbox->addLayout(vbox);
m_turntable_box->setLayout(hbox);
}
void WiimoteEmuExtension::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(m_classic_box);
m_main_layout->addWidget(m_drums_box);
m_main_layout->addWidget(m_guitar_box);
m_main_layout->addWidget(m_none_box);
m_main_layout->addWidget(m_nunchuk_box);
m_main_layout->addWidget(m_turntable_box);
setLayout(m_main_layout);
}
void WiimoteEmuExtension::LoadSettings()
{
Wiimote::LoadConfig();
}
void WiimoteEmuExtension::SaveSettings()
{
Wiimote::GetConfig()->SaveConfig();
}
InputConfig* WiimoteEmuExtension::GetConfig()
{
return Wiimote::GetConfig();
}
void WiimoteEmuExtension::ChangeExtensionType(WiimoteEmuExtension::Type type)
{
m_classic_box->setHidden(type != Type::CLASSIC_CONTROLLER);
m_drums_box->setHidden(type != Type::DRUMS);
m_guitar_box->setHidden(type != Type::GUITAR);
m_none_box->setHidden(type != Type::NONE);
m_nunchuk_box->setHidden(type != Type::NUNCHUK);
m_turntable_box->setHidden(type != Type::TURNTABLE);
}

View File

@ -0,0 +1,52 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QGroupBox;
class QHBoxLayout;
class WiimoteEmuExtension final : public MappingWidget
{
Q_OBJECT
public:
enum class Type
{
NONE,
CLASSIC_CONTROLLER,
DRUMS,
GUITAR,
NUNCHUK,
TURNTABLE
};
explicit WiimoteEmuExtension(MappingWindow* window);
InputConfig* GetConfig() override;
void ChangeExtensionType(Type type);
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateClassicLayout();
void CreateDrumsLayout();
void CreateGuitarLayout();
void CreateNoneLayout();
void CreateNunchukLayout();
void CreateTurntableLayout();
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
QGroupBox* m_classic_box;
QGroupBox* m_drums_box;
QGroupBox* m_guitar_box;
QGroupBox* m_none_box;
QGroupBox* m_nunchuk_box;
QGroupBox* m_turntable_box;
};

View File

@ -0,0 +1,114 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/WiimoteEmuGeneral.h"
#include <QComboBox>
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
#include "InputCommon/ControllerEmu/ControlGroup/Extension.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/InputConfig.h"
WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension)
: MappingWidget(window), m_extension_widget(extension)
{
CreateMainLayout();
Connect();
}
void WiimoteEmuGeneral::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
auto* vbox_layout = new QVBoxLayout();
m_main_layout->addWidget(CreateGroupBox(
tr("Buttons"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Buttons)));
m_main_layout->addWidget(CreateGroupBox(
tr("D-Pad"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::DPad)));
m_main_layout->addWidget(CreateGroupBox(
tr("Hotkeys"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Hotkeys)));
auto* extension_group = Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Extension);
auto* extension = CreateGroupBox(tr("Extension"), extension_group);
auto* ce_extension = static_cast<ControllerEmu::Extension*>(extension_group);
m_extension_combo = new QComboBox();
for (const auto& attachment : ce_extension->attachments)
{
// TODO: Figure out how to localize this
m_extension_combo->addItem(QString::fromStdString(attachment->GetName()));
}
extension->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
static_cast<QFormLayout*>(extension->layout())->addRow(m_extension_combo);
vbox_layout->addWidget(extension);
vbox_layout->addWidget(CreateGroupBox(
tr("Rumble"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Rumble)));
vbox_layout->addWidget(CreateGroupBox(
tr("Options"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Options)));
m_main_layout->addLayout(vbox_layout);
setLayout(m_main_layout);
}
void WiimoteEmuGeneral::Connect()
{
connect(m_extension_combo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &WiimoteEmuGeneral::OnAttachmentChanged);
}
void WiimoteEmuGeneral::OnAttachmentChanged(int extension)
{
const QString value = m_extension_combo->currentText();
static const QMap<QString, WiimoteEmuExtension::Type> value_map = {
{QStringLiteral("None"), WiimoteEmuExtension::Type::NONE},
{QStringLiteral("Classic"), WiimoteEmuExtension::Type::CLASSIC_CONTROLLER},
{QStringLiteral("Drums"), WiimoteEmuExtension::Type::DRUMS},
{QStringLiteral("Guitar"), WiimoteEmuExtension::Type::GUITAR},
{QStringLiteral("Nunchuk"), WiimoteEmuExtension::Type::NUNCHUK},
{QStringLiteral("Turntable"), WiimoteEmuExtension::Type::TURNTABLE}};
m_extension_widget->ChangeExtensionType(value_map[value]);
auto* ce_extension = static_cast<ControllerEmu::Extension*>(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Extension));
ce_extension->switch_extension = extension;
SaveSettings();
}
void WiimoteEmuGeneral::LoadSettings()
{
auto* ce_extension = static_cast<ControllerEmu::Extension*>(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Extension));
m_extension_combo->setCurrentIndex(ce_extension->switch_extension);
OnAttachmentChanged(ce_extension->switch_extension);
Wiimote::LoadConfig();
}
void WiimoteEmuGeneral::SaveSettings()
{
Wiimote::GetConfig()->SaveConfig();
}
InputConfig* WiimoteEmuGeneral::GetConfig()
{
return Wiimote::GetConfig();
}

View File

@ -0,0 +1,35 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QComboBox;
class QHBoxLayout;
class WiimoteEmuExtension;
class WiimoteEmuGeneral final : public MappingWidget
{
Q_OBJECT
public:
explicit WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
void Connect();
void OnAttachmentChanged(int index);
// Main
QHBoxLayout* m_main_layout;
// Extensions
QComboBox* m_extension_combo;
WiimoteEmuExtension* m_extension_widget;
};

View File

@ -0,0 +1,51 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/Config/Mapping/WiimoteEmuMotionControl.h"
#include <QFormLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "InputCommon/InputConfig.h"
WiimoteEmuMotionControl::WiimoteEmuMotionControl(MappingWindow* window) : MappingWidget(window)
{
CreateMainLayout();
}
void WiimoteEmuMotionControl::CreateMainLayout()
{
m_main_layout = new QHBoxLayout();
m_main_layout->addWidget(CreateGroupBox(
tr("Shake"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Shake)));
m_main_layout->addWidget(
CreateGroupBox(tr("IR"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IR)));
m_main_layout->addWidget(CreateGroupBox(
tr("Tilt"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Tilt)));
m_main_layout->addWidget(CreateGroupBox(
tr("Swing"), Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::Swing)));
setLayout(m_main_layout);
}
void WiimoteEmuMotionControl::LoadSettings()
{
Wiimote::LoadConfig();
}
void WiimoteEmuMotionControl::SaveSettings()
{
Wiimote::GetConfig()->SaveConfig();
}
InputConfig* WiimoteEmuMotionControl::GetConfig()
{
return Wiimote::GetConfig();
}

View File

@ -0,0 +1,31 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinQt/Config/Mapping/MappingWidget.h"
class QCheckBox;
class QFormLayout;
class QGroupBox;
class QHBoxLayout;
class QLabel;
class QVBoxLayout;
class WiimoteEmuMotionControl final : public MappingWidget
{
Q_OBJECT
public:
explicit WiimoteEmuMotionControl(MappingWindow* window);
InputConfig* GetConfig() override;
private:
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
// Main
QHBoxLayout* m_main_layout;
};