Wiimote: Close find handle afterwards, plus some cleanup.
Fixes Issue 2504 (thanks to Wienczny for finding that) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5270 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
48533bb3db
commit
f118de80a1
|
@ -639,7 +639,6 @@ int WiimotePairUp(void)
|
||||||
// Pair with Wii device(s)
|
// Pair with Wii device(s)
|
||||||
int radio = 0;
|
int radio = 0;
|
||||||
|
|
||||||
|
|
||||||
for (radio = 0; radio < nRadios; radio++)
|
for (radio = 0; radio < nRadios; radio++)
|
||||||
{
|
{
|
||||||
BLUETOOTH_RADIO_INFO radioInfo;
|
BLUETOOTH_RADIO_INFO radioInfo;
|
||||||
|
@ -672,17 +671,10 @@ int WiimotePairUp(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DWORD pcServices = 16;
|
|
||||||
//GUID guids[16];
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected)
|
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected)
|
||||||
{
|
{
|
||||||
// Wiimote found and not paired up yet
|
|
||||||
|
|
||||||
// Wiimote unpaired(no driver installed yet): Name: Nintendo RVL-CNT-01 ClassOfDevice: 9476 fConnected: 0 fRemembered: 0 fAuthenicated: 0
|
|
||||||
// Wiimote already paired(driver installed): Name: Nintendo RVL-CNT-01 ClassOfDevice: 9476 fConnected: 32 fRemembered: 16 fAuthenicated: 0
|
|
||||||
// Wiimote paired but disc.(driver still active): Name: Nintendo RVL-CNT-01 ClassOfDevice: 9476 fConnected: 0 fRemembered: 16 fAuthenicated: 0
|
|
||||||
//TODO: improve the readd of the BT driver, esp. when batteries of the wiimote are removed while beeing fConnected
|
//TODO: improve the readd of the BT driver, esp. when batteries of the wiimote are removed while beeing fConnected
|
||||||
if (btdi.fRemembered)
|
if (btdi.fRemembered)
|
||||||
{
|
{
|
||||||
|
@ -693,27 +685,8 @@ int WiimotePairUp(void)
|
||||||
BluetoothRemoveDevice(&btdi.Address);
|
BluetoothRemoveDevice(&btdi.Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is not done, the Wii device will not remember the pairing
|
|
||||||
// same thing here, it should return ERROR_SUCCESS, or ERROR_MORE_DATA if the wiimote
|
|
||||||
// offers more than 16 services (pcServices).
|
|
||||||
//BluetoothEnumerateInstalledServices(hRadios[radio], &btdi, &pcServices, guids);
|
|
||||||
|
|
||||||
// Activate service
|
// Activate service
|
||||||
DWORD hr = BluetoothSetServiceState(hRadios[radio], &btdi, &HumanInterfaceDeviceServiceClass_UUID, BLUETOOTH_SERVICE_ENABLE);
|
DWORD hr = BluetoothSetServiceState(hRadios[radio], &btdi, &HumanInterfaceDeviceServiceClass_UUID, BLUETOOTH_SERVICE_ENABLE);
|
||||||
|
|
||||||
////authentication not directly neeeded, read it w/o getting corrupted driver installation.
|
|
||||||
////MAC address is passphrase;
|
|
||||||
//WCHAR pass[6];
|
|
||||||
//pass[0] = radioInfo.address.rgBytes[0];
|
|
||||||
//pass[1] = radioInfo.address.rgBytes[1];
|
|
||||||
//pass[2] = radioInfo.address.rgBytes[2];
|
|
||||||
//pass[3] = radioInfo.address.rgBytes[3];
|
|
||||||
//pass[4] = radioInfo.address.rgBytes[4];
|
|
||||||
//pass[5] = radioInfo.address.rgBytes[5];
|
|
||||||
|
|
||||||
//// Pair with Wii device; Pairing before enumerating and setting service state will result mostly in unsuccessfull pairing.
|
|
||||||
//if (BluetoothAuthenticateDevice(NULL, hRadios[radio], &btdi, pass, 6) != ERROR_SUCCESS)
|
|
||||||
// error = TRUE;
|
|
||||||
if (!hr == ERROR_SUCCESS)
|
if (!hr == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
nPaired++;
|
nPaired++;
|
||||||
|
@ -722,9 +695,9 @@ int WiimotePairUp(void)
|
||||||
{
|
{
|
||||||
ERROR_LOG(WIIMOTE, "Pair-Up: BluetoothSetServiceState() returned %08x", hr);
|
ERROR_LOG(WIIMOTE, "Pair-Up: BluetoothSetServiceState() returned %08x", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} while (BluetoothFindNextDevice(hFind, &btdi));
|
} while (BluetoothFindNextDevice(hFind, &btdi));
|
||||||
|
BluetoothFindRadioClose(hFind);
|
||||||
}
|
}
|
||||||
|
|
||||||
SLEEP(10);
|
SLEEP(10);
|
||||||
|
|
Loading…
Reference in New Issue