| 1 | // Copyright 2021 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Config/Mapping/FreeLookRotation.h" |
| 5 | |
| 6 | #include <QGridLayout> |
| 7 | #include <QGroupBox> |
| 8 | #include <QHBoxLayout> |
| 9 | #include <QLabel> |
| 10 | #include <QPushButton> |
| 11 | |
| 12 | #include "Core/FreeLookManager.h" |
| 13 | #include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" |
| 14 | #include "InputCommon/InputConfig.h" |
| 15 | |
| 16 | FreeLookRotation::FreeLookRotation(MappingWindow* window) : MappingWidget(window) |
| 17 | { |
| 18 | CreateMainLayout(); |
| 19 | } |
| 20 | |
| 21 | void FreeLookRotation::CreateMainLayout() |
| 22 | { |
| 23 | m_main_layout = new QGridLayout; |
| 24 | |
| 25 | auto* alternate_input_layout = new QHBoxLayout(); |
| 26 | auto* note_label = new QLabel( |
| 27 | tr("Note: motion input may require configuring alternate input sources before use.")); |
| 28 | note_label->setWordWrap(true); |
| 29 | auto* alternate_input_sources_button = new QPushButton(tr("Alternate Input Sources")); |
| 30 | alternate_input_layout->addWidget(note_label, 1); |
| 31 | alternate_input_layout->addWidget(alternate_input_sources_button, 0, Qt::AlignRight); |
| 32 | connect(alternate_input_sources_button, &QPushButton::clicked, this, [this] { |
| 33 | ControllerInterfaceWindow* window = new ControllerInterfaceWindow(this); |
| 34 | window->setAttribute(Qt::WA_DeleteOnClose, true); |
| 35 | window->setWindowModality(Qt::WindowModality::WindowModal); |
| 36 | window->show(); |
| 37 | }); |
| 38 | m_main_layout->addLayout(alternate_input_layout, 0, 0, 1, -1); |
| 39 | |
| 40 | m_main_layout->addWidget( |
| 41 | CreateGroupBox(tr("Incremental Rotation (rad/sec)"), |
| 42 | FreeLook::GetInputGroup(GetPort(), FreeLookGroup::Rotation)), |
| 43 | 1, 0); |
| 44 | |
| 45 | setLayout(m_main_layout); |
| 46 | } |
| 47 | |
| 48 | InputConfig* FreeLookRotation::GetConfig() |
| 49 | { |
| 50 | return FreeLook::GetInputConfig(); |
| 51 | } |
| 52 | |
| 53 | void FreeLookRotation::LoadSettings() |
| 54 | { |
| 55 | FreeLook::LoadInputConfig(); |
| 56 | } |
| 57 | |
| 58 | void FreeLookRotation::SaveSettings() |
| 59 | { |
| 60 | FreeLook::GetInputConfig()->SaveConfig(); |
| 61 | } |