diff --git a/Externals/WiiUseSrc/Src/io_osx.m b/Externals/WiiUseSrc/Src/io_osx.m index 940852b306..bd7474002e 100644 --- a/Externals/WiiUseSrc/Src/io_osx.m +++ b/Externals/WiiUseSrc/Src/io_osx.m @@ -53,6 +53,7 @@ IOBluetoothL2CAPChannel * _cchan; #include "io.h" byte DataFromWiimote[MAX_PAYLOAD]; +NSUInteger g_length; static int wiiuse_connect_single(struct wiimote_t* wm, char* address); @@ -99,6 +100,7 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address); //here we got data from wiimote memcpy(DataFromWiimote, BtData, MAX_PAYLOAD); + g_length = length; //stop the main loop after reading CFRunLoopStop( CFRunLoopGetCurrent() ); @@ -318,7 +320,8 @@ static int wiiuse_connect_single(struct wiimote_t* wm, char* address) { cbt = [[ConnectBT alloc] init]; //start to connect to the wiimotes [cbt connectToWiimotes]; - + + usleep (200000); // Little delay, or else the device isn't ready! WIIUSE_INFO("Connected to wiimote [id %i].", wm->unid); /* do the handshake */ @@ -367,8 +370,11 @@ int wiiuse_io_read(struct wiimote_t* wm) { //run the main loop to get bt data CFRunLoopRun(); - memcpy(wm->event_buf,DataFromWiimote,sizeof(wm->event_buf)); + memcpy(wm->event_buf,DataFromWiimote, g_length); + if(!g_length || !wm->event_buf[0]) // no packet + return 0; + wm->event_buf[0] = 0xa2; // Make sure it's 0xa2, just in case return 1; } diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index c94495c7ef..9020943953 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -132,7 +132,10 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus); u32 netValues[2] = {0}; - int NetPlay = GetNetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues); + int NetPlay = 2; + #if defined(HAVE_WX) && HAVE_WX + NetPlay = GetNetInput(ISIDevice::m_iDeviceNumber, PadStatus, netValues); + #endif if (NetPlay != 2) { diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp index cdb0dafeb2..c90f9f209b 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp @@ -165,9 +165,13 @@ void DllConfig(HWND _hParent) } // Only allow one open at a time +#ifdef _WIN32 frame->Disable(); m_ConfigFrame->ShowModal(); frame->Enable(); +#else + m_ConfigFrame->ShowModal(); +#endif #ifdef _WIN32 frame->SetFocus(); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index d97692023a..dbae05b7c9 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -147,9 +147,13 @@ void DllConfig(HWND _hParent) } // Only allow one open at a time +#ifdef _WIN32 frame->Disable(); m_ConfigFrame->ShowModal(); frame->Enable(); +#else + m_ConfigFrame->ShowModal(); +#endif #ifdef _WIN32 frame->SetFocus(); diff --git a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp index 12662b13d2..f583dc273c 100644 --- a/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp +++ b/Source/Plugins/Plugin_GCPad/Src/GCPad.cpp @@ -164,9 +164,13 @@ void DllConfig(HWND _hParent) wxWindow *frame = GetParentedWxWindow(_hParent); m_ConfigFrame = new GCPadConfigDialog(frame); +#ifdef _WIN32 frame->Disable(); m_ConfigFrame->ShowModal(); frame->Enable(); +#else + m_ConfigFrame->ShowModal(); +#endif #ifdef _WIN32 frame->SetFocus(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index c77d9f7f4a..bcc6e4f1e1 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -291,10 +291,15 @@ void DllConfig(HWND _hParent) #endif // Prevent user to show more than 1 config window at same time +#ifdef _WIN32 frame->Disable(); m_ConfigFrame->CreateGUIControls(); m_ConfigFrame->ShowModal(); frame->Enable(); +#else + m_ConfigFrame->CreateGUIControls(); + m_ConfigFrame->ShowModal(); +#endif #ifdef _WIN32 frame->SetFocus(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index d8bd04c29c..f6b26a2f03 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -168,10 +168,13 @@ void DllConfig(HWND _hParent) #if defined(HAVE_WX) && HAVE_WX wxWindow *frame = GetParentedWxWindow(_hParent); m_BasicConfigFrame = new WiimoteBasicConfigDialog(frame); - +#ifdef _WIN32 frame->Disable(); m_BasicConfigFrame->ShowModal(); frame->Enable(); +#else + m_BasicConfigFrame->ShowModal(); +#endif #ifdef _WIN32 frame->SetFocus(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 9926a1197c..a2d757e4ce 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -77,6 +77,8 @@ bool g_RunTemporary = false; int g_RunTemporaryCountdown = 0; u8 g_EventBuffer[32]; bool g_WiimoteInUse[MAX_WIIMOTES]; + Common::Event NeedsConnect; + Common::Event Connected; // Probably this class should be in its own file @@ -315,6 +317,8 @@ int Initialize() // Return if already initialized if (g_RealWiiMoteInitialized) return g_NumberOfWiiMotes; + NeedsConnect.Init(); + Connected.Init(); // Clear the wiimote classes memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES); @@ -329,7 +333,15 @@ int Initialize() g_NumberOfWiiMotes = wiiuse_find(g_WiiMotesFromWiiUse, MAX_WIIMOTES, 5); DEBUG_LOG(WIIMOTE, "Found No of Wiimotes: %i", g_NumberOfWiiMotes); if (g_NumberOfWiiMotes > 0) + { g_RealWiiMotePresent = true; + // Create a new thread for listening for Wiimote data + // and also connecting in Linux/OSX. + // Windows connects to Wiimote in the wiiuse_find function + g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL); + NeedsConnect.Set(); + Connected.Wait(); + } else return 0; @@ -349,21 +361,10 @@ int Initialize() // Will test soon //wiiuse_set_timeout(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes, 220, 220); - // WiiUse initializes the Wiimotes in Windows right from the wiiuse_find function - // The Functionality should REALLY be changed - #ifndef _WIN32 - int Connect; - Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); - DEBUG_LOG(WIIMOTE, "Connected: %i", Connect); - #endif - // If we are connecting from the config window without a game running we set the LEDs if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_RealWiiMotePresent) FlashLights(true); - - // Create a new thread and start listening for Wiimote data - if (g_NumberOfWiiMotes > 0) - g_pReadThread = new Common::Thread(ReadWiimote_ThreadFunc, NULL); + /* Allocate memory and copy the Wiimote eeprom accelerometer neutral values to g_Eeprom. Unlike with and extension we have to do this here, because @@ -534,6 +535,15 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg) { g_StopThreadTemporary.Init(); g_StartThread.Init(); + NeedsConnect.Wait(); +#ifndef _WIN32 + int Connect; + // WiiUse initializes the Wiimotes in Windows right from the wiiuse_find function + // The Functionality should REALLY be changed + Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); + DEBUG_LOG(WIIMOTE, "Connected: %i", Connect); +#endif + Connected.Set(); while (!g_Shutdown) {