Hopefully buildfix Windows. (thanks for the patch, RachelB)

This commit is contained in:
Jordan Woyak 2013-02-07 14:15:47 -06:00
parent 246b11791b
commit 8f5fb7e6f9
6 changed files with 32 additions and 35 deletions

View File

@ -44,11 +44,6 @@ void Refresh();
void LoadSettings(); void LoadSettings();
#ifdef _WIN32
int PairUp(bool unpair = false);
int UnPair();
#endif
} }
#endif #endif

View File

@ -164,19 +164,6 @@ bool Wiimote::Connect()
return true; 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() void Wiimote::Disconnect()
{ {
close(cmd_sock); close(cmd_sock);

View File

@ -73,6 +73,8 @@ HINSTANCE bthprops_lib = NULL;
static int initialized = 0; static int initialized = 0;
int PairUp(bool unpair);
inline void init_lib() inline void init_lib()
{ {
if (!initialized) if (!initialized)
@ -132,6 +134,9 @@ WiimoteScanner::WiimoteScanner()
init_lib(); init_lib();
} }
WiimoteScanner::~WiimoteScanner()
{}
// Find and connect wiimotes. // Find and connect wiimotes.
// Does not replace already found wiimotes even if they are disconnected. // Does not replace already found wiimotes even if they are disconnected.
// wm is an array of max_wiimotes wiimotes // wm is an array of max_wiimotes wiimotes
@ -198,7 +203,7 @@ std::vector<Wiimote*> WiimoteScanner::FindWiimotes(size_t max_wiimotes)
wm->dev_handle = dev; wm->dev_handle = dev;
memcpy(wm->devicepath, detail_data->DevicePath, 197); memcpy(wm->devicepath, detail_data->DevicePath, 197);
found_wiimotes.push_back(wm); wiimotes.push_back(wm);
} }
if (detail_data) if (detail_data)
@ -206,7 +211,7 @@ std::vector<Wiimote*> WiimoteScanner::FindWiimotes(size_t max_wiimotes)
SetupDiDestroyDeviceInfoList(device_info); SetupDiDestroyDeviceInfoList(device_info);
return found_wiimotes; return wiimotes;
} }
bool WiimoteScanner::IsReady() const bool WiimoteScanner::IsReady() const
@ -262,15 +267,15 @@ bool Wiimote::IsConnected() const
int Wiimote::IORead(unsigned char* buf) int Wiimote::IORead(unsigned char* buf)
{ {
//*buf = 0; DWORD b;
if (!ReadFile(dev_handle, buf, MAX_PAYLOAD, &b, &hid_overlap)) if (!ReadFile(dev_handle, buf, MAX_PAYLOAD, &b, &hid_overlap))
{ {
// Partial read // Partial read
auto const b = GetLastError(); b = GetLastError();
if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED)) if ((b == ERROR_HANDLE_EOF) || (b == ERROR_DEVICE_NOT_CONNECTED))
{ {
// Remote disconnect // Remote disconnect
RealDisconnect(); Disconnect();
return 0; return 0;
} }
@ -308,14 +313,15 @@ int Wiimote::IORead(unsigned char* buf)
return MAX_PAYLOAD; // XXX 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) switch (stack)
{ {
case MSBT_STACK_UNKNOWN: case MSBT_STACK_UNKNOWN:
{ {
// Try to auto-detect the stack type // Try to auto-detect the stack type
DWORD bytes = 0;
auto i = WriteFile(dev_handle, buf + 1, 22, &bytes, &hid_overlap); auto i = WriteFile(dev_handle, buf + 1, 22, &bytes, &hid_overlap);
if (i) if (i)
{ {
@ -324,7 +330,7 @@ int Wiimote::IOWrite(unsigned char* buf, int len)
return i; return i;
} }
i = HidD_SetOutputReport(dev_handle, buf + 1, len - 1); i = HidD_SetOutputReport(dev_handle, (unsigned char*) buf + 1, len - 1);
if (i) if (i)
{ {
stack = MSBT_STACK_MS; 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); ERROR_LOG(WIIMOTE, "IOWrite[MSBT_STACK_UNKNOWN]: ERROR: %08x", dw);
// Correct? // Correct?
return -1 return -1;
} }
break; break;
} }
case MSBT_STACK_MS: case MSBT_STACK_MS:
{ {
i = HidD_SetOutputReport(dev_handle, buf + 1, len - 1); auto i = HidD_SetOutputReport(dev_handle, (unsigned char*) buf + 1, len - 1);
dw = GetLastError(); auto dw = GetLastError();
if (dw == 121) if (dw == 121)
{ {
// Semaphore timeout // Semaphore timeout
NOTICE_LOG(WIIMOTE, "WiimoteIOWrite[MSBT_STACK_MS]: Unable to send data to wiimote"); NOTICE_LOG(WIIMOTE, "WiimoteIOWrite[MSBT_STACK_MS]: Unable to send data to wiimote");
RealDisconnect(); Disconnect();
return 0; return 0;
} }

View File

@ -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() void Wiimote::ThreadFunc()
{ {
Common::SetCurrentThreadName("Wiimote Device Thread"); Common::SetCurrentThreadName("Wiimote Device Thread");

View File

@ -390,10 +390,6 @@ void DolphinApp::InitLanguageSupport()
int DolphinApp::OnExit() int DolphinApp::OnExit()
{ {
WiimoteReal::Shutdown(); WiimoteReal::Shutdown();
#ifdef _WIN32
if (SConfig::GetInstance().m_WiiAutoUnpair)
WiimoteReal::UnPair();
#endif
VideoBackend::ClearList(); VideoBackend::ClearList();
SConfig::Shutdown(); SConfig::Shutdown();
LogManager::Shutdown(); LogManager::Shutdown();

View File

@ -81,7 +81,7 @@ WiimoteConfigDiag::WiimoteConfigDiag(wxWindow* const parent, InputPlugin& plugin
wxFlexGridSizer* const real_wiimotes_sizer = new wxFlexGridSizer(3, 5, 5); wxFlexGridSizer* const real_wiimotes_sizer = new wxFlexGridSizer(3, 5, 5);
real_wiimotes_sizer->Add(connected_wiimotes_txt, 0, wxALIGN_CENTER_VERTICAL); real_wiimotes_sizer->Add(connected_wiimotes_txt, 0, wxALIGN_CENTER_VERTICAL);
#ifdef _WIN32 #ifdef _WIN32
real_wiimotes_sizer->Add(pairup_btn); //real_wiimotes_sizer->Add(pairup_btn);
#endif #endif
real_wiimotes_sizer->Add(refresh_btn); real_wiimotes_sizer->Add(refresh_btn);
real_wiimotes_group->Add(real_wiimotes_sizer, 1, wxALL, 5); real_wiimotes_group->Add(real_wiimotes_sizer, 1, wxALL, 5);