Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linux): allow configuring real wiimotes with known bluetooth addresses #13240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Source/Core/Core/Config/MainSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_PID{{System::Main, "BluetoothPassthro
const Info<std::string> MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS{
{System::Main, "BluetoothPassthrough", "LinkKeys"}, ""};

// Main.RealWiimote

const Info<std::string> MAIN_REAL_WIIMOTE_KNOWN_ADDRESSES{
{System::Main, "RealWiimote", "KnownAddresses"}, ""};

// Main.USBPassthrough

const Info<std::string> MAIN_USB_PASSTHROUGH_DEVICES{{System::Main, "USBPassthrough", "Devices"},
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Core/Config/MainSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ extern const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_VID;
extern const Info<int> MAIN_BLUETOOTH_PASSTHROUGH_PID;
extern const Info<std::string> MAIN_BLUETOOTH_PASSTHROUGH_LINK_KEYS;

// Main.RealWiimote

extern const Info<std::string> MAIN_REAL_WIIMOTE_KNOWN_ADDRESSES;

// Main.USBPassthrough

extern const Info<std::string> MAIN_USB_PASSTHROUGH_DEVICES;
Expand Down
24 changes: 24 additions & 0 deletions Source/Core/Core/HW/WiimoteReal/IOLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/Config/MainSettings.h"

namespace WiimoteReal
{
Expand Down Expand Up @@ -50,6 +51,8 @@ bool WiimoteScannerLinux::IsReady() const

void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wiimote*& found_board)
{
WiimoteScannerLinux::AddKnownAddresses(found_wiimotes);

// supposedly 1.28 seconds
int const wait_len = 1;

Expand Down Expand Up @@ -110,6 +113,27 @@ void WiimoteScannerLinux::FindWiimotes(std::vector<Wiimote*>& found_wiimotes, Wi
}
}

void WiimoteScannerLinux::AddKnownAddresses(std::vector<Wiimote*>& found_wiimotes)
{
std::string entries = Config::Get(Config::MAIN_REAL_WIIMOTE_KNOWN_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;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/HW/WiimoteReal/IOLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class WiimoteScannerLinux final : public WiimoteScannerBackend
private:
int m_device_id;
int m_device_sock;

void AddKnownAddresses(std::vector<Wiimote*>&);
};
} // namespace WiimoteReal

Expand Down