From c291a2db676c330bec77e77cc08ed5210be3daae Mon Sep 17 00:00:00 2001 From: luisr142004 Date: Tue, 9 Feb 2010 00:34:27 +0000 Subject: [PATCH] make ESC pause the game now instead of quitting plus fix another bug with key and window handling git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5035 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Frame.cpp | 9 +++++++-- Source/Core/DolphinWX/Src/Frame.h | 1 + Source/Core/DolphinWX/Src/FrameTools.cpp | 8 ++++++++ Source/PluginSpecs/PluginSpecs.h | 3 ++- Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp | 10 +++++++--- Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 4 ++-- Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp | 4 ++-- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index e8f478b794..7cfef5fc0d 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -145,6 +145,11 @@ CPanel::CPanel( case WM_USER: switch(wParam) { + // Pause + case WM_USER_PAUSE: + main_frame->DoPause(); + break; + // Stop case WM_USER_STOP: main_frame->DoStop(); @@ -739,7 +744,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) } else if(event.GetKeyCode() == WXK_ESCAPE) { - main_frame->DoStop(); + main_frame->DoPause(); } // event.Skip() allows the event to propagate to the gamelist for example else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this)) @@ -932,8 +937,8 @@ void CFrame::DoFullscreen(bool bF) #ifdef _WIN32 else // Post the message to the separate rendering window which will then handle it. { - PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); BringWindowToTop((HWND)Core::GetWindowHandle()); + PostMessage((HWND)Core::GetWindowHandle(), WM_USER, TOGGLE_FULLSCREEN, 0); } #endif } diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 332545c567..4564feb911 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -74,6 +74,7 @@ class CFrame : public wxFrame wxMenuBar* m_MenuBar; wxBitmap aNormalFile; void InitBitmaps(); + void DoPause(); void DoStop(); bool bRenderToMain; bool bNoWiimoteMsg; diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index fe29e18e0d..556eeb00cd 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -144,6 +144,7 @@ void CFrame::CreateMenu() m_pSubMenuFrameSkipping = emulationMenu->AppendSubMenu(skippingMenu, _T("Frame S&kipping")); for(int i = 0; i < 10; i++) skippingMenu->Append(IDM_FRAMESKIP0 + i, wxString::Format(_T("%i"), i), wxEmptyString, wxITEM_RADIO); + skippingMenu->Check(IDM_FRAMESKIP0 + SConfig::GetInstance().m_FrameSkip, true); emulationMenu->AppendSeparator(); emulationMenu->Append(IDM_SCREENSHOT, _T("Take S&creenshot\tF9")); @@ -688,6 +689,13 @@ void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED (event)) Core::ScreenShot(); } +// Pause the emulation +void CFrame::DoPause() +{ + Core::SetState(Core::CORE_PAUSE); + UpdateGUI(); +} + // Stop the emulation void CFrame::DoStop() { diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index 77db4eaa34..7e7a8b7e56 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -18,7 +18,8 @@ enum PLUGIN_COMM { // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on - WM_USER_STOP = 10, + WM_USER_PAUSE = 10, + WM_USER_STOP, WM_USER_CREATE, WM_USER_KEYDOWN, WM_USER_VIDEO_STOP, diff --git a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp index 1fc63db440..162075d1f1 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/EmuWindow.cpp @@ -101,8 +101,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) // Pressing Esc switches to Windowed mode from Fullscreen mode ToggleFullscreen(hWnd); } - // And stops the emulation when already in Windowed mode - PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); + // And pauses the emulation when already in Windowed mode + PostMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0); } break; case '3': // OSD keys @@ -130,6 +130,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) case VK_F5: case VK_F6: case VK_F7: case VK_F8: PostMessage(m_hMain, WM_SYSKEYDOWN, wParam, lParam); break; + default: + return DefWindowProc(hWnd, iMsg, wParam, lParam); } break; @@ -144,7 +146,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) case WM_CLOSE: // When the user closes the window, we post an event to the main window to call Stop() // Which then handles all the necessary steps to Shutdown the core + the plugins - if (m_hParent == NULL) + if (!g_Config.RenderToMainframe) { PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); } @@ -171,6 +173,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) case SC_SCREENSAVE: case SC_MONITORPOWER: break; + default: + return DefWindowProc(hWnd, iMsg, wParam, lParam); } break; default: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index 58e527e0f8..0831d97463 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -250,8 +250,8 @@ void OnKeyDown(WPARAM wParam) // Pressing Esc switches to Windowed mode from Fullscreen mode ToggleFullscreen(m_hWnd); } - // then stops the emulation if already Windowed - SendMessage(m_hWnd, WM_CLOSE, 0, 0); + // then pauses the emulation if already Windowed + SendMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0); } break; case '3': // OSD keys diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp index 5b374f8ca1..1ce1763454 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp @@ -162,8 +162,8 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) // Pressing Esc switches to Windowed mode from Fullscreen mode ToggleFullscreen(hWnd); } - // And stops the emulation when already in Windowed mode - PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0); + // And pause the emulation when already in Windowed mode + PostMessage(m_hMain, WM_USER, WM_USER_PAUSE, 0); break; } g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);