From 72b1570e08ed6534c924697def10612ef6b8e9d2 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Sun, 3 Jan 2010 23:05:52 +0000 Subject: [PATCH] Fixed Issue 1928 Fixed Issue 1917 (Since wxWidgets is not allowed in core, so I moved the popup window to CFrame) *Maybe* this could also fix Issue 1919? git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4780 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 39 ++++++++++++------- Source/Core/DolphinWX/Src/Frame.cpp | 12 +++++- .../Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 24 +++++++++++- .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 17 ++++---- .../Plugin_VideoSoftware/Src/Win32.cpp | 13 ++----- Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp | 12 ++---- Source/Plugins/Plugin_Wiimote/Src/main.cpp | 11 ++++++ Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp | 1 + 8 files changed, 87 insertions(+), 42 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 8b2d5bc8a7..e513f6507c 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -506,15 +506,20 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() // or CPU will disconnect WiiMote automatically // but don't send too many or it will jam the bus and cost extra CPU time // TODO: Figure out the correct frequency to send this thing - if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress() && m_WiiMotes[0].IsConnected()) + if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress()) { m_FreqDividerSync++; if (m_FreqDividerSync >= 500) // Feel free to tweak it { m_FreqDividerSync = 0; - SendEventNumberOfCompletedPackets(); - memset(m_PacketCount, 0, sizeof(m_PacketCount)); - return true; + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) + { + if (m_WiiMotes[i].IsConnected() == 3) + { + SendEventNumberOfCompletedPackets(); + return true; + } + } } } @@ -629,7 +634,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse() pInquiryResult->PayloadLength = (u8)(sizeof(SHCIEventInquiryResult) - 2 + (m_WiiMotes.size() * sizeof(hci_inquiry_response))); pInquiryResult->num_responses = (u8)m_WiiMotes.size(); - for (size_t i=0; iNumberOfHandles = Num; u16 *pData = (u16 *)(Event.m_buffer + sizeof(SHCIEventNumberOfCompletedPackets)); - for (int i = 0; i < Num; i++) + for (unsigned int i = 0; i < m_WiiMotes.size(); i++) { - pData[i] = m_WiiMotes[i].GetConnectionHandle(); - pData[Num + i] = m_PacketCount[i]; + if (m_WiiMotes[i].IsConnected() != 3) continue; + pData[0] = m_WiiMotes[i].GetConnectionHandle(); + pData[Num] = m_PacketCount[i]; + m_PacketCount[i] = 0; + pData++; } // Log @@ -1325,6 +1339,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom // void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input) { + // Inquiry should not be called normally + PanicAlert("HCI_CMD_INQUIRY is called, please report!"); + if (SendEventCommandStatus(HCI_CMD_INQUIRY)) return; @@ -1399,10 +1416,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", pDiscon->reason); SendEventDisconnect(pDiscon->con_handle, pDiscon->reason); - - PanicAlert("Wiimote (%i) has been disconnected by system due to idle time out.\n" - "Don't panic, this is quite a normal behavior for power saving.\n\n" - "To reconnect, Click \"Menu -> Tools -> Connect Wiimote\"", (pDiscon->con_handle & 0xFF) + 1); CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pDiscon->con_handle); if (pWiimote) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index b4fbd28a9d..b7ee6b6880 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -43,6 +43,7 @@ #include "ConfigManager.h" // Core #include "Core.h" #include "HW/DVDInterface.h" +#include "IPC_HLE/WII_IPC_HLE_Device_usb.h" #include "State.h" #include "VolumeHandler.h" @@ -135,7 +136,7 @@ CPanel::CPanel( : wxPanel(parent, id) { } -int abc = 0; + #ifdef _WIN32 WXLRESULT CPanel::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { @@ -157,6 +158,15 @@ int abc = 0; else main_frame->bRenderToMain = true; return 0; + + case WIIMOTE_DISCONNECT: + // The Wiimote has been disconnect, we offer reconnect here + if(AskYesNo("Wiimote %i has been disconnected by system.\n" + "Maybe this game doesn't support multi-wiimote,\n" + "or maybe it is due to idle time out or other reason.\n\n" + "Do you want to reconnect immediately?", lParam + 1, "Confirm", wxYES_NO)) + GetUsbPointer()->AccessWiiMote(lParam | 0x100)->Activate(true); + return 0; } break; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 28806b8df7..3d269c025a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -34,6 +34,20 @@ const TCHAR m_szClassName[] = _T("DolphinEmuWnd"); int g_winstyle; static volatile bool s_sizing; +// --------------------------------------------------------------------- +/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make + an empty transparent cursor */ +// ------------------ +HCURSOR hCursor = NULL, hCursorBlank = NULL; +void CreateCursors(HINSTANCE hInstance) +{ + BYTE ANDmaskCursor[] = { 0xff }; + BYTE XORmaskCursor[] = { 0x00 }; + hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor); + + hCursor = LoadCursor(NULL, IDC_ARROW); +} + bool IsSizing() { return s_sizing; @@ -117,14 +131,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) // Which then handles all the necessary steps to Shutdown the core + the plugins if (m_hParent == NULL) { - PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 ); + PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); return 0; } break; case WM_USER: - if (wParam == TOGGLE_FULLSCREEN) + if (wParam == WM_USER_STOP) + SetCursor((lParam) ? hCursor : hCursorBlank); + else if (wParam == TOGGLE_FULLSCREEN) ToggleFullscreen(hWnd); + else if (wParam == WIIMOTE_DISCONNECT) + PostMessage(m_hMain, WM_USER, wParam, lParam); break; case WM_SYSCOMMAND: @@ -159,6 +177,8 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T m_hInstance = hInstance; RegisterClassEx( &wndClass ); + CreateCursors(m_hInstance); + if (g_Config.RenderToMainframe) { m_hParent = m_hMain = parent; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index d888c344d4..23b2ca5f5c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -332,18 +332,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) and coordinate it with the other settings if nessesary */ case WM_USER: if (wParam == WM_USER_STOP) + SetCursor((lParam) ? hCursor : hCursorBlank); + else if (wParam == WM_USER_KEYDOWN) { - if (lParam) - SetCursor(hCursor); - else - SetCursor(hCursorBlank); - } - if (wParam == WM_USER_KEYDOWN) { OnKeyDown(lParam); FreeLookInput(wParam, lParam); } - if (wParam == TOGGLE_FULLSCREEN && !g_Config.RenderToMainframe) - ToggleFullscreen(m_hWnd); + else if (wParam == TOGGLE_FULLSCREEN) + { + if(!g_Config.RenderToMainframe) + ToggleFullscreen(m_hWnd); + } + else if (wParam == WIIMOTE_DISCONNECT) + PostMessage(m_hMain, WM_USER, wParam, lParam); break; // This is called when we close the window when we render to a separate window diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp index 651d54c9fe..325a941c78 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp @@ -191,15 +191,10 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) only let it pass through Dolphin > Frame.cpp to determine if it should be on or off and coordinate it with the other settings if nessesary */ case WM_USER: - /* I set wParam to 10 just in case there are other WM_USER events. If we want more - WM_USER cases we would start making wParam or lParam cases */ - if (wParam == 10) - { - if (lParam) - SetCursor(hCursor); - else - SetCursor(hCursorBlank); - } + if (wParam == WM_USER_STOP) + SetCursor((lParam) ? hCursor : hCursorBlank); + else if (wParam == WIIMOTE_DISCONNECT) + PostMessage(m_hMain, WM_USER, wParam, lParam); break; /* Post thes mouse events to the main window, it's nessesary becase in difference to the diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 74b4d09bc1..53d2e7786d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -311,6 +311,8 @@ void Shutdown() // Finally close SDL if (SDL_WasInit(0)) SDL_Quit(); + + g_SearchDeviceDone = false; } // Start emulation @@ -555,15 +557,7 @@ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size } void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) -{ - // Check for custom communication - if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_DISCONNECT) - { - WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number); - g_ReportingAuto[_number] = false; - return; - } - +{ g_ID = _number; hid_packet* hidp = (hid_packet*)_pData; diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 615c6acc52..542d757510 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -333,6 +333,17 @@ void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str()); #endif + // Check for custom communication + if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_DISCONNECT) + { + WiiMoteEmu::g_ReportingAuto[_number] = false; + WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number); +#ifdef _WIN32 + PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, _number); +#endif + return; + } + if (WiiMoteEmu::WiiMapping[_number].Source <= 1) WiiMoteEmu::ControlChannel(_number, _channelID, _pData, _Size); #if HAVE_WIIUSE diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 90ab64ae72..f89c6a5fbb 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -253,6 +253,7 @@ void Shutdown() // Remove the pointer to the initialize data g_PADInitialize = NULL; + g_SearchDeviceDone = false; }