From 430f44cb1eba66fa4af44e1c1f89265e5d2204f0 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Mon, 4 Jan 2010 03:11:31 +0000 Subject: [PATCH] Added hotkey Alt+F1/F2/F3/F4 for connect/disconnect wiimote with OSD display (But there is still a little problem with DX9 fullscreen toggling) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4782 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 20 +++++++----- Source/Core/DolphinWX/Src/Frame.h | 1 + Source/Core/DolphinWX/Src/FrameTools.cpp | 11 ++++--- .../Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 31 +++++++++++++------ .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 5 ++- .../Plugin_VideoSoftware/Src/Win32.cpp | 3 ++ 6 files changed, 48 insertions(+), 23 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index b7ee6b6880..ea6854ebcb 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -160,12 +160,17 @@ CPanel::CPanel( 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); + if (main_frame->bNoWiimoteMsg) + main_frame->bNoWiimoteMsg = false; + else + { + // 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; @@ -314,13 +319,12 @@ CFrame::CFrame(wxFrame* parent, , bRenderToMain(false), bFloatLogWindow(false), bFloatConsoleWindow(false) , HaveLeds(false), HaveSpeakers(false) , m_fLastClickTime(0), m_iLastMotionTime(0), LastMouseX(0), LastMouseY(0) + , m_bControlsCreated(false), bNoWiimoteMsg(false) #if wxUSE_TIMER , m_timer(this) #endif { - m_bControlsCreated = false; - if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true; // Give it a console early to show potential messages from this onward diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 8470023ec3..c7054a5d54 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -76,6 +76,7 @@ class CFrame : public wxFrame void InitBitmaps(); void DoStop(); bool bRenderToMain; + bool bNoWiimoteMsg; void UpdateGUI(); void ToggleLogWindow(bool, int i = -1); void ToggleConsole(bool, int i = -1); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index deff0c298c..c79e445d86 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -199,10 +199,10 @@ void CFrame::CreateMenu() toolsMenu->Append(IDM_LOAD_WII_MENU, _T("Load Wii Menu")); } toolsMenu->AppendSeparator(); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, _T("Connect Wiimote 1")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, _T("Connect Wiimote 2")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE3, _T("Connect Wiimote 3")); - toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, _T("Connect Wiimote 4")); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, _T("Connect Wiimote 1\tAlt+F1")); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, _T("Connect Wiimote 2\tAlt+F2")); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE3, _T("Connect Wiimote 3\tAlt+F3")); + toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, _T("Connect Wiimote 4\tAlt+F4")); m_MenuBar->Append(toolsMenu, _T("&Tools")); @@ -808,7 +808,10 @@ void CFrame::OnConnectWiimote(wxCommandEvent& event) if (Core::isRunning() && Core::GetStartupParameter().bWii) { int Id = event.GetId() - IDM_CONNECT_WIIMOTE1; + bNoWiimoteMsg = !event.IsChecked(); GetUsbPointer()->AccessWiiMote(Id | 0x100)->Activate(event.IsChecked()); + wxString msg(wxString::Format(wxT("Wiimote %i %s"), Id + 1, (event.IsChecked()) ? wxT("Connected") : wxT("Disconnected"))); + Core::DisplayMessage(msg.ToAscii(), 3000); } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 3d269c025a..0ab9e38532 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -113,8 +113,15 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) switch( LOWORD( wParam )) { case VK_RETURN: // Pressing Alt+Enter switch FullScreen/Windowed - ToggleFullscreen(hWnd); + if (m_hParent == NULL && !g_Config.RenderToMainframe) + { + ToggleFullscreen(hWnd); + return 0; + } break; + case VK_F1: case VK_F2: case VK_F3: case VK_F4: + PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); + return 0; } break; @@ -168,7 +175,9 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon( NULL, IDI_APPLICATION ); - wndClass.hCursor = LoadCursor( NULL, IDC_ARROW ); + // To interfer less with SetCursor() later we set this to NULL + //wndClass.hCursor = LoadCursor( NULL, IDC_ARROW ); + wndClass.hCursor = NULL; wndClass.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = m_szClassName; @@ -218,7 +227,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T void Show() { - ShowWindow(m_hWnd, SW_SHOWNORMAL); + ShowWindow(m_hWnd, SW_SHOW); BringWindowToTop(m_hWnd); UpdateWindow(m_hWnd); } @@ -259,7 +268,8 @@ void ToggleFullscreen(HWND hParent) { if (m_hParent == NULL) { - if (D3D::IsFullscreen()) { + if (D3D::IsFullscreen()) + { PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 ); return; } @@ -300,7 +310,6 @@ void ToggleFullscreen(HWND hParent) sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs); // Get into fullscreen - g_Config.bFullscreen = true; DEVMODE dmScreenSettings; memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); @@ -311,15 +320,17 @@ void ToggleFullscreen(HWND hParent) dmScreenSettings.dmFields = DM_PELSWIDTH|DM_PELSHEIGHT; if (ChangeDisplaySettings(&dmScreenSettings, 0) != DISP_CHANGE_SUCCESSFUL) return; - // Disable the cursor - ShowCursor(FALSE); - - // SetWindowPos to the upper-left corner of the screen - SetWindowPos(hParent, NULL, 0, 0, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER); // Set new window style -> PopUp SetWindowLong(hParent, GWL_STYLE, WS_POPUP); + // SetWindowPos to the upper-left corner of the screen + SetWindowPos(hParent, HWND_TOP, 0, 0, w_fs, h_fs, SWP_NOREPOSITION); + + // Disable the cursor + ShowCursor(FALSE); + g_Config.bFullscreen = true; + // Eventually show the window! EmuWindow::Show(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index 23b2ca5f5c..3a430de8d2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -291,8 +291,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { ToggleFullscreen(hWnd); return 0; - } + } break; + case VK_F1: case VK_F2: case VK_F3: case VK_F4: + PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); + return 0; } break; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp index 325a941c78..bc7e60fe32 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp @@ -148,6 +148,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) return 0; } break; + case VK_F1: case VK_F2: case VK_F3: case VK_F4: + PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); + return 0; } break;