From ddba5a3dfaa832e7cadea240d3c6645d7b874a91 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 11 Mar 2021 00:41:15 -0600 Subject: [PATCH] DolphinQt: Add separate Free Look tab for rotation --- Source/Core/DolphinQt/CMakeLists.txt | 2 + .../Config/Mapping/FreeLookRotation.cpp | 62 +++++++++++++++++++ .../Config/Mapping/FreeLookRotation.h | 26 ++++++++ .../Config/Mapping/MappingWindow.cpp | 2 + Source/Core/DolphinQt/DolphinQt.vcxproj | 2 + 5 files changed, 94 insertions(+) create mode 100644 Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.cpp create mode 100644 Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index ad248b320d..41b24a9c26 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -122,6 +122,8 @@ add_executable(dolphin-emu Config/LogWidget.h Config/Mapping/FreeLookGeneral.cpp Config/Mapping/FreeLookGeneral.h + Config/Mapping/FreeLookRotation.cpp + Config/Mapping/FreeLookRotation.h Config/Mapping/GCKeyboardEmu.cpp Config/Mapping/GCKeyboardEmu.h Config/Mapping/GCMicrophone.cpp diff --git a/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.cpp b/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.cpp new file mode 100644 index 0000000000..c01e9d1241 --- /dev/null +++ b/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.cpp @@ -0,0 +1,62 @@ +// Copyright 2021 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/Mapping/FreeLookRotation.h" + +#include +#include +#include +#include +#include + +#include "Core/FreeLookManager.h" +#include "DolphinQt/Config/ControllerInterface/ControllerInterfaceWindow.h" +#include "InputCommon/InputConfig.h" + +FreeLookRotation::FreeLookRotation(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void FreeLookRotation::CreateMainLayout() +{ + m_main_layout = new QGridLayout; + + auto* alternate_input_layout = new QHBoxLayout(); + auto* note_label = new QLabel( + tr("Note: motion input may require configuring alternate input sources before use.")); + note_label->setWordWrap(true); + auto* alternate_input_sources_button = new QPushButton(tr("Alternate Input Sources")); + alternate_input_layout->addWidget(note_label, 1); + alternate_input_layout->addWidget(alternate_input_sources_button, 0, Qt::AlignRight); + connect(alternate_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(); + }); + m_main_layout->addLayout(alternate_input_layout, 0, 0, 1, -1); + + m_main_layout->addWidget( + CreateGroupBox(tr("Incremental Rotation (rad/sec)"), + FreeLook::GetInputGroup(GetPort(), FreeLookGroup::Rotation)), + 1, 0); + + setLayout(m_main_layout); +} + +InputConfig* FreeLookRotation::GetConfig() +{ + return FreeLook::GetInputConfig(); +} + +void FreeLookRotation::LoadSettings() +{ + FreeLook::LoadInputConfig(); +} + +void FreeLookRotation::SaveSettings() +{ + FreeLook::GetInputConfig()->SaveConfig(); +} diff --git a/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.h b/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.h new file mode 100644 index 0000000000..de87aba59e --- /dev/null +++ b/Source/Core/DolphinQt/Config/Mapping/FreeLookRotation.h @@ -0,0 +1,26 @@ +// Copyright 2021 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/Mapping/MappingWidget.h" + +class QGridLayout; + +class FreeLookRotation final : public MappingWidget +{ + Q_OBJECT +public: + explicit FreeLookRotation(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); + + // Main + QGridLayout* m_main_layout; +}; diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index 976b289d44..ae9b2e0cc5 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -23,6 +23,7 @@ #include "Common/StringUtil.h" #include "DolphinQt/Config/Mapping/FreeLookGeneral.h" +#include "DolphinQt/Config/Mapping/FreeLookRotation.h" #include "DolphinQt/Config/Mapping/GCKeyboardEmu.h" #include "DolphinQt/Config/Mapping/GCMicrophone.h" #include "DolphinQt/Config/Mapping/GCPadEmu.h" @@ -436,6 +437,7 @@ void MappingWindow::SetMappingType(MappingWindow::Type type) { widget = new FreeLookGeneral(this); AddWidget(tr("General"), widget); + AddWidget(tr("Rotation"), new FreeLookRotation(this)); setWindowTitle(tr("Free Look Controller %1").arg(GetPort() + 1)); } break; diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 3a21497eef..18a838896e 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -80,6 +80,7 @@ + @@ -254,6 +255,7 @@ +