diff --git a/mc_mitm/source/controllers/controller_management.cpp b/mc_mitm/source/controllers/controller_management.cpp index 6df2530..cb67905 100644 --- a/mc_mitm/source/controllers/controller_management.cpp +++ b/mc_mitm/source/controllers/controller_management.cpp @@ -15,6 +15,7 @@ */ #include "controller_management.hpp" #include +#include "../utils.hpp" namespace ams::controller { @@ -40,10 +41,6 @@ namespace ams::controller { os::Mutex g_controller_lock(false); std::vector> g_controllers; - inline bool bdcmp(const bluetooth::Address *addr1, const bluetooth::Address *addr2) { - return std::memcmp(addr1, addr2, sizeof(bluetooth::Address)) == 0; - } - } ControllerType Identify(const bluetooth::DevicesSettings *device) { @@ -289,7 +286,7 @@ namespace ams::controller { std::scoped_lock lk(g_controller_lock); for (auto it = g_controllers.begin(); it < g_controllers.end(); ++it) { - if (bdcmp(&(*it)->Address(), address)) { + if (utils::BluetoothAddressCompare(&(*it)->Address(), address)) { g_controllers.erase(it); return; } @@ -300,7 +297,7 @@ namespace ams::controller { std::scoped_lock lk(g_controller_lock); for (auto it = g_controllers.begin(); it < g_controllers.end(); ++it) { - if (bdcmp(&(*it)->Address(), address)) { + if (utils::BluetoothAddressCompare(&(*it)->Address(), address)) { return (*it); } } diff --git a/mc_mitm/source/utils.cpp b/mc_mitm/source/utils.cpp index ddf5be4..0286712 100644 --- a/mc_mitm/source/utils.cpp +++ b/mc_mitm/source/utils.cpp @@ -17,6 +17,10 @@ namespace ams::utils { + bool BluetoothAddressCompare(const bluetooth::Address *addr1, const bluetooth::Address *addr2) { + return std::memcmp(addr1, addr2, sizeof(bluetooth::Address)) == 0; + } + Result BluetoothAddressToString(const bluetooth::Address *address, char *out, size_t out_size) { if (out_size < 2*sizeof(bluetooth::Address) + 1) return -1; diff --git a/mc_mitm/source/utils.hpp b/mc_mitm/source/utils.hpp index 7148eff..99d1983 100644 --- a/mc_mitm/source/utils.hpp +++ b/mc_mitm/source/utils.hpp @@ -18,6 +18,7 @@ namespace ams::utils { + bool BluetoothAddressCompare(const bluetooth::Address *addr1, const bluetooth::Address *addr2); Result BluetoothAddressToString(const bluetooth::Address *address, char *out, size_t out_size); }