mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-11-19 07:57:23 +00:00
Compare commits
6 Commits
a33e41c62c
...
4c48be43fe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c48be43fe | ||
|
|
0fdf1cc386 | ||
|
|
999e13b3b3 | ||
|
|
be95035cc4 | ||
|
|
d1526157df | ||
|
|
df5f351add |
@ -1,29 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BiMap<K, V>
|
||||
{
|
||||
|
||||
private Map<K, V> forward = new HashMap<>();
|
||||
private Map<V, K> backward = new HashMap<>();
|
||||
|
||||
public synchronized void add(K key, V value)
|
||||
{
|
||||
forward.put(key, value);
|
||||
backward.put(value, key);
|
||||
}
|
||||
|
||||
public synchronized V getForward(K key)
|
||||
{
|
||||
return forward.get(key);
|
||||
}
|
||||
|
||||
public synchronized K getBackward(V key)
|
||||
{
|
||||
return backward.get(key);
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -3,11 +3,6 @@
|
||||
|
||||
#include "Core/Config/FreeLookSettings.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Core/FreeLookConfig.h"
|
||||
|
||||
namespace Config
|
||||
{
|
||||
// Configuration Information
|
||||
|
||||
@ -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
|
||||
|
||||
@ -57,10 +57,19 @@ void DolphinAnalytics::AndroidSetGetValFunc(std::function<std::string(std::strin
|
||||
|
||||
DolphinAnalytics::DolphinAnalytics()
|
||||
{
|
||||
m_last_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
|
||||
|
||||
ReloadConfig();
|
||||
MakeBaseBuilder();
|
||||
|
||||
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { ReloadConfig(); });
|
||||
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] {
|
||||
bool current_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
|
||||
if (m_last_analytics_enabled != current_analytics_enabled)
|
||||
{
|
||||
m_last_analytics_enabled = current_analytics_enabled;
|
||||
ReloadConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DolphinAnalytics::~DolphinAnalytics()
|
||||
@ -80,7 +89,7 @@ void DolphinAnalytics::ReloadConfig()
|
||||
|
||||
// Install the HTTP backend if analytics support is enabled.
|
||||
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
|
||||
if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
|
||||
if (m_last_analytics_enabled)
|
||||
{
|
||||
new_backend = std::make_unique<Common::HttpAnalyticsBackend>(ANALYTICS_ENDPOINT);
|
||||
}
|
||||
|
||||
@ -203,4 +203,5 @@ private:
|
||||
std::mutex m_reporter_mutex;
|
||||
Common::AnalyticsReporter m_reporter;
|
||||
Config::ConfigChangedCallbackID m_config_changed_callback_id{};
|
||||
bool m_last_analytics_enabled = false;
|
||||
};
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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" />
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user