Make IsValidBluetoothName just check for "Nintendo RVL-" rather than having a bunch of hardcoded names.

This commit is contained in:
Jordan Woyak 2013-01-14 17:49:49 -06:00
parent 8cf3ea3eea
commit 032013c4bc
2 changed files with 7 additions and 14 deletions

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include <queue> #include <queue>
#include <algorithm>
#include <stdlib.h> #include <stdlib.h>
#include "Common.h" #include "Common.h"
@ -512,19 +513,11 @@ void StateChange(EMUSTATE_CHANGE newState)
// TODO: disable/enable auto reporting, maybe // TODO: disable/enable auto reporting, maybe
} }
bool IsValidBluetoothName(const char* name) { bool IsValidBluetoothName(const std::string& name)
static const char* kValidWiiRemoteBluetoothNames[] = { {
"Nintendo RVL-CNT-01", std::string const prefix("Nintendo RVL-");
"Nintendo RVL-CNT-01-TR", return name.size() > prefix.size() &&
"Nintendo RVL-WBC-01", std::equal(prefix.begin(), prefix.end(), name.begin());
};
if (name == NULL)
return false;
for (size_t i = 0; i < ARRAYSIZE(kValidWiiRemoteBluetoothNames); i++)
if (strcmp(name, kValidWiiRemoteBluetoothNames[i]) == 0)
return true;
return false;
} }
}; // end of namespace }; // end of namespace

View File

@ -117,7 +117,7 @@ void StateChange(EMUSTATE_CHANGE newState);
int FindWiimotes(Wiimote** wm, int max_wiimotes); int FindWiimotes(Wiimote** wm, int max_wiimotes);
bool IsValidBluetoothName(const char* name); bool IsValidBluetoothName(const std::string& name);
}; // WiimoteReal }; // WiimoteReal