2017-05-20 15:53:17 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
#include <QGridLayout>
|
2017-05-20 15:53:17 +00:00
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
#include "Core/HW/Wiimote.h"
|
2019-01-01 14:32:39 +00:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Classic.h"
|
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Drums.h"
|
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Guitar.h"
|
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h"
|
2019-02-26 01:52:01 +00:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
2019-01-01 14:32:39 +00:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
2018-12-15 01:53:20 +00:00
|
|
|
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "InputCommon/InputConfig.h"
|
|
|
|
|
|
|
|
WiimoteEmuExtension::WiimoteEmuExtension(MappingWindow* window) : MappingWidget(window)
|
|
|
|
{
|
|
|
|
CreateClassicLayout();
|
|
|
|
CreateDrumsLayout();
|
|
|
|
CreateGuitarLayout();
|
|
|
|
CreateNoneLayout();
|
|
|
|
CreateNunchukLayout();
|
|
|
|
CreateTurntableLayout();
|
2018-12-15 01:53:20 +00:00
|
|
|
CreateUDrawTabletLayout();
|
2019-02-26 01:52:01 +00:00
|
|
|
CreateTaTaConLayout();
|
2017-05-20 15:53:17 +00:00
|
|
|
CreateMainLayout();
|
|
|
|
|
2019-04-27 15:51:57 +00:00
|
|
|
ChangeExtensionType(WiimoteEmu::ExtensionNumber::NONE);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::CreateClassicLayout()
|
|
|
|
{
|
2019-03-16 16:55:47 +00:00
|
|
|
auto* layout = new QGridLayout();
|
2017-05-20 15:53:17 +00:00
|
|
|
m_classic_box = new QGroupBox(tr("Classic Controller"), this);
|
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Buttons"),
|
|
|
|
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Buttons)),
|
2019-04-27 19:23:29 +00:00
|
|
|
0, 0);
|
|
|
|
layout->addWidget(CreateGroupBox(tr("D-Pad"), Wiimote::GetClassicGroup(
|
|
|
|
GetPort(), WiimoteEmu::ClassicGroup::DPad)),
|
|
|
|
1, 0);
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Left Stick"),
|
|
|
|
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::LeftStick)),
|
|
|
|
0, 1, -1, 1);
|
|
|
|
layout->addWidget(
|
2017-05-20 15:53:17 +00:00
|
|
|
CreateGroupBox(tr("Right Stick"),
|
2019-03-16 16:55:47 +00:00
|
|
|
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::RightStick)),
|
|
|
|
0, 2, -1, 1);
|
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Triggers"),
|
|
|
|
Wiimote::GetClassicGroup(GetPort(), WiimoteEmu::ClassicGroup::Triggers)),
|
2019-04-27 19:23:29 +00:00
|
|
|
0, 3, -1, 1);
|
2019-03-16 16:55:47 +00:00
|
|
|
|
|
|
|
m_classic_box->setLayout(layout);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::CreateDrumsLayout()
|
|
|
|
{
|
2019-03-16 16:55:47 +00:00
|
|
|
auto* layout = new QGridLayout();
|
2019-05-01 22:25:48 +00:00
|
|
|
m_drums_box = new QGroupBox(tr("Drum Kit"), this);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Stick"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Stick)),
|
|
|
|
0, 0, -1, 1);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Pads"), Wiimote::GetDrumsGroup(GetPort(), WiimoteEmu::DrumsGroup::Pads)),
|
|
|
|
0, 1);
|
|
|
|
layout->addWidget(CreateGroupBox(tr("Buttons"), Wiimote::GetDrumsGroup(
|
|
|
|
GetPort(), WiimoteEmu::DrumsGroup::Buttons)),
|
|
|
|
1, 1);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
m_drums_box->setLayout(layout);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2019-03-16 16:55:47 +00:00
|
|
|
auto* layout = new QGridLayout();
|
2017-05-20 15:53:17 +00:00
|
|
|
m_nunchuk_box = new QGroupBox(tr("Nunchuk"), this);
|
|
|
|
|
2019-04-27 19:23:29 +00:00
|
|
|
layout->addWidget(CreateGroupBox(tr("Shake"), Wiimote::GetNunchukGroup(
|
|
|
|
GetPort(), WiimoteEmu::NunchukGroup::Shake)),
|
|
|
|
0, 0);
|
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Buttons"),
|
|
|
|
Wiimote::GetNunchukGroup(GetPort(), WiimoteEmu::NunchukGroup::Buttons)),
|
|
|
|
1, 0);
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(CreateGroupBox(tr("Stick"), Wiimote::GetNunchukGroup(
|
|
|
|
GetPort(), WiimoteEmu::NunchukGroup::Stick)),
|
2019-04-27 19:23:29 +00:00
|
|
|
0, 1, -1, 1);
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(CreateGroupBox(tr("Tilt"), Wiimote::GetNunchukGroup(
|
|
|
|
GetPort(), WiimoteEmu::NunchukGroup::Tilt)),
|
2019-04-27 19:23:29 +00:00
|
|
|
0, 2, -1, 1);
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(CreateGroupBox(tr("Swing"), Wiimote::GetNunchukGroup(
|
|
|
|
GetPort(), WiimoteEmu::NunchukGroup::Swing)),
|
2019-04-27 19:23:29 +00:00
|
|
|
0, 3, -1, 1);
|
2019-03-16 16:55:47 +00:00
|
|
|
|
|
|
|
m_nunchuk_box->setLayout(layout);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::CreateGuitarLayout()
|
|
|
|
{
|
|
|
|
auto* hbox = new QHBoxLayout();
|
|
|
|
m_guitar_box = new QGroupBox(tr("Guitar"), this);
|
|
|
|
|
|
|
|
auto* vbox = new QVBoxLayout();
|
|
|
|
vbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Stick"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Stick)));
|
2018-05-08 23:54:47 +00:00
|
|
|
hbox->addLayout(vbox);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
|
|
|
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)));
|
2018-05-08 23:54:47 +00:00
|
|
|
hbox->addLayout(vbox2);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2018-12-29 18:59:47 +00:00
|
|
|
auto* vbox3 = new QVBoxLayout();
|
|
|
|
vbox3->addWidget(CreateGroupBox(
|
|
|
|
tr("Buttons"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Buttons)));
|
|
|
|
vbox3->addWidget(CreateGroupBox(
|
|
|
|
tr("Whammy"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::Whammy)));
|
|
|
|
vbox3->addWidget(CreateGroupBox(
|
|
|
|
tr("Slider Bar"), Wiimote::GetGuitarGroup(GetPort(), WiimoteEmu::GuitarGroup::SliderBar)));
|
|
|
|
hbox->addLayout(vbox3);
|
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
m_guitar_box->setLayout(hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::CreateTurntableLayout()
|
|
|
|
{
|
2019-03-16 16:55:47 +00:00
|
|
|
auto* layout = new QGridLayout();
|
2019-05-01 22:25:48 +00:00
|
|
|
m_turntable_box = new QGroupBox(tr("DJ Turntable"), this);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(CreateGroupBox(tr("Stick"), Wiimote::GetTurntableGroup(
|
|
|
|
GetPort(), WiimoteEmu::TurntableGroup::Stick)),
|
|
|
|
0, 0, -1, 1);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Buttons"),
|
|
|
|
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Buttons)),
|
|
|
|
0, 1);
|
|
|
|
layout->addWidget(
|
|
|
|
CreateGroupBox(tr("Effect"),
|
|
|
|
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::EffectDial)),
|
|
|
|
1, 1, -1, 1);
|
2018-12-29 18:59:47 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
layout->addWidget(
|
2017-07-23 10:58:32 +00:00
|
|
|
// i18n: "Table" refers to a turntable
|
2017-05-20 15:53:17 +00:00
|
|
|
CreateGroupBox(tr("Left Table"),
|
2019-03-16 16:55:47 +00:00
|
|
|
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::LeftTable)),
|
|
|
|
0, 2);
|
|
|
|
layout->addWidget(CreateGroupBox(
|
|
|
|
// i18n: "Table" refers to a turntable
|
|
|
|
tr("Right Table"), Wiimote::GetTurntableGroup(
|
|
|
|
GetPort(), WiimoteEmu::TurntableGroup::RightTable)),
|
|
|
|
1, 2);
|
|
|
|
layout->addWidget(
|
2017-05-20 15:53:17 +00:00
|
|
|
CreateGroupBox(tr("Crossfade"),
|
2019-03-16 16:55:47 +00:00
|
|
|
Wiimote::GetTurntableGroup(GetPort(), WiimoteEmu::TurntableGroup::Crossfade)),
|
|
|
|
2, 2);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
2019-03-16 16:55:47 +00:00
|
|
|
m_turntable_box->setLayout(layout);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-15 01:53:20 +00:00
|
|
|
void WiimoteEmuExtension::CreateUDrawTabletLayout()
|
|
|
|
{
|
|
|
|
auto* hbox = new QHBoxLayout();
|
|
|
|
m_udraw_tablet_box = new QGroupBox(tr("uDraw GameTablet"), this);
|
|
|
|
|
|
|
|
hbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Buttons"),
|
|
|
|
Wiimote::GetUDrawTabletGroup(GetPort(), WiimoteEmu::UDrawTabletGroup::Buttons)));
|
|
|
|
|
|
|
|
hbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Stylus"), Wiimote::GetUDrawTabletGroup(GetPort(), WiimoteEmu::UDrawTabletGroup::Stylus)));
|
|
|
|
|
|
|
|
hbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Touch"), Wiimote::GetUDrawTabletGroup(GetPort(), WiimoteEmu::UDrawTabletGroup::Touch)));
|
|
|
|
|
|
|
|
m_udraw_tablet_box->setLayout(hbox);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:52:01 +00:00
|
|
|
void WiimoteEmuExtension::CreateTaTaConLayout()
|
|
|
|
{
|
|
|
|
auto* hbox = new QHBoxLayout();
|
|
|
|
m_tatacon_box = new QGroupBox(tr("Taiko Drum"), this);
|
|
|
|
|
|
|
|
hbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Center"), Wiimote::GetTaTaConGroup(GetPort(), WiimoteEmu::TaTaConGroup::Center)));
|
|
|
|
hbox->addWidget(CreateGroupBox(
|
|
|
|
tr("Rim"), Wiimote::GetTaTaConGroup(GetPort(), WiimoteEmu::TaTaConGroup::Rim)));
|
|
|
|
|
|
|
|
m_tatacon_box->setLayout(hbox);
|
|
|
|
}
|
|
|
|
|
2017-05-20 15:53:17 +00:00
|
|
|
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);
|
2018-12-15 01:53:20 +00:00
|
|
|
m_main_layout->addWidget(m_udraw_tablet_box);
|
2019-02-26 01:52:01 +00:00
|
|
|
m_main_layout->addWidget(m_tatacon_box);
|
2017-05-20 15:53:17 +00:00
|
|
|
|
|
|
|
setLayout(m_main_layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::LoadSettings()
|
|
|
|
{
|
|
|
|
Wiimote::LoadConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiimoteEmuExtension::SaveSettings()
|
|
|
|
{
|
|
|
|
Wiimote::GetConfig()->SaveConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
InputConfig* WiimoteEmuExtension::GetConfig()
|
|
|
|
{
|
|
|
|
return Wiimote::GetConfig();
|
|
|
|
}
|
|
|
|
|
2019-04-27 15:51:57 +00:00
|
|
|
void WiimoteEmuExtension::ChangeExtensionType(u32 type)
|
2017-05-20 15:53:17 +00:00
|
|
|
{
|
2019-04-27 15:51:57 +00:00
|
|
|
using WiimoteEmu::ExtensionNumber;
|
|
|
|
|
|
|
|
m_none_box->setHidden(type != ExtensionNumber::NONE);
|
|
|
|
m_nunchuk_box->setHidden(type != ExtensionNumber::NUNCHUK);
|
|
|
|
m_classic_box->setHidden(type != ExtensionNumber::CLASSIC);
|
|
|
|
m_guitar_box->setHidden(type != ExtensionNumber::GUITAR);
|
|
|
|
m_drums_box->setHidden(type != ExtensionNumber::DRUMS);
|
|
|
|
m_turntable_box->setHidden(type != ExtensionNumber::TURNTABLE);
|
2018-12-15 01:53:20 +00:00
|
|
|
m_udraw_tablet_box->setHidden(type != ExtensionNumber::UDRAW_TABLET);
|
2019-02-26 01:52:01 +00:00
|
|
|
m_tatacon_box->setHidden(type != ExtensionNumber::TATACON);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|