diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index e0d21f0754..6bc5e7fa77 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -71,6 +71,10 @@ add_executable(dolphin-emu Config/ControllersWindow.h Config/FilesystemWidget.cpp Config/FilesystemWidget.h + Config/FreeLookWidget.cpp + Config/FreeLookWidget.h + Config/FreeLookWindow.cpp + Config/FreeLookWindow.h Config/GameConfigEdit.cpp Config/GameConfigEdit.h Config/GameConfigHighlighter.cpp @@ -112,6 +116,8 @@ add_executable(dolphin-emu Config/LogConfigWidget.h Config/LogWidget.cpp Config/LogWidget.h + Config/Mapping/FreeLookGeneral.cpp + Config/Mapping/FreeLookGeneral.h Config/Mapping/GCKeyboardEmu.cpp Config/Mapping/GCKeyboardEmu.h Config/Mapping/GCMicrophone.cpp diff --git a/Source/Core/DolphinQt/Config/FreeLookWidget.cpp b/Source/Core/DolphinQt/Config/FreeLookWidget.cpp new file mode 100644 index 0000000000..dec4493ca9 --- /dev/null +++ b/Source/Core/DolphinQt/Config/FreeLookWidget.cpp @@ -0,0 +1,112 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/FreeLookWidget.h" + +#include +#include +#include +#include +#include + +#include "Core/Config/FreeLookSettings.h" +#include "Core/ConfigManager.h" +#include "Core/Core.h" + +#include "DolphinQt/Config/Graphics/GraphicsChoice.h" +#include "DolphinQt/Config/Mapping/MappingWindow.h" +#include "DolphinQt/Config/ToolTipControls/ToolTipCheckBox.h" +#include "DolphinQt/Settings.h" + +FreeLookWidget::FreeLookWidget(QWidget* parent) : QWidget(parent) +{ + CreateLayout(); + LoadSettings(); + ConnectWidgets(); +} + +void FreeLookWidget::CreateLayout() +{ + auto* layout = new QVBoxLayout(); + + m_enable_freelook = new ToolTipCheckBox(tr("Enable")); + m_enable_freelook->setChecked(Config::Get(Config::FREE_LOOK_ENABLED)); + m_enable_freelook->SetDescription( + tr("Allows manipulation of the in-game camera.

If unsure, " + "leave this unchecked.")); + m_freelook_controller_configure_button = new QPushButton(tr("Configure Controller")); + + m_freelook_control_type = new GraphicsChoice({tr("Six Axis"), tr("First Person"), tr("Orbital")}, + Config::FL1_CONTROL_TYPE); + m_freelook_control_type->SetTitle(tr("Free Look Control Type")); + m_freelook_control_type->SetDescription(tr( + "Changes the in-game camera type during Free Look.

" + "Six Axis: Offers full camera control on all axes, akin to moving a spacecraft in zero " + "gravity. This is the most powerful Free Look option but is the most challenging to use.
" + "
" + "First Person: Controls the free camera similarly to a first person video game. The camera " + "can rotate and travel, but roll is impossible. Easy to use, but limiting.

" + "Orbital: Rotates the free camera around the original camera. Has no lateral movement, only " + "rotation and you may zoom up to the camera's origin point.")); + + auto* description = + new QLabel(tr("Free Look allows for manipulation of the in-game camera. " + "Different camera types are available from the dropdown.

" + "For detailed instructions, " + "" + "refer to this page.")); + description->setTextFormat(Qt::RichText); + description->setWordWrap(true); + description->setTextInteractionFlags(Qt::TextBrowserInteraction); + description->setOpenExternalLinks(true); + + auto* hlayout = new QHBoxLayout(); + hlayout->addWidget(new QLabel(tr("Camera 1"))); + hlayout->addWidget(m_freelook_control_type); + hlayout->addWidget(m_freelook_controller_configure_button); + + layout->addWidget(m_enable_freelook); + layout->addLayout(hlayout); + layout->addWidget(description); + + setLayout(layout); +} + +void FreeLookWidget::ConnectWidgets() +{ + connect(m_freelook_controller_configure_button, &QPushButton::clicked, this, + &FreeLookWidget::OnFreeLookControllerConfigured); + connect(m_enable_freelook, &QCheckBox::clicked, this, &FreeLookWidget::SaveSettings); + connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] { + const QSignalBlocker blocker(this); + LoadSettings(); + }); +} + +void FreeLookWidget::OnFreeLookControllerConfigured() +{ + if (m_freelook_controller_configure_button != QObject::sender()) + return; + const int index = 0; + MappingWindow* window = new MappingWindow(this, MappingWindow::Type::MAPPING_FREELOOK, index); + window->setAttribute(Qt::WA_DeleteOnClose, true); + window->setWindowModality(Qt::WindowModality::WindowModal); + window->show(); +} + +void FreeLookWidget::LoadSettings() +{ + const bool checked = Config::Get(Config::FREE_LOOK_ENABLED); + m_enable_freelook->setChecked(checked); + m_freelook_control_type->setEnabled(checked); + m_freelook_controller_configure_button->setEnabled(checked); +} + +void FreeLookWidget::SaveSettings() +{ + const bool checked = m_enable_freelook->isChecked(); + Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, checked); + m_freelook_control_type->setEnabled(checked); + m_freelook_controller_configure_button->setEnabled(checked); +} diff --git a/Source/Core/DolphinQt/Config/FreeLookWidget.h b/Source/Core/DolphinQt/Config/FreeLookWidget.h new file mode 100644 index 0000000000..c517406a6c --- /dev/null +++ b/Source/Core/DolphinQt/Config/FreeLookWidget.h @@ -0,0 +1,30 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class GraphicsChoice; +class QPushButton; +class ToolTipCheckBox; + +class FreeLookWidget final : public QWidget +{ + Q_OBJECT +public: + explicit FreeLookWidget(QWidget* parent); + +private: + void CreateLayout(); + void ConnectWidgets(); + + void OnFreeLookControllerConfigured(); + void LoadSettings(); + void SaveSettings(); + + ToolTipCheckBox* m_enable_freelook; + GraphicsChoice* m_freelook_control_type; + QPushButton* m_freelook_controller_configure_button; +}; diff --git a/Source/Core/DolphinQt/Config/FreeLookWindow.cpp b/Source/Core/DolphinQt/Config/FreeLookWindow.cpp new file mode 100644 index 0000000000..8e9845aeef --- /dev/null +++ b/Source/Core/DolphinQt/Config/FreeLookWindow.cpp @@ -0,0 +1,31 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/FreeLookWindow.h" + +#include +#include +#include +#include + +#include "DolphinQt/Config/FreeLookWidget.h" + +FreeLookWindow::FreeLookWindow(QWidget* parent) : QDialog(parent) +{ + CreateMainLayout(); + + setWindowTitle(tr("Free Look Settings")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +} + +void FreeLookWindow::CreateMainLayout() +{ + m_button_box = new QDialogButtonBox(QDialogButtonBox::Close); + connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject); + + auto* main_layout = new QVBoxLayout(); + main_layout->addWidget(new FreeLookWidget(this)); + main_layout->addWidget(m_button_box); + setLayout(main_layout); +} diff --git a/Source/Core/DolphinQt/Config/FreeLookWindow.h b/Source/Core/DolphinQt/Config/FreeLookWindow.h new file mode 100644 index 0000000000..5424c528a6 --- /dev/null +++ b/Source/Core/DolphinQt/Config/FreeLookWindow.h @@ -0,0 +1,21 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class QDialogButtonBox; + +class FreeLookWindow final : public QDialog +{ + Q_OBJECT +public: + explicit FreeLookWindow(QWidget* parent); + +private: + void CreateMainLayout(); + + QDialogButtonBox* m_button_box; +}; diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index d91c7ee8c5..16ebd14dc9 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -80,19 +80,6 @@ void AdvancedWidget::CreateWidgets() utility_layout->addWidget(m_dump_efb_target, 1, 1); - // Freelook - auto* freelook_box = new QGroupBox(tr("Free Look")); - auto* freelook_layout = new QGridLayout(); - freelook_box->setLayout(freelook_layout); - - m_enable_freelook = new GraphicsBool(tr("Enable"), Config::GFX_FREE_LOOK); - m_freelook_control_type = new GraphicsChoice({tr("Six Axis"), tr("First Person"), tr("Orbital")}, - Config::GFX_FREE_LOOK_CONTROL_TYPE); - - freelook_layout->addWidget(m_enable_freelook, 0, 0); - freelook_layout->addWidget(new QLabel(tr("Control Type:")), 1, 0); - freelook_layout->addWidget(m_freelook_control_type, 1, 1); - // Texture dumping auto* texture_dump_box = new QGroupBox(tr("Texture Dumping")); auto* texture_dump_layout = new QGridLayout(); @@ -155,7 +142,6 @@ void AdvancedWidget::CreateWidgets() main_layout->addWidget(debugging_box); main_layout->addWidget(utility_box); - main_layout->addWidget(freelook_box); main_layout->addWidget(texture_dump_box); main_layout->addWidget(dump_box); main_layout->addWidget(misc_box); @@ -170,7 +156,6 @@ void AdvancedWidget::ConnectWidgets() connect(m_load_custom_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_dump_use_ffv1, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_enable_prog_scan, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); - connect(m_enable_freelook, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); connect(m_dump_textures, &QCheckBox::toggled, this, &AdvancedWidget::SaveSettings); } @@ -180,8 +165,6 @@ void AdvancedWidget::LoadSettings() m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1)); m_enable_prog_scan->setChecked(Config::Get(Config::SYSCONF_PROGRESSIVE_SCAN)); - - m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK)); m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); } @@ -192,8 +175,6 @@ void AdvancedWidget::SaveSettings() m_dump_bitrate->setEnabled(!Config::Get(Config::GFX_USE_FFV1)); Config::SetBase(Config::SYSCONF_PROGRESSIVE_SCAN, m_enable_prog_scan->isChecked()); - - m_freelook_control_type->setEnabled(Config::Get(Config::GFX_FREE_LOOK)); m_dump_mip_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); m_dump_base_textures->setEnabled(Config::Get(Config::GFX_DUMP_TEXTURES)); } @@ -268,22 +249,6 @@ void AdvancedWidget::AddDescriptions() QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.

If " "unsure, leave this unchecked."); #endif - static const char TR_FREE_LOOK_DESCRIPTION[] = QT_TR_NOOP( - "Allows manipulation of the in-game camera. Move the mouse while holding the right button " - "to pan or middle button to roll.

Use the WASD keys while holding SHIFT to move " - "the " - "camera. Press SHIFT+2 to increase speed or SHIFT+1 to decrease speed. Press SHIFT+R " - "to reset the camera or SHIFT+F to reset the speed.

If unsure, " - "leave this unchecked."); - static const char TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION[] = QT_TR_NOOP( - "Changes the in-game camera type during freelook.

" - "Six Axis: Offers full camera control on all axes, akin to moving a spacecraft in zero " - "gravity. This is the most powerful freelook option but is the most challenging to use.

" - "First Person: Controls the free camera similarly to a first person video game. The camera " - "can rotate and travel, but roll is impossible. Easy to use, but limiting.

" - "Orbital: Rotates the free camera around the original camera. Has no lateral movement, only " - "rotation and you may zoom up to the camera's origin point."); static const char TR_CROPPING_DESCRIPTION[] = QT_TR_NOOP( "Crops the picture from its native aspect ratio to 4:3 or " "16:9.

If unsure, leave this unchecked."); @@ -330,9 +295,6 @@ void AdvancedWidget::AddDescriptions() #endif m_enable_cropping->SetDescription(tr(TR_CROPPING_DESCRIPTION)); m_enable_prog_scan->SetDescription(tr(TR_PROGRESSIVE_SCAN_DESCRIPTION)); - m_enable_freelook->SetDescription(tr(TR_FREE_LOOK_DESCRIPTION)); - m_freelook_control_type->SetTitle(tr("Free Look Control Type")); - m_freelook_control_type->SetDescription(tr(TR_FREE_LOOK_CONTROL_TYPE_DESCRIPTION)); m_backend_multithreading->SetDescription(tr(TR_BACKEND_MULTITHREADING_DESCRIPTION)); #ifdef _WIN32 m_borderless_fullscreen->SetDescription(tr(TR_BORDERLESS_FULLSCREEN_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h index a73d9ae1de..180df811b0 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.h @@ -42,8 +42,6 @@ private: GraphicsBool* m_dump_efb_target; GraphicsBool* m_disable_vram_copies; GraphicsBool* m_load_custom_textures; - GraphicsBool* m_enable_freelook; - GraphicsChoice* m_freelook_control_type; // Texture dumping GraphicsBool* m_dump_textures; diff --git a/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.cpp b/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.cpp new file mode 100644 index 0000000000..7fcd8bb63b --- /dev/null +++ b/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.cpp @@ -0,0 +1,48 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Config/Mapping/FreeLookGeneral.h" + +#include +#include + +#include "Core/FreeLookManager.h" +#include "InputCommon/InputConfig.h" + +FreeLookGeneral::FreeLookGeneral(MappingWindow* window) : MappingWidget(window) +{ + CreateMainLayout(); +} + +void FreeLookGeneral::CreateMainLayout() +{ + auto* layout = new QGridLayout; + + layout->addWidget( + CreateGroupBox(tr("Move"), FreeLook::GetInputGroup(GetPort(), FreeLookGroup::Move)), 0, 0); + layout->addWidget( + CreateGroupBox(tr("Speed"), FreeLook::GetInputGroup(GetPort(), FreeLookGroup::Speed)), 0, 1); + layout->addWidget(CreateGroupBox(tr("Field of View"), + FreeLook::GetInputGroup(GetPort(), FreeLookGroup::FieldOfView)), + 0, 2); + layout->addWidget( + CreateGroupBox(tr("Other"), FreeLook::GetInputGroup(GetPort(), FreeLookGroup::Other)), 0, 3); + + setLayout(layout); +} + +void FreeLookGeneral::LoadSettings() +{ + FreeLook::LoadInputConfig(); +} + +void FreeLookGeneral::SaveSettings() +{ + FreeLook::GetInputConfig()->SaveConfig(); +} + +InputConfig* FreeLookGeneral::GetConfig() +{ + return FreeLook::GetInputConfig(); +} diff --git a/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.h b/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.h new file mode 100644 index 0000000000..d867db6793 --- /dev/null +++ b/Source/Core/DolphinQt/Config/Mapping/FreeLookGeneral.h @@ -0,0 +1,21 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "DolphinQt/Config/Mapping/MappingWidget.h" + +class FreeLookGeneral final : public MappingWidget +{ + Q_OBJECT +public: + explicit FreeLookGeneral(MappingWindow* window); + + InputConfig* GetConfig() override; + +private: + void LoadSettings() override; + void SaveSettings() override; + void CreateMainLayout(); +}; diff --git a/Source/Core/DolphinQt/Config/Mapping/HotkeyGraphics.cpp b/Source/Core/DolphinQt/Config/Mapping/HotkeyGraphics.cpp index 9114322bce..1212142379 100644 --- a/Source/Core/DolphinQt/Config/Mapping/HotkeyGraphics.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/HotkeyGraphics.cpp @@ -18,12 +18,12 @@ void HotkeyGraphics::CreateMainLayout() { m_main_layout = new QGridLayout(); - m_main_layout->addWidget( - CreateGroupBox(tr("Freelook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)), 0, 0, -1, 1); - m_main_layout->addWidget(CreateGroupBox(tr("Graphics Toggles"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES)), - 0, 1); + 0, 0, -1, 1); + + m_main_layout->addWidget( + CreateGroupBox(tr("FreeLook"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK)), 0, 1); m_main_layout->addWidget( CreateGroupBox(tr("Internal Resolution"), HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR)), 1, 1); diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index d433d27247..17521d12fa 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -21,6 +21,7 @@ #include "Common/IniFile.h" #include "Common/StringUtil.h" +#include "DolphinQt/Config/Mapping/FreeLookGeneral.h" #include "DolphinQt/Config/Mapping/GCKeyboardEmu.h" #include "DolphinQt/Config/Mapping/GCMicrophone.h" #include "DolphinQt/Config/Mapping/GCPadEmu.h" @@ -428,6 +429,13 @@ void MappingWindow::SetMappingType(MappingWindow::Type type) setWindowTitle(tr("Hotkey Settings")); break; } + case Type::MAPPING_FREELOOK: + { + widget = new FreeLookGeneral(this); + AddWidget(tr("General"), widget); + setWindowTitle(tr("Free Look Controller %1").arg(GetPort() + 1)); + } + break; default: return; } diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h index c98ce900a1..520cdc2f68 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.h @@ -42,7 +42,9 @@ public: // Wii MAPPING_WIIMOTE_EMU, // Hotkeys - MAPPING_HOTKEYS + MAPPING_HOTKEYS, + // Freelook + MAPPING_FREELOOK, }; explicit MappingWindow(QWidget* parent, Type type, int port_num); diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index de63050059..840233cc5e 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -55,6 +55,8 @@ + + @@ -75,6 +77,7 @@ + @@ -223,6 +226,8 @@ + + @@ -243,6 +248,7 @@ + diff --git a/Source/Core/DolphinQt/HotkeyScheduler.cpp b/Source/Core/DolphinQt/HotkeyScheduler.cpp index 1377dd6e48..1805d1e4db 100644 --- a/Source/Core/DolphinQt/HotkeyScheduler.cpp +++ b/Source/Core/DolphinQt/HotkeyScheduler.cpp @@ -15,10 +15,12 @@ #include "Common/Config/Config.h" #include "Common/Thread.h" +#include "Core/Config/FreeLookSettings.h" #include "Core/Config/GraphicsSettings.h" #include "Core/Config/UISettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/FreeLookManager.h" #include "Core/Host.h" #include "Core/HotkeyManager.h" #include "Core/IOS/IOS.h" @@ -30,7 +32,6 @@ #include "InputCommon/ControlReference/ControlReference.h" #include "InputCommon/ControllerInterface/ControllerInterface.h" -#include "VideoCommon/FreeLookCamera.h" #include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/VertexShaderManager.h" @@ -537,57 +538,15 @@ void HotkeyScheduler::Run() Config::SetCurrent(Config::GFX_STEREO_CONVERGENCE, std::min(stereo_convergence + 5, Config::GFX_STEREO_CONVERGENCE_MAXIMUM)); - // Freelook - static float fl_speed = 1.0; - + // Free Look if (IsHotkey(HK_FREELOOK_TOGGLE)) { - const bool new_value = !Config::Get(Config::GFX_FREE_LOOK); - Config::SetCurrent(Config::GFX_FREE_LOOK, new_value); - OSD::AddMessage(StringFromFormat("Freelook: %s", new_value ? "Enabled" : "Disabled")); + const bool new_value = !Config::Get(Config::FREE_LOOK_ENABLED); + Config::SetCurrent(Config::FREE_LOOK_ENABLED, new_value); + OSD::AddMessage(StringFromFormat("Free Look: %s", new_value ? "Enabled" : "Disabled")); } - if (IsHotkey(HK_FREELOOK_DECREASE_SPEED, true)) - fl_speed /= 1.1f; - - if (IsHotkey(HK_FREELOOK_INCREASE_SPEED, true)) - fl_speed *= 1.1f; - - if (IsHotkey(HK_FREELOOK_RESET_SPEED, true)) - fl_speed = 1.0; - - if (IsHotkey(HK_FREELOOK_UP, true)) - g_freelook_camera.MoveVertical(-fl_speed); - - if (IsHotkey(HK_FREELOOK_DOWN, true)) - g_freelook_camera.MoveVertical(fl_speed); - - if (IsHotkey(HK_FREELOOK_LEFT, true)) - g_freelook_camera.MoveHorizontal(fl_speed); - - if (IsHotkey(HK_FREELOOK_RIGHT, true)) - g_freelook_camera.MoveHorizontal(-fl_speed); - - if (IsHotkey(HK_FREELOOK_ZOOM_IN, true)) - g_freelook_camera.Zoom(fl_speed); - - if (IsHotkey(HK_FREELOOK_ZOOM_OUT, true)) - g_freelook_camera.Zoom(-fl_speed); - - if (IsHotkey(HK_FREELOOK_INCREASE_FOV_X, true)) - g_freelook_camera.IncreaseFovX(g_freelook_camera.GetFovStepSize()); - - if (IsHotkey(HK_FREELOOK_DECREASE_FOV_X, true)) - g_freelook_camera.IncreaseFovX(-1.0f * g_freelook_camera.GetFovStepSize()); - - if (IsHotkey(HK_FREELOOK_INCREASE_FOV_Y, true)) - g_freelook_camera.IncreaseFovY(g_freelook_camera.GetFovStepSize()); - - if (IsHotkey(HK_FREELOOK_DECREASE_FOV_Y, true)) - g_freelook_camera.IncreaseFovY(-1.0f * g_freelook_camera.GetFovStepSize()); - - if (IsHotkey(HK_FREELOOK_RESET, true)) - g_freelook_camera.Reset(); + FreeLook::UpdateInput(); // Savestates for (u32 i = 0; i < State::NUM_STATES; i++) diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 54deeb47c6..b54687828d 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -41,6 +41,7 @@ #include "Core/Config/NetplaySettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/FreeLookManager.h" #include "Core/HW/DVD/DVDInterface.h" #include "Core/HW/GCKeyboard.h" #include "Core/HW/GCPad.h" @@ -62,6 +63,7 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/CheatsManager.h" #include "DolphinQt/Config/ControllersWindow.h" +#include "DolphinQt/Config/FreeLookWindow.h" #include "DolphinQt/Config/Graphics/GraphicsWindow.h" #include "DolphinQt/Config/LogConfigWidget.h" #include "DolphinQt/Config/LogWidget.h" @@ -302,6 +304,7 @@ void MainWindow::InitControllers() Pad::Initialize(); Keyboard::Initialize(); Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES); + FreeLook::Initialize(); m_hotkey_scheduler = new HotkeyScheduler(); m_hotkey_scheduler->Start(); @@ -315,6 +318,9 @@ void MainWindow::InitControllers() Keyboard::LoadConfig(); Keyboard::GetConfig()->SaveConfig(); + + FreeLook::LoadInputConfig(); + FreeLook::GetInputConfig()->SaveConfig(); } void MainWindow::ShutdownControllers() @@ -325,6 +331,7 @@ void MainWindow::ShutdownControllers() Keyboard::Shutdown(); Wiimote::Shutdown(); HotkeyManagerEmu::Shutdown(); + FreeLook::Shutdown(); g_controller_interface.Shutdown(); m_hotkey_scheduler->deleteLater(); @@ -479,6 +486,7 @@ void MainWindow::ConnectMenuBar() connect(m_menu_bar, &MenuBar::ConfigureAudio, this, &MainWindow::ShowAudioWindow); connect(m_menu_bar, &MenuBar::ConfigureControllers, this, &MainWindow::ShowControllersWindow); connect(m_menu_bar, &MenuBar::ConfigureHotkeys, this, &MainWindow::ShowHotkeyDialog); + connect(m_menu_bar, &MenuBar::ConfigureFreelook, this, &MainWindow::ShowFreeLookWindow); // Tools connect(m_menu_bar, &MenuBar::ShowMemcardManager, this, &MainWindow::ShowMemcardManager); @@ -1101,6 +1109,19 @@ void MainWindow::ShowControllersWindow() m_controllers_window->activateWindow(); } +void MainWindow::ShowFreeLookWindow() +{ + if (!m_freelook_window) + { + m_freelook_window = new FreeLookWindow(this); + InstallHotkeyFilter(m_freelook_window); + } + + m_freelook_window->show(); + m_freelook_window->raise(); + m_freelook_window->activateWindow(); +} + void MainWindow::ShowSettingsWindow() { if (!m_settings_window) diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 8f69bd6c8e..bd9da7651c 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -23,6 +23,7 @@ class ControllersWindow; class DiscordHandler; class DragEnterEvent; class FIFOPlayerWindow; +class FreeLookWindow; class GameList; class GCTASInputWindow; class GraphicsWindow; @@ -147,6 +148,7 @@ private: void ShowAudioWindow(); void ShowControllersWindow(); void ShowGraphicsWindow(); + void ShowFreeLookWindow(); void ShowAboutDialog(); void ShowHotkeyDialog(); void ShowNetPlaySetupDialog(); @@ -213,6 +215,7 @@ private: GraphicsWindow* m_graphics_window = nullptr; FIFOPlayerWindow* m_fifo_window = nullptr; MappingWindow* m_hotkey_window = nullptr; + FreeLookWindow* m_freelook_window = nullptr; HotkeyScheduler* m_hotkey_scheduler; NetPlayDialog* m_netplay_dialog; diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 94c322e8e8..3869fcf8e5 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -528,6 +528,7 @@ void MenuBar::AddOptionsMenu() m_controllers_action = options_menu->addAction(tr("&Controller Settings"), this, &MenuBar::ConfigureControllers); options_menu->addAction(tr("&Hotkey Settings"), this, &MenuBar::ConfigureHotkeys); + options_menu->addAction(tr("&Free Look Settings"), this, &MenuBar::ConfigureFreelook); options_menu->addSeparator(); diff --git a/Source/Core/DolphinQt/MenuBar.h b/Source/Core/DolphinQt/MenuBar.h index b42a661813..c0364edbd9 100644 --- a/Source/Core/DolphinQt/MenuBar.h +++ b/Source/Core/DolphinQt/MenuBar.h @@ -91,6 +91,7 @@ signals: void ConfigureAudio(); void ConfigureControllers(); void ConfigureHotkeys(); + void ConfigureFreelook(); // View void ShowList();