mirror of
https://github.com/ndeadly/MissionControl
synced 2024-11-26 14:20:21 +00:00
mc.mitm: move and rename bdcmp function
This commit is contained in:
parent
8439391295
commit
a085eea269
3 changed files with 8 additions and 6 deletions
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#include "controller_management.hpp"
|
||||
#include <stratosphere.hpp>
|
||||
#include "../utils.hpp"
|
||||
|
||||
namespace ams::controller {
|
||||
|
||||
|
@ -40,10 +41,6 @@ namespace ams::controller {
|
|||
os::Mutex g_controller_lock(false);
|
||||
std::vector<std::shared_ptr<SwitchController>> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue