Better checking for extension.

This commit is contained in:
Matthew Parlane 2013-05-21 22:54:01 +12:00
parent e2b0632334
commit f178015461
1 changed files with 12 additions and 3 deletions

View File

@ -344,13 +344,16 @@ void WiimoteScanner::CheckDeviceType(std::basic_string<TCHAR> &devicepath, bool
while (rc > 0 && --max_cycles > 0) while (rc > 0 && --max_cycles > 0)
{ {
if ((rc = CheckDeviceType_Read(dev_handle, buf, 1)) <= 0) if ((rc = CheckDeviceType_Read(dev_handle, buf, 1)) <= 0)
{
// DEBUG_LOG(WIIMOTE, "CheckDeviceType: Read failed...");
break; break;
}
switch (buf[1]) switch (buf[1])
{ {
case WM_STATUS_REPORT: case WM_STATUS_REPORT:
{ {
real_wiimote = true; // DEBUG_LOG(WIIMOTE, "CheckDeviceType: Got Status Report");
wm_status_report * wsr = (wm_status_report*)&buf[2]; wm_status_report * wsr = (wm_status_report*)&buf[2];
if (wsr->extension) if (wsr->extension)
{ {
@ -366,6 +369,7 @@ void WiimoteScanner::CheckDeviceType(std::basic_string<TCHAR> &devicepath, bool
} }
else else
{ {
real_wiimote = true;
// Normal Wiimote, exit while and be happy. // Normal Wiimote, exit while and be happy.
rc = -1; rc = -1;
} }
@ -373,18 +377,23 @@ void WiimoteScanner::CheckDeviceType(std::basic_string<TCHAR> &devicepath, bool
} }
case WM_ACK_DATA: case WM_ACK_DATA:
{ {
real_wiimote = true; // DEBUG_LOG(WIIMOTE, "CheckDeviceType: Got Ack");
break; break;
} }
case WM_READ_DATA_REPLY: case WM_READ_DATA_REPLY:
{ {
// DEBUG_LOG(WIIMOTE, "CheckDeviceType: Got Data Reply");
wm_read_data_reply * wrdr wm_read_data_reply * wrdr
= (wm_read_data_reply*)&buf[2]; = (wm_read_data_reply*)&buf[2];
// Check if it has returned what we asked. // Check if it has returned what we asked.
if (Common::swap16(wrdr->address) == 0x00fa) if (Common::swap16(wrdr->address) == 0x00fa)
{ {
real_wiimote = true;
// 0x020420A40000ULL means balance board. // 0x020420A40000ULL means balance board.
u64 ext_type = (*(u64*)&wrdr->data[0]); u64 ext_type = (*(u64*)&wrdr->data[0]);
// DEBUG_LOG(WIIMOTE,
// "CheckDeviceType: GOT EXT TYPE %llX",
// ext_type);
is_bb = ext_type == 0x020420A40000ULL; is_bb = ext_type == 0x020420A40000ULL;
} }
else else
@ -401,7 +410,7 @@ void WiimoteScanner::CheckDeviceType(std::basic_string<TCHAR> &devicepath, bool
default: default:
{ {
// We let read try again incase there is another packet waiting. // We let read try again incase there is another packet waiting.
// ERROR_LOG(WIIMOTE, "CheckDeviceType: GOT UNKNOWN REPLY: %X", buf[1]); // DEBUG_LOG(WIIMOTE, "CheckDeviceType: GOT UNKNOWN REPLY: %X", buf[1]);
break; break;
} }
} }