diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index 27a88026cb..24201706e1 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -993,6 +993,11 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, DataFrame, pHeader->Length + sizeof(SL2CAP_Header), "m_pHost->SendACLFrame: "); } + +// =================================================== +/* On a second boot the _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)) makes a report. However + the game eventually starts and the Wiimote connects, but it takes at least ten seconds. */ +// ---------------- void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size) { //allocate @@ -1019,6 +1024,7 @@ void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size } + namespace Core { /* This is called continously from the Wiimote plugin as soon as it has received diff --git a/Source/MusicMod.sln b/Source/MusicMod.sln index bc9628fa38..fe762043ed 100644 --- a/Source/MusicMod.sln +++ b/Source/MusicMod.sln @@ -231,7 +231,6 @@ Global {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|Win32.ActiveCfg = Debug|Win32 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|x64.ActiveCfg = Debug|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.Build.0 = DebugFast|Win32 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|x64.ActiveCfg = DebugFast|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.ActiveCfg = Release|Win32 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.ActiveCfg = Release|x64 @@ -306,7 +305,6 @@ Global {33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.ActiveCfg = Debug|x64 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.Debug|x64.Build.0 = Debug|x64 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|Win32.Build.0 = DebugFast|Win32 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.ActiveCfg = DebugFast|x64 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.DebugFast|x64.Build.0 = DebugFast|x64 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|Win32.ActiveCfg = Release|Win32 @@ -315,6 +313,7 @@ Global {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.ActiveCfg = Debug|Win32 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.ActiveCfg = Debug|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 + {8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.Build.0 = DebugFast|Win32 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.ActiveCfg = DebugFast|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32 @@ -371,7 +370,6 @@ Global {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.ActiveCfg = Debug|x64 {DE7C596C-CBC4-4278-8909-146D63990803}.Debug|x64.Build.0 = Debug|x64 {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|Win32.Build.0 = DebugFast|Win32 {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.ActiveCfg = DebugFast|x64 {DE7C596C-CBC4-4278-8909-146D63990803}.DebugFast|x64.Build.0 = DebugFast|x64 {DE7C596C-CBC4-4278-8909-146D63990803}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 327d952fca..9373705007 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -48,16 +48,26 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_CHECKBOX(ID_CONNECT_REAL, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_USE_REAL, ConfigDialog::GeneralSettingsChanged) + + EVT_TIMER(IDTM_EXIT, ConfigDialog::FlashLights) END_EVENT_TABLE() ///////////////////////////// -ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style) +ConfigDialog::ConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, + const wxPoint &position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) { + #if wxUSE_TIMER + m_ExitTimer = new wxTimer(this, IDTM_EXIT); + // Reset values + ShutDown = false; + #endif + g_Config.Load(); CreateGUIControls(); + UpdateGUI(); } ConfigDialog::~ConfigDialog() @@ -184,6 +194,71 @@ void ConfigDialog::AboutClick(wxCommandEvent& WXUNUSED (event)) ///////////////////////////////// +///////////////////////////////////////////////////////////////////////// +/* Flash lights and rumble (for Connect and Disconnect) in its own thread like this + to avoid a delay when the Connect checkbox is pressed (that would occur if we use + Sleep() instead). */ +// ------------ +void ConfigDialog::StartTimer() +{ + TimerCounter = 0; + + // Start the constant timer + int TimesPerSecond = 10; + m_ExitTimer->Start( floor((double)(1000 / TimesPerSecond)) ); + + // Run it immedeately for the first time + DoFlashLights(); +} + +void ConfigDialog::DoFlashLights() +{ + TimerCounter++; + + if(TimerCounter == 1) wiiuse_rumble(WiiMoteReal::g_WiiMotesFromWiiUse[0], 1); + + if(TimerCounter == 1) + { + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_1); + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_2); + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_3); + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4); + } + + // Make the rumble period equal on both Init and Shutdown + if (TimerCounter == 1 && ShutDown) TimerCounter++; + + if (TimerCounter >= 3 || TimerCounter <= 5) + { + wiiuse_rumble(WiiMoteReal::g_WiiMotesFromWiiUse[0], 0); + } + + if(TimerCounter == 3) + { + if(ShutDown) + { + // Set led 4 + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE); + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4); + + // Clean up wiiuse + wiiuse_cleanup(WiiMoteReal::g_WiiMotesFromWiiUse, WiiMoteReal::g_NumberOfWiiMotes); + + ShutDown = false; + } + else + { + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE); + wiiuse_set_leds(WiiMoteReal::g_WiiMotesFromWiiUse[0], WIIMOTE_LED_1); + } + + // Stop timer + m_ExitTimer->Stop(); + } + + Console::Print("TimerCounter == %i\n", TimerCounter); +} +///////////////////////////////// // =================================================== @@ -288,6 +363,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) break; ///////////////// } + g_Config.Save(); UpdateGUI(); } @@ -298,7 +374,12 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) // ------------- void ConfigDialog::UpdateGUI() { - // Save status - m_ConnectRealWiimote->Enable(g_RealWiiMotePresent); + /* I have disabled this option during a running game because it's enough to be able to switch + between using and not using then. To also use the connect option during a running game would + mean that the wiimote must be sent the current reporting mode and the channel ID after it + has been initialized. If you know how to set that manually please feel free to make functions + for that so that this option can be enabled during gameplay. */ + m_ConnectRealWiimote->Enable(!g_EmulatorRunning); m_UseRealWiimote->Enable(g_RealWiiMotePresent && g_Config.bConnectRealWiimote); + Console::Print("Present: %i, Connect: %i\n", g_RealWiiMotePresent, g_Config.bConnectRealWiimote); } diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h index bac5d801ae..6a0f6895cb 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.h @@ -39,7 +39,15 @@ class ConfigDialog : public wxDialog const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); virtual ~ConfigDialog(); + void CloseClick(wxCommandEvent& event); + void UpdateGUI(); + + wxTimer * m_ExitTimer; + void DoFlashLights(); + void StartTimer(); + void FlashLights(wxTimerEvent& WXUNUSED(event)) { DoFlashLights(); } + bool ShutDown; int TimerCounter; private: DECLARE_EVENT_TABLE(); @@ -59,6 +67,7 @@ class ConfigDialog : public wxDialog { ID_CLOSE = 1000, ID_ABOUTOGL, + IDTM_EXIT, // Timer ID_NOTEBOOK, ID_PAGEEMU, @@ -81,8 +90,7 @@ class ConfigDialog : public wxDialog void DoExtensionConnectedDisconnected(); // Emulated - void GeneralSettingsChanged(wxCommandEvent& event); - void UpdateGUI(); + void GeneralSettingsChanged(wxCommandEvent& event); }; #endif diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 7eebfa57d0..4303ac74c6 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -25,8 +25,9 @@ #include #include "Common.h" // Common -#include "StringUtil.h" // for ArrayToString +#include "StringUtil.h" // for ArrayToString() +#include "main.h" #include "wiimote_hid.h" #include "EmuSubroutines.h" #include "EmuDefinitions.h" @@ -108,6 +109,8 @@ void WriteCrypted16(u8* _baseBlock, u16 _address, u16 _value) // ---------------- void Initialize() { + if (g_EmulatedWiiMoteInitialized) return; + memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE); memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0)); memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0)); @@ -132,9 +135,11 @@ void Initialize() memcpy(g_RegExt + 0xfa, classic_id, sizeof(classic_id)); } + g_EmulatedWiiMoteInitialized = true; -// g_RegExt[0xfd] = 0x1e; -// g_RegExt[0xfc] = 0x9a; + // I forgot what these were for? + // g_RegExt[0xfd] = 0x1e; + // g_RegExt[0xfc] = 0x9a; } // ================ @@ -197,6 +202,8 @@ void CheckAckDelay() // ---------------- void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) { + //Console::Print("Emu InterruptChannel\n"); + LOGV(WII_IPC_WIIMOTE, 3, "============================================================="); LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input"); const u8* data = (const u8*)_pData; @@ -267,7 +274,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) //if((data[1] == WM_WRITE_DATA || data[1] == WM_READ_DATA) // && data[3] == 0xa4) //{ - if (!g_Config.bUseRealWiimote) CreateAckDelay((u8)_channelID, (u16)sr->channel); + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) CreateAckDelay((u8)_channelID, (u16)sr->channel); //} //else //{ @@ -295,8 +302,10 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) { + //Console::Print("Emu ControlChannel\n"); + const u8* data = (const u8*)_pData; - // dump raw data + // Dump raw data { LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel"); std::string Temp = ArrayToString(data, 0, _Size); @@ -353,7 +362,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) void Update() { //LOG(WII_IPC_WIIMOTE, "Wiimote_Update"); - Console::Print("g_ReportingMode %i\n", g_ReportingMode); + //Console::Print("Emu Update: %i\n", g_ReportingMode); switch(g_ReportingMode) { diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index 66396e9d53..4d9727f546 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -39,14 +39,14 @@ ////////////////////////////////////////////////////////////////////////////////////////// // Includes // ŻŻŻŻŻŻŻŻŻŻŻŻŻ -#include "pluginspecs_wiimote.h" - #include #include #include "Common.h" // Common #include "StringUtil.h" +#include "pluginspecs_wiimote.h" +#include "main.h" // Local #include "wiimote_hid.h" #include "EmuMain.h" #include "EmuSubroutines.h" @@ -97,12 +97,12 @@ void HidOutputReport(u16 _channelID, wm_report* sr) { WmDataReporting(_channelID, (wm_data_reporting*)sr->data); break; case WM_REQUEST_STATUS: // 0x15 - if (!g_Config.bUseRealWiimote) WmRequestStatus(_channelID, (wm_request_status*)sr->data); + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmRequestStatus(_channelID, (wm_request_status*)sr->data); //Temp = ArrayToString(sr->data, sizeof(wm_request_status), 0); //Console::Print("\n%s: InterruptChannel: %s\n", Tm().c_str(), Temp.c_str()); break; case WM_READ_DATA: // 0x17 - if (!g_Config.bUseRealWiimote) WmReadData(_channelID, (wm_read_data*)sr->data); + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmReadData(_channelID, (wm_read_data*)sr->data); break; /* This enables or disables the IR lights, we update the global variable g_IR @@ -116,17 +116,17 @@ void HidOutputReport(u16 _channelID, wm_report* sr) { break; case WM_WRITE_DATA: // 0x16 - if (!g_Config.bUseRealWiimote) WmWriteData(_channelID, (wm_write_data*)sr->data); + if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WmWriteData(_channelID, (wm_write_data*)sr->data); break; case WM_SPEAKER_ENABLE: // 0x14 LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); - Console::Print("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); + //Console::Print("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); if(sr->data[0] == 0x02) g_Speaker = 0; else if(sr->data[0] == 0x06) g_Speaker = 1; break; case WM_SPEAKER_MUTE: LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]); - Console::Print("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); + //Console::Print("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]); if(sr->data[0] == 0x02) g_SpeakerVoice = 0; // g_SpeakerVoice else if(sr->data[0] == 0x06) g_SpeakerVoice = 1; break; @@ -196,9 +196,9 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address) LOGV(WII_IPC_WIIMOTE, 2, " WMSendAck()"); LOGV(WII_IPC_WIIMOTE, 2, " Report ID: %02x", _reportID); - //std::string Temp = ArrayToString(DataFrame, Offset, 0); + std::string Temp = ArrayToString(DataFrame, Offset, 0); //LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str()); - //Console::Print("%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str()); + Console::Print("%s: WMSendAck: %s\n", Tm(true).c_str(), Temp.c_str()); /* Debug. Write the report for extension registry writes. if((_reportID == 0x16 || _reportID == 0x17) && ((address >> 16) & 0xfe) == 0xa4) diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 5e72dbb24a..7d887f881f 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -48,20 +48,23 @@ bool g_EmulatorRunning = false; bool g_FrameOpen = false; bool g_RealWiiMotePresent = false; bool g_RealWiiMoteInitialized = false; +bool g_EmulatedWiiMoteInitialized = false; HINSTANCE g_hInstance; #if defined(HAVE_WX) && HAVE_WX -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) + wxWindow win; + ConfigDialog *frame; -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); + class wxDLLApp : public wxApp + { + bool OnInit() + { + return true; + } + }; + IMPLEMENT_APP_NO_MAIN(wxDLLApp) + WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); #endif //////////////////////////////////// @@ -127,17 +130,17 @@ void DllConfig(HWND _hParent) { #if defined(HAVE_WX) && HAVE_WX - wxWindow win; - #ifdef _WIN32 win.SetHWND(_hParent); #endif + g_FrameOpen = true; + frame = new ConfigDialog(&win); + DoInitialize(); - g_FrameOpen = true; - ConfigDialog frame(&win); - frame.ShowModal(); - //frame.Show(); + + frame->ShowModal(); + //frame.Show(); #ifdef _WIN32 win.SetHWND(0); @@ -154,18 +157,33 @@ extern "C" void Initialize(void *init) g_EmulatorRunning = true; + #if defined(HAVE_WX) && HAVE_WX + if(g_FrameOpen) if(frame) frame->UpdateGUI(); + #endif + DoInitialize(); } extern "C" void Shutdown(void) { // We will only shutdown when both a game and the frame is closed - if (g_FrameOpen) { g_EmulatorRunning = false; return; } + if (g_FrameOpen) + { + #if defined(HAVE_WX) && HAVE_WX + if(frame) frame->UpdateGUI(); + #endif + return; + } + + // Not running + g_EmulatorRunning = false; #if HAVE_WIIUSE if(g_RealWiiMoteInitialized) WiiMoteReal::Shutdown(); #endif WiiMoteEmu::Shutdown(); + + Console::Close(); } @@ -180,7 +198,11 @@ extern "C" void DoState(unsigned char **ptr, int mode) // =================================================== /* This function produce Wiimote Input (reports from the Wiimote) in response - to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp. */ + to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp. + + Switch between real and emulated wiimote: We send all this Input to WiiMoteEmu::InterruptChannel() + so that it knows the channel ID and the data reporting mode at all times. + */ // ---------------- extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) { @@ -196,11 +218,11 @@ extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 } // Decice where to send the message - //if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) - WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size); + //if (!g_RealWiiMotePresent) + WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size); #if HAVE_WIIUSE - //else if (g_RealWiiMotePresent) - WiiMoteReal::InterruptChannel(_channelID, _pData, _Size); + if (g_RealWiiMotePresent) + WiiMoteReal::InterruptChannel(_channelID, _pData, _Size); #endif LOGV(WII_IPC_WIIMOTE, 3, "============================================================="); @@ -223,10 +245,10 @@ extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _ LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str()); } - if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) + if (!g_RealWiiMotePresent) WiiMoteEmu::ControlChannel(_channelID, _pData, _Size); #if HAVE_WIIUSE - else if (g_RealWiiMotePresent) + else WiiMoteReal::ControlChannel(_channelID, _pData, _Size); #endif diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index 731f790373..18e54b87d0 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -22,6 +22,9 @@ // Includes // ŻŻŻŻŻŻŻŻŻŻ #include // System +#if defined(HAVE_WX) && HAVE_WX + #include "ConfigDlg.h" +#endif //////////////////////////////// @@ -44,6 +47,11 @@ void DoInitialize(); extern bool g_FrameOpen; extern bool g_RealWiiMotePresent; extern bool g_RealWiiMoteInitialized; + extern bool g_EmulatedWiiMoteInitialized; + + #if defined(HAVE_WX) && HAVE_WX + extern ConfigDialog *frame; + #endif #endif //////////////////////////////// diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index 8e783c755f..41802bdde2 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -35,6 +35,9 @@ #include "EmuMain.h" #define EXCLUDE_H // Avoid certain declarations in main.h #include "wiimote_real.h" +#if defined(HAVE_WX) && HAVE_WX + #include "ConfigDlg.h" +#endif extern SWiimoteInitialize g_WiimoteInitialize; //////////////////////////////////////// @@ -241,7 +244,6 @@ void SendEvent(SEvent& _rEvent) //****************************************************************************** // Function Definitions //****************************************************************************** - int Initialize() { if (g_RealWiiMoteInitialized) return g_NumberOfWiiMotes; @@ -263,14 +265,7 @@ int Initialize() //int Connect = wiiuse_connect(g_WiiMotesFromWiiUse, MAX_WIIMOTES); //Console::Print("Connected: %i\n", Connect); - wiiuse_rumble(g_WiiMotesFromWiiUse[0], 1); - wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4); - Sleep(40); - wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_NONE); - Sleep(40); - wiiuse_set_leds(g_WiiMotesFromWiiUse[0], WIIMOTE_LED_4); - Sleep(120); - wiiuse_rumble(g_WiiMotesFromWiiUse[0], 0); + if(frame) frame->StartTimer(); } else { @@ -295,7 +290,7 @@ void DoState(void* ptr, int mode) {} void Shutdown(void) { - g_Shutdown = true; + g_Shutdown = true; // Stop the thread if (g_pReadThread != NULL) @@ -312,20 +307,31 @@ void Shutdown(void) g_WiiMotes[i] = NULL; } - // Clean up wiiuse - wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes); + #if defined(HAVE_WX) && HAVE_WX + if(frame) frame->ShutDown = true; + if(frame) frame->StartTimer(); + #else + // Clean up wiiuse + wiiuse_cleanup(g_WiiMotesFromWiiUse, g_NumberOfWiiMotes); + + // Uninitialized + g_RealWiiMoteInitialized = false; + #endif // Uninitialized g_RealWiiMoteInitialized = false; + g_RealWiiMotePresent = false; } void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size) { + //Console::Print("Real InterruptChannel\n"); g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size); } void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) { + //Console::Print("Real ControlChannel\n"); g_WiiMotes[0]->SendData(_channelID, (const u8*)_pData, _Size); } @@ -335,6 +341,7 @@ void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) // --------------- void Update() { + //Console::Print("Real Update\n"); for (int i = 0; i < g_NumberOfWiiMotes; i++) { g_WiiMotes[i]->Update(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.h b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.h index 3c3b3ad078..6ccdf89668 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.h +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.h @@ -41,7 +41,8 @@ void Update(); void ReadWiimote(); #ifndef EXCLUDE_H - extern wiimote_t** g_WiiMotesFromWiiUse; + extern wiimote_t** g_WiiMotesFromWiiUse; + extern int g_NumberOfWiiMotes; #endif }; // WiiMoteReal