diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 6ee56e461a..2a3c11afd0 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -186,6 +186,8 @@ const Info MAIN_WII_SD_CARD_FILESIZE{{System::Main, "Core", "WiiSDCardFiles const Info MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false}; const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING{ {System::Main, "Core", "WiimoteContinuousScanning"}, false}; +const Info MAIN_WIIMOTE_AUTO_CONNECT_ADDRESSES{ + {System::Main, "Core", "WiimoteAutoConnectAddresses"}, ""}; const Info MAIN_WIIMOTE_ENABLE_SPEAKER{{System::Main, "Core", "WiimoteEnableSpeaker"}, false}; const Info MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE{ {System::Main, "Core", "WiimoteControllerInterface"}, false}; diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 748ffac440..44f33b0111 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -105,6 +105,7 @@ extern const Info MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC; extern const Info MAIN_WII_SD_CARD_FILESIZE; extern const Info MAIN_WII_KEYBOARD; extern const Info MAIN_WIIMOTE_CONTINUOUS_SCANNING; +extern const Info MAIN_WIIMOTE_AUTO_CONNECT_ADDRESSES; extern const Info MAIN_WIIMOTE_ENABLE_SPEAKER; extern const Info MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE; extern const Info MAIN_MMU; diff --git a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp index 8fe5456146..70627b31fd 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp @@ -14,6 +14,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" +#include "Core/Config/MainSettings.h" namespace WiimoteReal { @@ -52,6 +53,8 @@ bool WiimoteScannerLinux::IsReady() const void WiimoteScannerLinux::FindWiimotes(std::vector& found_wiimotes, Wiimote*& found_board) { + WiimoteScannerLinux::AddAutoConnectAddresses(found_wiimotes); + // supposedly 1.28 seconds int const wait_len = 1; @@ -111,6 +114,27 @@ void WiimoteScannerLinux::FindWiimotes(std::vector& found_wiimotes, Wi } } +void WiimoteScannerLinux::AddAutoConnectAddresses(std::vector& found_wiimotes) +{ + std::string entries = Config::Get(Config::MAIN_WIIMOTE_AUTO_CONNECT_ADDRESSES); + if (entries.empty()) + return; + for (const auto& bt_address_str : SplitString(entries, ',')) + { + bdaddr_t bt_addr; + if (str2ba(bt_address_str.c_str(), &bt_addr) < 0) + { + WARN_LOG_FMT(WIIMOTE, "Bad Known Bluetooth Address: {}", bt_address_str); + continue; + } + if (!IsNewWiimote(bt_address_str)) + continue; + Wiimote* wm = new WiimoteLinux(bt_addr); + found_wiimotes.push_back(wm); + NOTICE_LOG_FMT(WIIMOTE, "Added Wiimote with fixed address ({}).", bt_address_str); + } +} + WiimoteLinux::WiimoteLinux(bdaddr_t bdaddr) : m_bdaddr(bdaddr) { m_really_disconnect = true; diff --git a/Source/Core/Core/HW/WiimoteReal/IOLinux.h b/Source/Core/Core/HW/WiimoteReal/IOLinux.h index a27faacee9..0f84659a39 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOLinux.h +++ b/Source/Core/Core/HW/WiimoteReal/IOLinux.h @@ -50,6 +50,8 @@ public: private: int m_device_id; int m_device_sock; + + void AddAutoConnectAddresses(std::vector&); }; } // namespace WiimoteReal