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();
#ifdef _WIN32
int PairUp(bool unpair = false);
int UnPair();
#endif
}
#endif

View File

@ -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);

View File

@ -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<Wiimote*> 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<Wiimote*> 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;
}

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

View File

@ -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();

View File

@ -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);