diff --git a/Source/Core/Core/Src/HW/Wiimote.h b/Source/Core/Core/Src/HW/Wiimote.h index d514cf9909..dd0e6df389 100644 --- a/Source/Core/Core/Src/HW/Wiimote.h +++ b/Source/Core/Core/Src/HW/Wiimote.h @@ -44,11 +44,6 @@ void Refresh(); void LoadSettings(); -#ifdef _WIN32 -int PairUp(bool unpair = false); -int UnPair(); -#endif - } #endif diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp index 24e25e9a2b..2d3ed01e6d 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp @@ -164,19 +164,6 @@ bool Wiimote::Connect() return true; } -void Wiimote::StartThread() -{ - m_run_thread = true; - m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this); -} - -void Wiimote::StopThread() -{ - m_run_thread = false; - if (m_wiimote_thread.joinable()) - m_wiimote_thread.join(); -} - void Wiimote::Disconnect() { close(cmd_sock); diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp index e285a33729..77555bae86 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp @@ -73,6 +73,8 @@ HINSTANCE bthprops_lib = NULL; static int initialized = 0; +int PairUp(bool unpair); + inline void init_lib() { if (!initialized) @@ -132,6 +134,9 @@ WiimoteScanner::WiimoteScanner() init_lib(); } +WiimoteScanner::~WiimoteScanner() +{} + // Find and connect wiimotes. // Does not replace already found wiimotes even if they are disconnected. // wm is an array of max_wiimotes wiimotes @@ -198,7 +203,7 @@ std::vector WiimoteScanner::FindWiimotes(size_t max_wiimotes) wm->dev_handle = dev; memcpy(wm->devicepath, detail_data->DevicePath, 197); - found_wiimotes.push_back(wm); + wiimotes.push_back(wm); } if (detail_data) @@ -206,7 +211,7 @@ std::vector WiimoteScanner::FindWiimotes(size_t max_wiimotes) SetupDiDestroyDeviceInfoList(device_info); - return found_wiimotes; + return wiimotes; } bool WiimoteScanner::IsReady() const @@ -262,15 +267,15 @@ bool Wiimote::IsConnected() const int Wiimote::IORead(unsigned char* buf) { - //*buf = 0; + DWORD b; if (!ReadFile(dev_handle, buf, MAX_PAYLOAD, &b, &hid_overlap)) { // Partial read - auto const b = GetLastError(); + b = GetLastError(); if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) { // Remote disconnect - RealDisconnect(); + Disconnect(); return 0; } @@ -308,14 +313,15 @@ int Wiimote::IORead(unsigned char* buf) return MAX_PAYLOAD; // XXX } -int Wiimote::IOWrite(unsigned char* buf, int len) +int Wiimote::IOWrite(const u8* buf, int len) { + DWORD bytes = 0; switch (stack) { case MSBT_STACK_UNKNOWN: { // Try to auto-detect the stack type - DWORD bytes = 0; + auto i = WriteFile(dev_handle, buf + 1, 22, &bytes, &hid_overlap); if (i) { @@ -324,7 +330,7 @@ int Wiimote::IOWrite(unsigned char* buf, int len) return i; } - i = HidD_SetOutputReport(dev_handle, buf + 1, len - 1); + i = HidD_SetOutputReport(dev_handle, (unsigned char*) buf + 1, len - 1); if (i) { stack = MSBT_STACK_MS; @@ -343,20 +349,20 @@ int Wiimote::IOWrite(unsigned char* buf, int len) { ERROR_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]: ERROR: %08x", dw); // Correct? - return -1 + return -1; } break; } case MSBT_STACK_MS: { - i = HidD_SetOutputReport(dev_handle, buf + 1, len - 1); - dw = GetLastError(); + auto i = HidD_SetOutputReport(dev_handle, (unsigned char*) buf + 1, len - 1); + auto dw = GetLastError(); if (dw == 121) { // Semaphore timeout NOTICE_LOG(WIIMOTE, "WiimoteIOWrite[MSBT_STACK_MS]: Unable to send data to wiimote"); - RealDisconnect(); + Disconnect(); return 0; } diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp index 516fa3a51e..eb4856d2f9 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp @@ -357,6 +357,19 @@ void WiimoteScanner::ThreadFunc() } } +void Wiimote::StartThread() +{ + m_run_thread = true; + m_wiimote_thread = std::thread(std::mem_fun(&Wiimote::ThreadFunc), this); +} + +void Wiimote::StopThread() +{ + m_run_thread = false; + if (m_wiimote_thread.joinable()) + m_wiimote_thread.join(); +} + void Wiimote::ThreadFunc() { Common::SetCurrentThreadName("Wiimote Device Thread"); diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 338ed59547..d9d1908de3 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -390,10 +390,6 @@ void DolphinApp::InitLanguageSupport() int DolphinApp::OnExit() { WiimoteReal::Shutdown(); -#ifdef _WIN32 - if (SConfig::GetInstance().m_WiiAutoUnpair) - WiimoteReal::UnPair(); -#endif VideoBackend::ClearList(); SConfig::Shutdown(); LogManager::Shutdown(); diff --git a/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp index d38eadb0e1..b50ec9bc5d 100644 --- a/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp +++ b/Source/Core/DolphinWX/Src/WiimoteConfigDiag.cpp @@ -81,7 +81,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin wxFlexGridSizer* const real_wiimotes_sizer = new wxFlexGridSizer(3, 5, 5); real_wiimotes_sizer->Add(connected_wiimotes_txt, 0, wxALIGN_CENTER_VERTICAL); #ifdef _WIN32 - real_wiimotes_sizer->Add(pairup_btn); + //real_wiimotes_sizer->Add(pairup_btn); #endif real_wiimotes_sizer->Add(refresh_btn); real_wiimotes_group->Add(real_wiimotes_sizer, 1, wxALL, 5);