mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 01:49:33 -06:00
Merge pull request #13240 from thalesmg/20241225-m-known-bt-addresses-config-only
feat(linux): allow configuring real wiimotes with known bluetooth addresses
This commit is contained in:
@ -186,6 +186,8 @@ const Info<u64> MAIN_WII_SD_CARD_FILESIZE{{System::Main, "Core", "WiiSDCardFiles
|
|||||||
const Info<bool> MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false};
|
const Info<bool> MAIN_WII_KEYBOARD{{System::Main, "Core", "WiiKeyboard"}, false};
|
||||||
const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING{
|
const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING{
|
||||||
{System::Main, "Core", "WiimoteContinuousScanning"}, false};
|
{System::Main, "Core", "WiimoteContinuousScanning"}, false};
|
||||||
|
const Info<std::string> MAIN_WIIMOTE_AUTO_CONNECT_ADDRESSES{
|
||||||
|
{System::Main, "Core", "WiimoteAutoConnectAddresses"}, ""};
|
||||||
const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER{{System::Main, "Core", "WiimoteEnableSpeaker"}, false};
|
const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER{{System::Main, "Core", "WiimoteEnableSpeaker"}, false};
|
||||||
const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE{
|
const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE{
|
||||||
{System::Main, "Core", "WiimoteControllerInterface"}, false};
|
{System::Main, "Core", "WiimoteControllerInterface"}, false};
|
||||||
|
@ -105,6 +105,7 @@ extern const Info<bool> MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC;
|
|||||||
extern const Info<u64> MAIN_WII_SD_CARD_FILESIZE;
|
extern const Info<u64> MAIN_WII_SD_CARD_FILESIZE;
|
||||||
extern const Info<bool> MAIN_WII_KEYBOARD;
|
extern const Info<bool> MAIN_WII_KEYBOARD;
|
||||||
extern const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING;
|
extern const Info<bool> MAIN_WIIMOTE_CONTINUOUS_SCANNING;
|
||||||
|
extern const Info<std::string> MAIN_WIIMOTE_AUTO_CONNECT_ADDRESSES;
|
||||||
extern const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER;
|
extern const Info<bool> MAIN_WIIMOTE_ENABLE_SPEAKER;
|
||||||
extern const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE;
|
extern const Info<bool> MAIN_CONNECT_WIIMOTES_FOR_CONTROLLER_INTERFACE;
|
||||||
extern const Info<bool> MAIN_MMU;
|
extern const Info<bool> MAIN_MMU;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
|
|
||||||
namespace WiimoteReal
|
namespace WiimoteReal
|
||||||
{
|
{
|
||||||
@ -52,6 +53,8 @@ bool WiimoteScannerLinux::IsReady() const
|
|||||||
|
|
||||||
void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wiimote*& found_board)
|
void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wiimote*& found_board)
|
||||||
{
|
{
|
||||||
|
WiimoteScannerLinux::AddAutoConnectAddresses(found_wiimotes);
|
||||||
|
|
||||||
// supposedly 1.28 seconds
|
// supposedly 1.28 seconds
|
||||||
int const wait_len = 1;
|
int const wait_len = 1;
|
||||||
|
|
||||||
@ -111,6 +114,27 @@ void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WiimoteScannerLinux::AddAutoConnectAddresses(std::vector<Wiimote*>& 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)
|
WiimoteLinux::WiimoteLinux(bdaddr_t bdaddr) : m_bdaddr(bdaddr)
|
||||||
{
|
{
|
||||||
m_really_disconnect = true;
|
m_really_disconnect = true;
|
||||||
|
@ -50,6 +50,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_device_id;
|
int m_device_id;
|
||||||
int m_device_sock;
|
int m_device_sock;
|
||||||
|
|
||||||
|
void AddAutoConnectAddresses(std::vector<Wiimote*>&);
|
||||||
};
|
};
|
||||||
} // namespace WiimoteReal
|
} // namespace WiimoteReal
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user