diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index b533ba74d6..5abd318b1f 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -496,7 +496,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimo JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadWiimoteConfig(JNIEnv*, jclass) { - WiimoteReal::LoadSettings(); Wiimote::LoadConfig(); } diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index 7ca13a7729..755a0f9277 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -53,58 +53,6 @@ namespace BootManager { -// TODO this is an ugly hack which allows us to restore values trampled by per-game settings -// Apply fire liberally -struct ConfigCache -{ -public: - // fill the cache with values from the configuration - void SaveConfig(const SConfig& config); - // restore values to the configuration from the cache - void RestoreConfig(SConfig* config); - - // These store if the relevant setting should be reset back later (true) or if it should be left - // alone on restore (false) - bool bSetVolume = false; - std::array bSetWiimoteSource{}; - -private: - bool valid = false; - std::array iWiimoteSource{}; -}; - -void ConfigCache::SaveConfig(const SConfig& config) -{ - valid = true; - - for (int i = 0; i != MAX_BBMOTES; ++i) - iWiimoteSource[i] = WiimoteCommon::GetSource(i); - - bSetVolume = false; - bSetWiimoteSource.fill(false); -} - -void ConfigCache::RestoreConfig(SConfig* config) -{ - if (!valid) - return; - - valid = false; - - // Only change these back if they were actually set by game ini, since they can be changed while a - // game is running. - if (config->bWii) - { - for (unsigned int i = 0; i < MAX_BBMOTES; ++i) - { - if (bSetWiimoteSource[i]) - WiimoteCommon::SetSource(i, iWiimoteSource[i]); - } - } -} - -static ConfigCache config_cache; - // Boot the ISO or file bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) { @@ -113,46 +61,9 @@ bool BootCore(std::unique_ptr boot, const WindowSystemInfo& wsi) SConfig& StartUp = SConfig::GetInstance(); - config_cache.SaveConfig(StartUp); - if (!StartUp.SetPathsAndGameMetadata(*boot)) return false; - // Load game specific settings - if (!std::holds_alternative(boot->parameters)) - { - IniFile game_ini = StartUp.LoadGameIni(); - - // General settings - IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls"); - - // Wii settings - if (StartUp.bWii) - { - int source; - for (unsigned int i = 0; i < MAX_WIIMOTES; ++i) - { - controls_section->Get(fmt::format("WiimoteSource{}", i), &source, -1); - if (source != -1 && WiimoteCommon::GetSource(i) != WiimoteSource(source) && - WiimoteSource(source) >= WiimoteSource::None && - WiimoteSource(source) <= WiimoteSource::Real) - { - config_cache.bSetWiimoteSource[i] = true; - WiimoteCommon::SetSource(i, WiimoteSource(source)); - } - } - controls_section->Get("WiimoteSourceBB", &source, -1); - if (source != -1 && - WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) != WiimoteSource(source) && - (WiimoteSource(source) == WiimoteSource::None || - WiimoteSource(source) == WiimoteSource::Real)) - { - config_cache.bSetWiimoteSource[WIIMOTE_BALANCE_BOARD] = true; - WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, WiimoteSource(source)); - } - } - } - // Movie settings if (Movie::IsPlayingInput() && Movie::IsConfigSaved()) { @@ -313,7 +224,6 @@ void RestoreConfig() Config::RemoveLayer(Config::LayerType::GlobalGame); Config::RemoveLayer(Config::LayerType::LocalGame); SConfig::GetInstance().ResetRunningGameMetadata(); - config_cache.RestoreConfig(&SConfig::GetInstance()); } } // namespace BootManager diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index c0608572df..4063e01562 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -36,6 +36,8 @@ add_library(core Config/SYSCONFSettings.h Config/UISettings.cpp Config/UISettings.h + Config/WiimoteSettings.cpp + Config/WiimoteSettings.h ConfigLoaders/BaseConfigLoader.cpp ConfigLoaders/BaseConfigLoader.h ConfigLoaders/GameConfigLoader.cpp diff --git a/Source/Core/Core/Config/WiimoteSettings.cpp b/Source/Core/Core/Config/WiimoteSettings.cpp new file mode 100644 index 0000000000..6a9fe8efb2 --- /dev/null +++ b/Source/Core/Core/Config/WiimoteSettings.cpp @@ -0,0 +1,30 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "Core/Config/WiimoteSettings.h" + +#include "Core/HW/Wiimote.h" + +namespace Config +{ +const Info WIIMOTE_1_SOURCE{{System::WiiPad, "Wiimote1", "Source"}, + WiimoteSource::Emulated}; +const Info WIIMOTE_2_SOURCE{{System::WiiPad, "Wiimote2", "Source"}, + WiimoteSource::None}; +const Info WIIMOTE_3_SOURCE{{System::WiiPad, "Wiimote3", "Source"}, + WiimoteSource::None}; +const Info WIIMOTE_4_SOURCE{{System::WiiPad, "Wiimote4", "Source"}, + WiimoteSource::None}; +const Info WIIMOTE_BB_SOURCE{{System::WiiPad, "BalanceBoard", "Source"}, + WiimoteSource::None}; + +const Info& GetInfoForWiimoteSource(int index) +{ + static const std::array*, 5> infos{ + &WIIMOTE_1_SOURCE, &WIIMOTE_2_SOURCE, &WIIMOTE_3_SOURCE, + &WIIMOTE_4_SOURCE, &WIIMOTE_BB_SOURCE, + }; + return *infos[index]; +} + +} // namespace Config diff --git a/Source/Core/Core/Config/WiimoteSettings.h b/Source/Core/Core/Config/WiimoteSettings.h new file mode 100644 index 0000000000..9e97c35726 --- /dev/null +++ b/Source/Core/Core/Config/WiimoteSettings.h @@ -0,0 +1,20 @@ +// Copyright 2022 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "Common/Config/Config.h" + +enum class WiimoteSource; + +namespace Config +{ +extern const Info WIIMOTE_1_SOURCE; +extern const Info WIIMOTE_2_SOURCE; +extern const Info WIIMOTE_3_SOURCE; +extern const Info WIIMOTE_4_SOURCE; +extern const Info WIIMOTE_BB_SOURCE; + +const Info& GetInfoForWiimoteSource(int index); + +} // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index cf864b97b2..62fe3e5968 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -26,6 +26,7 @@ #include "Core/Config/MainSettings.h" #include "Core/Config/SYSCONFSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigLoaders/IsSettingSaveable.h" namespace ConfigLoaders @@ -79,6 +80,11 @@ static const INIToLocationMap& GetINIToLocationMap() {{"Controls", "PadType1"}, {Config::GetInfoForSIDevice(1).GetLocation()}}, {{"Controls", "PadType2"}, {Config::GetInfoForSIDevice(2).GetLocation()}}, {{"Controls", "PadType3"}, {Config::GetInfoForSIDevice(3).GetLocation()}}, + {{"Controls", "WiimoteSource0"}, {Config::WIIMOTE_1_SOURCE.GetLocation()}}, + {{"Controls", "WiimoteSource1"}, {Config::WIIMOTE_2_SOURCE.GetLocation()}}, + {{"Controls", "WiimoteSource2"}, {Config::WIIMOTE_3_SOURCE.GetLocation()}}, + {{"Controls", "WiimoteSource3"}, {Config::WIIMOTE_4_SOURCE.GetLocation()}}, + {{"Controls", "WiimoteSourceBB"}, {Config::WIIMOTE_BB_SOURCE.GetLocation()}}, }; return ini_to_location; } diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 18fa55f176..2dd5a5697d 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -10,6 +10,7 @@ #include "Core/Config/GraphicsSettings.h" #include "Core/Config/MainSettings.h" #include "Core/Config/UISettings.h" +#include "Core/Config/WiimoteSettings.h" namespace ConfigLoaders { @@ -129,6 +130,14 @@ bool IsSettingSaveable(const Config::Location& config_location) // UI.General &Config::MAIN_USE_DISCORD_PRESENCE.GetLocation(), + + // Wiimote + + &Config::WIIMOTE_1_SOURCE.GetLocation(), + &Config::WIIMOTE_2_SOURCE.GetLocation(), + &Config::WIIMOTE_3_SOURCE.GetLocation(), + &Config::WIIMOTE_4_SOURCE.GetLocation(), + &Config::WIIMOTE_BB_SOURCE.GetLocation(), }; return std::any_of(begin(s_setting_saveable), end(s_setting_saveable), diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index 30d522b564..675e533346 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -3,9 +3,13 @@ #include "Core/HW/Wiimote.h" +#include + #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" @@ -23,16 +27,17 @@ // Limit the amount of wiimote connect requests, when a button is pressed in disconnected state static std::array s_last_connect_request_counter; -namespace WiimoteCommon +namespace { static std::array, MAX_BBMOTES> s_wiimote_sources; +static std::optional s_config_callback_id = std::nullopt; WiimoteSource GetSource(unsigned int index) { return s_wiimote_sources[index]; } -void SetSource(unsigned int index, WiimoteSource source) +void OnSourceChanged(unsigned int index, WiimoteSource source) { const WiimoteSource previous_source = s_wiimote_sources[index].exchange(source); @@ -44,9 +49,19 @@ void SetSource(unsigned int index, WiimoteSource source) WiimoteReal::HandleWiimoteSourceChange(index); - Core::RunAsCPUThread([index] { UpdateSource(index); }); + Core::RunAsCPUThread([index] { WiimoteCommon::UpdateSource(index); }); } +void RefreshConfig() +{ + for (int i = 0; i < MAX_BBMOTES; ++i) + OnSourceChanged(i, Config::Get(Config::GetInfoForWiimoteSource(i))); +} + +} // namespace + +namespace WiimoteCommon +{ void UpdateSource(unsigned int index) { const auto bluetooth = WiiUtils::GetBluetoothEmuDevice(); @@ -144,6 +159,12 @@ void Shutdown() s_config.ClearControllers(); WiimoteReal::Stop(); + + if (s_config_callback_id) + { + Config::RemoveConfigChangedCallback(*s_config_callback_id); + s_config_callback_id = std::nullopt; + } } void Initialize(InitializeMode init_mode) @@ -158,6 +179,10 @@ void Initialize(InitializeMode init_mode) LoadConfig(); + if (!s_config_callback_id) + s_config_callback_id = Config::AddConfigChangedCallback(RefreshConfig); + RefreshConfig(); + WiimoteReal::Initialize(init_mode); // Reload Wiimotes with our settings @@ -191,7 +216,7 @@ void DoState(PointerWrap& p) { for (int i = 0; i < MAX_BBMOTES; ++i) { - const WiimoteSource source = WiimoteCommon::GetSource(i); + const WiimoteSource source = GetSource(i); auto state_wiimote_source = u8(source); p.Do(state_wiimote_source); diff --git a/Source/Core/Core/HW/Wiimote.h b/Source/Core/Core/HW/Wiimote.h index 1df00539ce..ee59aec2e1 100644 --- a/Source/Core/Core/HW/Wiimote.h +++ b/Source/Core/Core/HW/Wiimote.h @@ -54,9 +54,6 @@ namespace WiimoteCommon { class HIDWiimote; -WiimoteSource GetSource(unsigned int index); -void SetSource(unsigned int index, WiimoteSource source); - // Used to reconnect WiimoteDevice instance to HID source. // Must be run from CPU thread. void UpdateSource(unsigned int index); @@ -108,6 +105,4 @@ void Resume(); void Pause(); void Refresh(); -void LoadSettings(); - } // namespace WiimoteReal diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 4f2896ad49..6b36551774 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -11,11 +11,14 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/Swap.h" #include "Common/Thread.h" + #include "Core/Config/MainSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/Wiimote.h" @@ -25,6 +28,7 @@ #include "Core/HW/WiimoteReal/IOLinux.h" #include "Core/HW/WiimoteReal/IOWin.h" #include "Core/HW/WiimoteReal/IOhidapi.h" + #include "InputCommon/ControllerInterface/Wiimote/WiimoteController.h" #include "InputCommon/InputConfig.h" @@ -78,8 +82,11 @@ static void TryToFillWiimoteSlot(u32 index) { std::lock_guard lk(g_wiimotes_mutex); - if (g_wiimotes[index] || WiimoteCommon::GetSource(index) != WiimoteSource::Real) + if (g_wiimotes[index] || + Config::Get(Config::GetInfoForWiimoteSource(index)) != WiimoteSource::Real) + { return; + } // If the pool is empty, attempt to steal from ControllerInterface. if (s_wiimote_pool.empty()) @@ -531,9 +538,11 @@ static unsigned int CalculateWantedWiimotes() std::lock_guard lk(g_wiimotes_mutex); // Figure out how many real Wiimotes are required unsigned int wanted_wiimotes = 0; - for (unsigned int i = 0; i < MAX_WIIMOTES; ++i) - if (WiimoteCommon::GetSource(i) == WiimoteSource::Real && !g_wiimotes[i]) + for (int i = 0; i < MAX_WIIMOTES; ++i) + { + if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Real && !g_wiimotes[i]) ++wanted_wiimotes; + } return wanted_wiimotes; } @@ -541,9 +550,11 @@ static unsigned int CalculateWantedBB() { std::lock_guard lk(g_wiimotes_mutex); unsigned int wanted_bb = 0; - if (WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) == WiimoteSource::Real && + if (Config::Get(Config::WIIMOTE_BB_SOURCE) == WiimoteSource::Real && !g_wiimotes[WIIMOTE_BALANCE_BOARD]) + { ++wanted_bb; + } return wanted_bb; } @@ -823,32 +834,6 @@ int Wiimote::GetIndex() const return m_index; } -void LoadSettings() -{ - std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + WIIMOTE_INI_NAME ".ini"; - - IniFile inifile; - inifile.Load(ini_filename); - - for (unsigned int i = 0; i < MAX_WIIMOTES; ++i) - { - std::string secname("Wiimote"); - secname += static_cast('1' + i); - IniFile::Section& sec = *inifile.GetOrCreateSection(secname); - - unsigned int source = 0; - sec.Get("Source", &source, i ? int(WiimoteSource::None) : int(WiimoteSource::Emulated)); - WiimoteCommon::SetSource(i, WiimoteSource(source)); - } - - std::string secname("BalanceBoard"); - IniFile::Section& sec = *inifile.GetOrCreateSection(secname); - - unsigned int bb_source = 0; - sec.Get("Source", &bb_source, int(WiimoteSource::None)); - WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, WiimoteSource(bb_source)); -} - // config dialog calls this when some settings change void Initialize(::Wiimote::InitializeMode init_mode) { @@ -924,7 +909,7 @@ void Pause() // Called from the Wiimote scanner thread (or UI thread on source change) static bool TryToConnectWiimoteToSlot(std::unique_ptr& wm, unsigned int i) { - if (WiimoteCommon::GetSource(i) != WiimoteSource::Real || g_wiimotes[i]) + if (Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::Real || g_wiimotes[i]) return false; if (!wm->Connect(i)) diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index 25b8f54018..ec168b5c36 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -36,6 +36,7 @@ #include "Core/Boot/Boot.h" #include "Core/Config/MainSettings.h" #include "Core/Config/SYSCONFSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigLoaders/MovieConfigLoader.h" #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -169,7 +170,7 @@ std::string GetInputDisplay() s_controllers[i] = ControllerType::GC; else s_controllers[i] = ControllerType::None; - s_wiimotes[i] = WiimoteCommon::GetSource(i) != WiimoteSource::None; + s_wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None; } } @@ -506,7 +507,7 @@ void ChangeWiiPads(bool instantly) for (int i = 0; i < MAX_WIIMOTES; ++i) { - wiimotes[i] = WiimoteCommon::GetSource(i) != WiimoteSource::None; + wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None; } // This is important for Wiimotes, because they can desync easily if they get re-activated @@ -518,7 +519,8 @@ void ChangeWiiPads(bool instantly) { const bool is_using_wiimote = IsUsingWiimote(i); - WiimoteCommon::SetSource(i, is_using_wiimote ? WiimoteSource::Emulated : WiimoteSource::None); + Config::SetCurrent(Config::GetInfoForWiimoteSource(i), + is_using_wiimote ? WiimoteSource::Emulated : WiimoteSource::None); if (bt != nullptr) bt->AccessWiimoteByIndex(i)->Activate(is_using_wiimote); } diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 54aeb83e83..2d60e0f776 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -37,6 +37,7 @@ #include "Core/Config/MainSettings.h" #include "Core/Config/NetplaySettings.h" #include "Core/Config/SessionSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/GeckoCode.h" #include "Core/HW/EXI/EXI.h" @@ -1741,8 +1742,8 @@ bool NetPlayClient::StartGame(const std::string& path) for (unsigned int i = 0; i < 4; ++i) { - WiimoteCommon::SetSource(i, - m_wiimote_map[i] > 0 ? WiimoteSource::Emulated : WiimoteSource::None); + Config::SetCurrent(Config::GetInfoForWiimoteSource(i), + m_wiimote_map[i] > 0 ? WiimoteSource::Emulated : WiimoteSource::None); } // boot game diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index c0d465aafe..79557b58c7 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -176,6 +176,7 @@ + @@ -763,6 +764,7 @@ + diff --git a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp index e5616da4bf..613455ead6 100644 --- a/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp +++ b/Source/Core/DolphinQt/Config/WiimoteControllersWidget.cpp @@ -17,7 +17,10 @@ #include #include +#include "Common/Config/Config.h" + #include "Core/Config/MainSettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/Wiimote.h" @@ -301,9 +304,9 @@ void WiimoteControllersWidget::LoadSettings() { for (size_t i = 0; i < m_wiimote_groups.size(); i++) { - m_wiimote_boxes[i]->setCurrentIndex(int(WiimoteCommon::GetSource(u32(i)))); + m_wiimote_boxes[i]->setCurrentIndex(int(Config::Get(Config::GetInfoForWiimoteSource(int(i))))); } - m_wiimote_real_balance_board->setChecked(WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD) == + m_wiimote_real_balance_board->setChecked(Config::Get(Config::WIIMOTE_BB_SOURCE) == WiimoteSource::Real); m_wiimote_speaker_data->setChecked(Config::Get(Config::MAIN_WIIMOTE_ENABLE_SPEAKER)); m_wiimote_ciface->setChecked(Config::Get(Config::MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE)); @@ -328,17 +331,15 @@ void WiimoteControllersWidget::SaveSettings() Config::SetBaseOrCurrent(Config::MAIN_BLUETOOTH_PASSTHROUGH_ENABLED, m_wiimote_passthrough->isChecked()); - WiimoteCommon::SetSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ? - WiimoteSource::Real : - WiimoteSource::None); + const WiimoteSource bb_source = + m_wiimote_real_balance_board->isChecked() ? WiimoteSource::Real : WiimoteSource::None; + Config::SetBaseOrCurrent(Config::WIIMOTE_BB_SOURCE, bb_source); for (size_t i = 0; i < m_wiimote_groups.size(); i++) { const int index = m_wiimote_boxes[i]->currentIndex(); - WiimoteCommon::SetSource(u32(i), WiimoteSource(index)); + Config::SetBaseOrCurrent(Config::GetInfoForWiimoteSource(int(i)), WiimoteSource(index)); } - UICommon::SaveWiimoteSources(); - SConfig::GetInstance().SaveSettings(); } diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 7fc42cc44a..9c7d4d37ae 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -39,6 +39,7 @@ #include "Core/CommonTitles.h" #include "Core/Config/MainSettings.h" #include "Core/Config/NetplaySettings.h" +#include "Core/Config/WiimoteSettings.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/FreeLookManager.h" @@ -1735,7 +1736,7 @@ void MainWindow::OnStartRecording() controllers[i] = Movie::ControllerType::GC; else controllers[i] = Movie::ControllerType::None; - wiimotes[i] = WiimoteCommon::GetSource(i) != WiimoteSource::None; + wiimotes[i] = Config::Get(Config::GetInfoForWiimoteSource(i)) != WiimoteSource::None; } if (Movie::BeginRecordingInput(controllers, wiimotes)) @@ -1795,7 +1796,7 @@ void MainWindow::ShowTASInput() for (int i = 0; i < num_wii_controllers; i++) { - if (WiimoteCommon::GetSource(i) == WiimoteSource::Emulated && + if (Config::Get(Config::GetInfoForWiimoteSource(i)) == WiimoteSource::Emulated && (!Core::IsRunning() || SConfig::GetInstance().bWii)) { m_wii_tas_input_windows[i]->show(); diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index a5f0721251..2843a5fa3a 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -106,7 +106,6 @@ void Init() SConfig::Init(); Discord::Init(); Common::Log::LogManager::Init(); - WiimoteReal::LoadSettings(); GCAdapter::Init(); VideoBackendBase::ActivateBackend(Config::Get(Config::MAIN_GFX_BACKEND)); @@ -356,29 +355,6 @@ void SetUserDirectory(std::string custom_path) File::SetUserPath(D_USER_IDX, std::move(user_path)); } -void SaveWiimoteSources() -{ - std::string ini_filename = File::GetUserPath(D_CONFIG_IDX) + WIIMOTE_INI_NAME ".ini"; - - IniFile inifile; - inifile.Load(ini_filename); - - for (unsigned int i = 0; i < MAX_WIIMOTES; ++i) - { - std::string secname("Wiimote"); - secname += (char)('1' + i); - IniFile::Section& sec = *inifile.GetOrCreateSection(secname); - - sec.Set("Source", int(WiimoteCommon::GetSource(i))); - } - - std::string secname("BalanceBoard"); - IniFile::Section& sec = *inifile.GetOrCreateSection(secname); - sec.Set("Source", int(WiimoteCommon::GetSource(WIIMOTE_BALANCE_BOARD))); - - inifile.Save(ini_filename); -} - bool TriggerSTMPowerEvent() { const auto ios = IOS::HLE::GetIOS(); diff --git a/Source/Core/UICommon/UICommon.h b/Source/Core/UICommon/UICommon.h index ea1d44e599..6bdb11f541 100644 --- a/Source/Core/UICommon/UICommon.h +++ b/Source/Core/UICommon/UICommon.h @@ -27,8 +27,6 @@ void SetUserDirectory(std::string custom_path); bool TriggerSTMPowerEvent(); -void SaveWiimoteSources(); - // Return a pretty file size string from byte count. // e.g. 1134278 -> "1.08 MiB" std::string FormatSize(u64 bytes, int decimals = 2);