From f7ef58ff9a44dff06be78a5c2dd34586ffa71591 Mon Sep 17 00:00:00 2001 From: skidau Date: Thu, 29 Dec 2011 21:18:35 +1100 Subject: [PATCH] Removed the VID/PID validation for Wiimotes allowing Dolphin to detect third party wiimotes with a VID/PID that is different to Nintendo's. Checked for timeouts reported by the bluetooth stack. Added RVL-CNT-01-TR detection. --- Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp | 65 +++++-------------- .../Core/Src/HW/WiimoteReal/WiimoteReal.cpp | 17 ----- 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp index e7316a896d..c22e1972dc 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp @@ -124,11 +124,6 @@ inline void init_lib() } } -// VID = Nintendo, PID = Wiimote -static int VIDLength = 3; -static int VID[3] = {0x057E, 0x0001, 0x0002}; -static int PID[3] = {0x0306, 0x0002, 0x00F7}; - namespace WiimoteReal { @@ -210,39 +205,23 @@ int FindWiimotes(Wiimote** wm, int max_wiimotes) attr.Size = sizeof(attr); HidD_GetAttributes(dev, &attr); - bool foundWiimote = false; - for (int i = 0; i < VIDLength; i++) - { - if (attr.VendorID == VID[i] && attr.ProductID == PID[i]) - { - foundWiimote = true; - break; - } - } + // Find an unused slot + unsigned int k = 0; + for (; k < MAX_WIIMOTES && !(WIIMOTE_SRC_REAL & g_wiimote_sources[k] && !wm[k]); ++k); + wm[k] = new Wiimote(k); + wm[k]->dev_handle = dev; + memcpy(wm[k]->devicepath, detail_data->DevicePath, 197); - if (foundWiimote) + if (!wm[k]->Connect()) { - // This is a wiimote - // Find an unused slot - unsigned int k = 0; - for (; k < MAX_WIIMOTES && !(WIIMOTE_SRC_REAL & g_wiimote_sources[k] && !wm[k]); ++k); - wm[k] = new Wiimote(k); - wm[k]->dev_handle = dev; - memcpy(wm[k]->devicepath, detail_data->DevicePath, 197); - - if (!wm[k]->Connect()) - { - ERROR_LOG(WIIMOTE, "Unable to connect to wiimote %i.", wm[k]->index + 1); - delete wm[k]; - wm[k] = NULL; - } - else - ++found_wiimotes; + ERROR_LOG(WIIMOTE, "Unable to connect to wiimote %i.", wm[k]->index + 1); + delete wm[k]; + wm[k] = NULL; + CloseHandle(dev); } else { - // Not a wiimote - CloseHandle(dev); + ++found_wiimotes; } } @@ -399,28 +378,16 @@ int Wiimote::IOWrite(unsigned char* buf, int len) return i; } -#if 0 dw = GetLastError(); // Checking for 121 = timeout on semaphore/device off/disconnected to // avoid trouble with other stacks toshiba/widcomm - // 995 = The I/O operation has been aborted because of a thread exit or - // an application request. - - if ( (dw == 121) || (dw == 995) ) + if (dw == 121) { - NOTICE_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]"); + NOTICE_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]: Timeout"); RealDisconnect(); } else ERROR_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]: ERROR: %08x", dw); -#endif - - - // If the part below causes trouble on WIDCOMM/TOSHIBA stack uncomment - // the lines above, and comment out the 3 lines below instead. - - NOTICE_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]"); - RealDisconnect(); return 0; } @@ -456,8 +423,8 @@ int PairUp(bool unpair) { init_lib(); - // match strings like "Nintendo RVL-WBC-01", "Nintendo RVL-CNT-01" - const std::wregex wiimote_device_name(L"Nintendo RVL-\\w{3}-\\d{2}"); + // match strings like "Nintendo RVL-WBC-01", "Nintendo RVL-CNT-01", "Nintendo RVL-CNT-01-TR" + const std::wregex wiimote_device_name(L"Nintendo RVL-\\w{3}-\\d{2}(-\\w{2})?"); int nPaired = 0; diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp index d1e2826ed3..f5ded4125d 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp @@ -142,23 +142,6 @@ void Wiimote::InterruptChannel(const u16 channel, const void* const data, const rpt.second = (u8)size; memcpy(rpt.first, (u8*)data, size); - // some hax, since we just send the last data report to Dolphin on each Update() call - // , make the wiimote only send updated data reports when data changes - // == less bt traffic, eliminates some unneeded packets - //if (WM_REPORT_MODE == ((u8*)data)[1]) - //{ - // // also delete the last data report - // if (m_last_data_report.first) - // { - // delete[] m_last_data_report.first; - // m_last_data_report.first = NULL; - // } - - // // nice var names :p, this seems to be this one - // ((wm_report_mode*)(rpt.first + 2))->all_the_time = false; - // //((wm_report_mode*)(data + 2))->continuous = false; - //} - // Convert output DATA packets to SET_REPORT packets. // Nintendo Wiimotes work without this translation, but 3rd // party ones don't.