mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-10 12:21:39 +00:00
Config: Port SI device settings to new config system.
This commit is contained in:
parent
a0a0bfc5ca
commit
5c325eef38
17 changed files with 114 additions and 66 deletions
|
@ -12,7 +12,7 @@
|
|||
#include "Common/Flag.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HW/SI/SI.h"
|
||||
|
@ -61,6 +61,16 @@ static Common::Flag s_adapter_detect_thread_running;
|
|||
|
||||
static u64 s_last_init = 0;
|
||||
|
||||
static std::optional<size_t> s_config_callback_id = std::nullopt;
|
||||
static std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS>
|
||||
s_config_si_device_type{};
|
||||
|
||||
static void RefreshConfig()
|
||||
{
|
||||
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
|
||||
s_config_si_device_type[i] = Config::Get(Config::GetInfoForSIDevice(i));
|
||||
}
|
||||
|
||||
static void ScanThreadFunc()
|
||||
{
|
||||
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
|
||||
|
@ -200,6 +210,10 @@ void Init()
|
|||
jclass adapter_class = env->FindClass("org/dolphinemu/dolphinemu/utils/Java_GCAdapter");
|
||||
s_adapter_class = reinterpret_cast<jclass>(env->NewGlobalRef(adapter_class));
|
||||
|
||||
if (!s_config_callback_id)
|
||||
s_config_callback_id = Config::AddConfigChangedCallback(RefreshConfig);
|
||||
RefreshConfig();
|
||||
|
||||
if (UseAdapter())
|
||||
StartScanThread();
|
||||
}
|
||||
|
@ -236,6 +250,12 @@ void Shutdown()
|
|||
{
|
||||
StopScanThread();
|
||||
Reset();
|
||||
|
||||
if (s_config_callback_id)
|
||||
{
|
||||
Config::RemoveConfigChangedCallback(*s_config_callback_id);
|
||||
s_config_callback_id = std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void StartScanThread()
|
||||
|
@ -376,8 +396,7 @@ void ResetDeviceType(int chan)
|
|||
|
||||
bool UseAdapter()
|
||||
{
|
||||
const auto& si_devices = SConfig::GetInstance().m_SIDevice;
|
||||
|
||||
const auto& si_devices = s_config_si_device_type;
|
||||
return std::any_of(std::begin(si_devices), std::end(si_devices), [](const auto device_type) {
|
||||
return device_type == SerialInterface::SIDEVICE_WIIU_ADAPTER;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue