This commit is contained in:
Jordan Woyak 2025-11-15 14:52:22 -06:00 committed by GitHub
commit 4c48be43fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 30 additions and 146 deletions

View File

@ -123,8 +123,6 @@ add_library(core
FifoPlayer/FifoPlayer.h
FifoPlayer/FifoRecorder.cpp
FifoPlayer/FifoRecorder.h
FreeLookConfig.cpp
FreeLookConfig.h
FreeLookManager.cpp
FreeLookManager.h
GeckoCode.cpp

View File

@ -3,11 +3,6 @@
#include "Core/Config/FreeLookSettings.h"
#include <string>
#include "Common/Config/Config.h"
#include "Core/FreeLookConfig.h"
namespace Config
{
// Configuration Information

View File

@ -3,11 +3,16 @@
#pragma once
#include "Common/Config/Config.h"
#include "Common/Config/ConfigInfo.h"
namespace FreeLook
{
enum class ControlType : int;
enum class ControlType : int
{
SixAxis,
FPS,
Orbital
};
}
namespace Config

View File

@ -1,64 +0,0 @@
// Copyright 2020 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Core/FreeLookConfig.h"
#include <optional>
#include "Core/AchievementManager.h"
#include "Core/CPUThreadConfigCallback.h"
#include "Core/Config/AchievementSettings.h"
#include "Core/Config/FreeLookSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
namespace FreeLook
{
static Config s_config;
static Config s_active_config;
static std::optional<CPUThreadConfigCallback::ConfigChangedCallbackID>
s_config_changed_callback_id = std::nullopt;
Config& GetConfig()
{
return s_config;
}
const Config& GetActiveConfig()
{
return s_active_config;
}
void UpdateActiveConfig()
{
s_active_config = s_config;
}
Config::Config()
{
camera_config.control_type = ControlType::SixAxis;
enabled = false;
}
void Config::Refresh()
{
if (!s_config_changed_callback_id.has_value())
{
s_config_changed_callback_id =
CPUThreadConfigCallback::AddConfigChangedCallback([] { s_config.Refresh(); });
}
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
!AchievementManager::GetInstance().IsHardcoreModeActive();
}
void Config::Shutdown()
{
if (!s_config_changed_callback_id.has_value())
return;
CPUThreadConfigCallback::RemoveConfigChangedCallback(*s_config_changed_callback_id);
s_config_changed_callback_id.reset();
}
} // namespace FreeLook

View File

@ -1,41 +0,0 @@
// Copyright 2020 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// IMPORTANT: UI etc should modify the value returned by FreeLook::GetConfig().
// Free Look code should read from the value returned by FreeLook::GetActiveConfig().
// The reason for this is to get rid of race conditions etc when the
// configuration changes in the middle of a frame.
#pragma once
namespace FreeLook
{
enum class ControlType : int
{
SixAxis,
FPS,
Orbital
};
struct CameraConfig
{
ControlType control_type;
};
// NEVER inherit from this class.
struct Config final
{
Config();
void Refresh();
void Shutdown();
CameraConfig camera_config;
bool enabled;
};
Config& GetConfig();
const Config& GetActiveConfig();
// Called every frame.
void UpdateActiveConfig();
} // namespace FreeLook

View File

@ -7,14 +7,11 @@
#include <fmt/ranges.h>
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/ScopeGuard.h"
#include "Core/Config/FreeLookSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/FreeLookConfig.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
@ -22,7 +19,6 @@
#include "InputCommon/InputConfig.h"
#include "VideoCommon/FreeLookCamera.h"
#include "VideoCommon/OnScreenDisplay.h"
namespace
{
@ -326,8 +322,6 @@ void Shutdown()
{
s_config.UnregisterHotplugCallback();
s_config.ClearControllers();
GetConfig().Shutdown();
}
void Initialize()
@ -339,7 +333,7 @@ void Initialize()
s_config.RegisterHotplugCallback();
FreeLook::GetConfig().Refresh();
g_freelook_camera.RefreshConfig();
s_config.LoadConfig();
}

View File

@ -250,7 +250,6 @@
<ClInclude Include="Core\FifoPlayer\FifoDataFile.h" />
<ClInclude Include="Core\FifoPlayer\FifoPlayer.h" />
<ClInclude Include="Core\FifoPlayer\FifoRecorder.h" />
<ClInclude Include="Core\FreeLookConfig.h" />
<ClInclude Include="Core\FreeLookManager.h" />
<ClInclude Include="Core\GeckoCode.h" />
<ClInclude Include="Core\GeckoCodeConfig.h" />
@ -933,7 +932,6 @@
<ClCompile Include="Core\FifoPlayer\FifoDataFile.cpp" />
<ClCompile Include="Core\FifoPlayer\FifoPlayer.cpp" />
<ClCompile Include="Core\FifoPlayer\FifoRecorder.cpp" />
<ClCompile Include="Core\FreeLookConfig.cpp" />
<ClCompile Include="Core\FreeLookManager.cpp" />
<ClCompile Include="Core\GeckoCode.cpp" />
<ClCompile Include="Core\GeckoCodeConfig.cpp" />

View File

@ -4,18 +4,13 @@
#include "VideoCommon/FreeLookCamera.h"
#include <algorithm>
#include <math.h>
#include <fmt/format.h>
#include "Common/MathUtil.h"
#include "Common/ChunkFile.h"
#include "Core/ConfigManager.h"
#include "Common/Config/Config.h"
#include "Core/Core.h"
#include "VideoCommon/VideoCommon.h"
FreeLookCamera g_freelook_camera;
namespace
@ -260,21 +255,18 @@ float CameraControllerInput::GetSpeed() const
FreeLookCamera::FreeLookCamera()
{
SetControlType(FreeLook::ControlType::SixAxis);
RefreshConfig();
}
void FreeLookCamera::SetControlType(FreeLook::ControlType type)
void FreeLookCamera::RefreshConfig()
{
if (m_current_type && *m_current_type == type)
{
return;
}
m_is_enabled = Config::Get(Config::FREE_LOOK_ENABLED);
const auto type = Config::Get(Config::FL1_CONTROL_TYPE);
if (type == FreeLook::ControlType::SixAxis)
{
m_camera_controller = std::make_unique<SixAxisController>();
}
else if (type == FreeLook::ControlType::Orbital)
if (m_current_type == type)
return;
if (type == FreeLook::ControlType::Orbital)
{
m_camera_controller = std::make_unique<OrbitalController>();
}
@ -282,6 +274,10 @@ void FreeLookCamera::SetControlType(FreeLook::ControlType type)
{
m_camera_controller = std::make_unique<FPSController>();
}
else
{
m_camera_controller = std::make_unique<SixAxisController>();
}
m_current_type = type;
}
@ -330,7 +326,7 @@ void FreeLookCamera::DoState(PointerWrap& p)
bool FreeLookCamera::IsActive() const
{
return FreeLook::GetActiveConfig().enabled;
return m_is_enabled;
}
CameraController* FreeLookCamera::GetController() const

View File

@ -7,7 +7,7 @@
#include <optional>
#include "Common/Matrix.h"
#include "Core/FreeLookConfig.h"
#include "Core/Config/FreeLookSettings.h"
class PointerWrap;
@ -79,7 +79,9 @@ class FreeLookCamera
{
public:
FreeLookCamera();
void SetControlType(FreeLook::ControlType type);
void RefreshConfig();
Common::Matrix44 GetView() const;
Common::Vec2 GetFieldOfViewMultiplier() const;
@ -90,8 +92,10 @@ public:
CameraController* GetController() const;
private:
std::optional<FreeLook::ControlType> m_current_type;
std::unique_ptr<CameraController> m_camera_controller;
bool m_is_enabled{};
std::optional<FreeLook::ControlType> m_current_type;
};
extern FreeLookCamera g_freelook_camera;

View File

@ -305,10 +305,9 @@ void CheckForConfigChanges()
const auto old_hdr = g_ActiveConfig.bHDR;
UpdateActiveConfig();
FreeLook::UpdateActiveConfig();
g_vertex_manager->OnConfigChange();
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
g_freelook_camera.RefreshConfig();
if (g_ActiveConfig.bGraphicMods && !old_graphics_mods_enabled)
{