| 1 | // Copyright 2019 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/Mapping/WiimoteEmuMotionControlIMU.h" |
| 5 | |
| 6 | #include <QFormLayout> |
| 7 | #include <QGroupBox> |
| 8 | #include <QHBoxLayout> |
| 9 | #include <QLabel> |
| 10 | #include <QPushButton> |
| 11 | #include <QString> |
| 12 | #include <QVBoxLayout> |
| 13 | |
| 14 | #include "Core/HW/Wiimote.h" |
| 15 | #include "Core/HW/WiimoteEmu/WiimoteEmu.h" |
| 16 | |
| 17 | #include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" |
| 18 | #include "DolphinQt/QtUtils/QtUtils.h" |
| 19 | |
| 20 | #include "InputCommon/InputConfig.h" |
| 21 | |
| 22 | WiimoteEmuMotionControlIMU::WiimoteEmuMotionControlIMU(MappingWindow* window) |
| 23 | : MappingWidget(window) |
| 24 | { |
| 25 | CreateMainLayout(); |
| 26 | } |
| 27 | |
| 28 | void WiimoteEmuMotionControlIMU::CreateMainLayout() |
| 29 | { |
| 30 | auto* warning_layout = new QHBoxLayout(); |
| 31 | auto* warning_label = |
| 32 | new QLabel(tr("The controls under Accelerometer and Gyroscope are designed to " |
| 33 | "interface directly with motion sensor hardware. They are not intended for " |
| 34 | "mapping traditional buttons, triggers or axes. You might need to configure " |
| 35 | "alternate input sources before using these controls.")); |
| 36 | warning_label->setWordWrap(true); |
| 37 | auto* warning_input_sources_button = new QPushButton(tr("Alternate Input Sources")); |
| 38 | warning_layout->addWidget( |
| 39 | QtUtils::CreateIconWarning(this, QStyle::SP_MessageBoxWarning, warning_label), 1); |
| 40 | warning_layout->addWidget(warning_input_sources_button); |
| 41 | connect(warning_input_sources_button, &QPushButton::clicked, this, [this] { |
| 42 | ControllerInterfaceWindow window{this}; |
| 43 | window.exec(); |
| 44 | }); |
| 45 | |
| 46 | auto* groups_layout = new QHBoxLayout(); |
| 47 | groups_layout->addWidget( |
| 48 | CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUPoint))); |
| 49 | groups_layout->addWidget( |
| 50 | CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IRPassthrough))); |
| 51 | groups_layout->addWidget(CreateGroupBox( |
| 52 | Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUAccelerometer))); |
| 53 | groups_layout->addWidget( |
| 54 | CreateGroupBox(Wiimote::GetWiimoteGroup(GetPort(), WiimoteEmu::WiimoteGroup::IMUGyroscope))); |
| 55 | |
| 56 | m_main_layout = new QVBoxLayout(); |
| 57 | m_main_layout->addLayout(warning_layout); |
| 58 | m_main_layout->addLayout(groups_layout); |
| 59 | |
| 60 | setLayout(m_main_layout); |
| 61 | } |
| 62 | |
| 63 | void WiimoteEmuMotionControlIMU::LoadSettings() |
| 64 | { |
| 65 | Wiimote::LoadConfig(); |
| 66 | } |
| 67 | |
| 68 | void WiimoteEmuMotionControlIMU::SaveSettings() |
| 69 | { |
| 70 | Wiimote::GetConfig()->SaveConfig(); |
| 71 | } |
| 72 | |
| 73 | InputConfig* WiimoteEmuMotionControlIMU::GetConfig() |
| 74 | { |
| 75 | return Wiimote::GetConfig(); |
| 76 | } |