Skip to content
Permalink
Browse files

Wiimote Mapping UI: Motion Input tab: Rework mapping warning, add exp…

…lanation of and button to open Alternate Input Sources window.
  • Loading branch information...
rlnilsen committed Oct 24, 2019
1 parent 5ff7949 commit 332cad21a40a2565141ca817a3cc684d8f10bfca
@@ -8,12 +8,15 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QString>
#include <QVBoxLayout>

#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"

#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h"

#include "InputCommon/InputConfig.h"

WiimoteEmuMotionControlIMU::WiimoteEmuMotionControlIMU(MappingWindow* window)
@@ -22,36 +25,36 @@ WiimoteEmuMotionControlIMU::WiimoteEmuMotionControlIMU(MappingWindow* window)
CreateMainLayout();
}

QGroupBox* WiimoteEmuMotionControlIMU::AddWarning(QGroupBox* groupbox)
{
QFormLayout* layout = static_cast<QFormLayout*>(groupbox->layout());
QLabel* label;

label = new QLabel(QLatin1String(""));
layout->addRow(label);

label = new QLabel(tr("WARNING"));
label->setStyleSheet(QLatin1String("QLabel { color : red; }"));
layout->addRow(label);

label = new QLabel(
tr("These controls are not intended for mapping regular buttons, triggers or axes."));
label->setWordWrap(true);
layout->addRow(label);

return groupbox;
}

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

m_main_layout->addWidget(
auto* warning_layout = new QHBoxLayout();
auto* warning_label =
new QLabel(tr("WARNING: The controls under Accelerometer and Gyroscope are designed to "
"interface directly with motion sensor hardware. They are not intended for "
"mapping traditional buttons, triggers or axes. You might need to configure "
"alternate input sources before using these controls."));
warning_label->setWordWrap(true);
auto* warning_input_sources_button = new QPushButton(tr("Alternate Input Sources"));
warning_layout->addWidget(warning_label, 1);
warning_layout->addWidget(warning_input_sources_button, 0, Qt::AlignRight);
connect(warning_input_sources_button, &QPushButton::clicked, this, [this] {
ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this);
window->setAttribute(Qt::WA_DeleteOnClose, true);
window->setWindowModality(Qt::WindowModality::WindowModal);
window->show();
});

auto* groups_layout = new QHBoxLayout();
groups_layout->addWidget(
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUPoint)));
m_main_layout->addWidget(AddWarning(CreateGroupBox(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUAccelerometer))));
m_main_layout->addWidget(AddWarning(
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUGyroscope))));
groups_layout->addWidget(CreateGroupBox(
Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUAccelerometer)));
groups_layout->addWidget(
CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUGyroscope)));

m_main_layout = new QVBoxLayout();
m_main_layout->addLayout(warning_layout);
m_main_layout->addLayout(groups_layout);

setLayout(m_main_layout);
}
@@ -25,8 +25,7 @@ class WiimoteEmuMotionControlIMU final : public MappingWidget
void LoadSettings() override;
void SaveSettings() override;
void CreateMainLayout();
static QGroupBox* AddWarning(QGroupBox* groupbox);

// Main
QHBoxLayout* m_main_layout;
QVBoxLayout* m_main_layout;
};

0 comments on commit 332cad2

Please sign in to comment.
You can’t perform that action at this time.