1. Proper shutdown, hopefully no crash anymore (Continuation of skidau's work)
2. Connect/Disconnect Wiimote on the fly, no need to pause game PS: Toggling full screen by ESC in DX9 doesn't work yet, it will close Dolphin instead at the time. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4754 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
f97b782551
commit
97779ea295
|
@ -102,9 +102,7 @@ SCoreStartupParameter g_CoreStartupParameter;
|
|||
// This event is set when the emuthread starts.
|
||||
Common::Event emuThreadGoing;
|
||||
Common::Event cpuRunloopQuit;
|
||||
Common::Event gpuShutdownCall;
|
||||
|
||||
|
||||
// Display messages and return values
|
||||
|
||||
// Formatted stop message
|
||||
|
@ -300,16 +298,6 @@ THREAD_RETURN CpuThread(void *pArg)
|
|||
CCPU::Run();
|
||||
cpuRunloopQuit.Set();
|
||||
|
||||
#ifdef _WIN32
|
||||
gpuShutdownCall.Wait();
|
||||
|
||||
// Call video shutdown from the video thread in single core mode, which is the cpuThread
|
||||
if (!_CoreParameter.bCPUThread)
|
||||
Plugins.ShutdownVideoPlugin();
|
||||
#endif
|
||||
|
||||
gpuShutdownCall.Shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -319,7 +307,6 @@ THREAD_RETURN CpuThread(void *pArg)
|
|||
THREAD_RETURN EmuThread(void *pArg)
|
||||
{
|
||||
cpuRunloopQuit.Init();
|
||||
gpuShutdownCall.Init();
|
||||
|
||||
Common::SetCurrentThreadName("Emuthread - starting");
|
||||
const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter;
|
||||
|
@ -472,6 +459,7 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||
// then we lose the powerdown check. ... unless powerdown sends a message :P
|
||||
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
||||
{
|
||||
Host_UpdateMainFrame();
|
||||
if (Callback_PeekMessages)
|
||||
Callback_PeekMessages();
|
||||
Common::SleepCurrentThread(20);
|
||||
|
@ -483,33 +471,9 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||
#endif
|
||||
}
|
||||
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Stop() and Video Loop Ended").c_str());
|
||||
WARN_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
|
||||
|
||||
// We have now exited the Video Loop and will shut down
|
||||
|
||||
// Write message
|
||||
if (g_pUpdateFPSDisplay != NULL) g_pUpdateFPSDisplay("Stopping...");
|
||||
|
||||
HW::Shutdown();
|
||||
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str());
|
||||
WARN_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down plugins").c_str());
|
||||
Plugins.ShutdownPlugins();
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Plugins shutdown").c_str());
|
||||
|
||||
#ifdef _WIN32
|
||||
gpuShutdownCall.Set();
|
||||
|
||||
// Call video shutdown from the video thread, in dual core mode it's the EmuThread
|
||||
// Or set an event in Single Core mode, to call the shutdown from the cpuThread
|
||||
if (_CoreParameter.bCPUThread)
|
||||
Plugins.ShutdownVideoPlugin();
|
||||
#else
|
||||
// On unix platforms, the EmuThread is ALWAYS the video thread
|
||||
Plugins.ShutdownVideoPlugin();
|
||||
#endif
|
||||
|
||||
if (cpuThread)
|
||||
{
|
||||
WARN_LOG(CONSOLE, "%s", StopMessage(true, "Stopping CPU thread ...").c_str());
|
||||
|
@ -539,13 +503,25 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||
cpuThread = NULL;
|
||||
}
|
||||
|
||||
// The hardware is uninitialized
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Stop() and Video Loop Ended").c_str());
|
||||
// We have now exited the Video Loop and will shut down
|
||||
|
||||
g_bHwInit = false;
|
||||
g_bStopping = false;
|
||||
|
||||
|
||||
WARN_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down plugins").c_str());
|
||||
Plugins.ShutdownVideoPlugin();
|
||||
Plugins.ShutdownPlugins();
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Plugins shutdown").c_str());
|
||||
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
|
||||
HW::Shutdown();
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str());
|
||||
|
||||
NOTICE_LOG(CONSOLE, "%s", StopMessage(true, "Main thread stopped").c_str());
|
||||
NOTICE_LOG(CONSOLE, "Stop [Main Thread]\t\t---- Shutdown complete ----");
|
||||
|
||||
g_bStopping = false;
|
||||
|
||||
Host_UpdateMainFrame();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -260,6 +260,7 @@ EVT_MENU_RANGE(IDM_FRAMESKIP0, IDM_FRAMESKIP9, CFrame::OnFrameSkip)
|
|||
EVT_MENU_RANGE(IDM_DRIVE1, IDM_DRIVE24, CFrame::OnBootDrive)
|
||||
|
||||
// Other
|
||||
EVT_ACTIVATE(CFrame::OnActive)
|
||||
EVT_CLOSE(CFrame::OnClose)
|
||||
EVT_SIZE(CFrame::OnResize)
|
||||
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, CFrame::OnGameListCtrl_ItemActivated)
|
||||
|
@ -493,6 +494,12 @@ void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
|
|||
|
||||
// --------
|
||||
// Events
|
||||
void CFrame::OnActive(wxActivateEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
if (event.GetActive())
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
void CFrame::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
|
|
|
@ -267,6 +267,7 @@ class CFrame : public wxFrame
|
|||
void OnPlayRecording(wxCommandEvent& event);
|
||||
void OnChangeDisc(wxCommandEvent& event);
|
||||
void OnScreenshot(wxCommandEvent& event);
|
||||
void OnActive(wxActivateEvent& event);
|
||||
void OnClose(wxCloseEvent &event);
|
||||
void OnLoadState(wxCommandEvent& event);
|
||||
void OnSaveState(wxCommandEvent& event);
|
||||
|
|
|
@ -807,8 +807,11 @@ void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED (event))
|
|||
|
||||
void CFrame::OnConnectWiimote(wxCommandEvent& event)
|
||||
{
|
||||
int Id = event.GetId() - IDM_CONNECT_WIIMOTE1;
|
||||
GetUsbPointer()->AccessWiiMote(Id | 0x100)->Activate(event.IsChecked());
|
||||
if (Core::isRunning() && Core::GetStartupParameter().bWii)
|
||||
{
|
||||
int Id = event.GetId() - IDM_CONNECT_WIIMOTE1;
|
||||
GetUsbPointer()->AccessWiiMote(Id | 0x100)->Activate(event.IsChecked());
|
||||
}
|
||||
}
|
||||
|
||||
// Toogle fullscreen. In Windows the fullscreen mode is accomplished by expanding the m_Panel to cover
|
||||
|
@ -949,23 +952,16 @@ void CFrame::UpdateGUI()
|
|||
if (DiscIO::CNANDContentManager::Access().GetNANDLoader(FULL_WII_MENU_DIR).IsValid())
|
||||
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(!Initialized);
|
||||
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Enable(Paused && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Enable(Paused && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Enable(Paused && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Enable(Paused && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Enable(Initialized && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Enable(Initialized && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Enable(Initialized && Core::GetStartupParameter().bWii);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Enable(Initialized && Core::GetStartupParameter().bWii);
|
||||
if (Initialized && Core::GetStartupParameter().bWii)
|
||||
{
|
||||
if (GetUsbPointer()->AccessWiiMote(0x0100) != NULL)
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Check(GetUsbPointer()->AccessWiiMote(0x0100)->IsConnected() == 3);
|
||||
|
||||
if (GetUsbPointer()->AccessWiiMote(0x0101) != NULL)
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Check(GetUsbPointer()->AccessWiiMote(0x0101)->IsConnected() == 3);
|
||||
|
||||
if (GetUsbPointer()->AccessWiiMote(0x0102) != NULL)
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Check(GetUsbPointer()->AccessWiiMote(0x0102)->IsConnected() == 3);
|
||||
|
||||
if (GetUsbPointer()->AccessWiiMote(0x0103) != NULL)
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Check(GetUsbPointer()->AccessWiiMote(0x0103)->IsConnected() == 3);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Check(GetUsbPointer()->AccessWiiMote(0x0100)->IsConnected() == 3);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Check(GetUsbPointer()->AccessWiiMote(0x0101)->IsConnected() == 3);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Check(GetUsbPointer()->AccessWiiMote(0x0102)->IsConnected() == 3);
|
||||
GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Check(GetUsbPointer()->AccessWiiMote(0x0103)->IsConnected() == 3);
|
||||
}
|
||||
|
||||
if (Running)
|
||||
|
|
|
@ -61,11 +61,32 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
|||
switch (LOWORD(wParam))
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
SendMessage(m_hWnd, WM_CLOSE, 0, 0);
|
||||
// Toggle full screen doesn't work yet
|
||||
/*
|
||||
if (g_ActiveConfig.bFullscreen)
|
||||
{
|
||||
// Pressing Esc switch to Windowed in Fullscreen mode
|
||||
ToggleFullscreen(hWnd);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// And stops the emulation when already in Windowed mode
|
||||
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
if (g_ActiveConfig.bFullscreen)
|
||||
{
|
||||
DestroyWindow(hWnd);
|
||||
PostQuitMessage(0);
|
||||
ExitProcess(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
||||
break;
|
||||
/*
|
||||
case WM_SYSKEYDOWN:
|
||||
switch( LOWORD( wParam ))
|
||||
{
|
||||
|
@ -75,64 +96,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
|||
DestroyWindow(hWnd);
|
||||
PostQuitMessage(0);
|
||||
ExitProcess(0);
|
||||
/* Get out of fullscreen
|
||||
g_Config.bFullscreen = false;
|
||||
|
||||
// FullScreen - > Desktop
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
|
||||
// Re-Enable the cursor
|
||||
ShowCursor(TRUE);
|
||||
|
||||
RECT rcdesktop;
|
||||
RECT rc = {0, 0, 640, 480};
|
||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
|
||||
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
||||
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
||||
// SetWindowPos to the center of the screen
|
||||
SetWindowPos(hWnd, NULL, X, Y, 640, 480, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||
|
||||
// Set new window style FS -> Windowed
|
||||
SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||
|
||||
// Eventually show the window!
|
||||
EmuWindow::Show();*/
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
// Get into fullscreen
|
||||
g_Config.bFullscreen = true;
|
||||
DEVMODE dmScreenSettings;
|
||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||
RECT rcdesktop;
|
||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
|
||||
// Desktop -> FullScreen
|
||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||
dmScreenSettings.dmPelsWidth = rcdesktop.right;
|
||||
dmScreenSettings.dmPelsHeight = rcdesktop.bottom;
|
||||
dmScreenSettings.dmBitsPerPel = 32;
|
||||
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
|
||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||
return 0;
|
||||
// Disable the cursor
|
||||
ShowCursor(FALSE);
|
||||
|
||||
// SetWindowPos to the upper-left corner of the screen
|
||||
SetWindowPos(hWnd, NULL, 0, 0, rcdesktop.right, rcdesktop.bottom, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||
|
||||
// Set new window style -> PopUp
|
||||
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
|
||||
|
||||
// Eventually show the window!
|
||||
EmuWindow::Show();
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
//g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
|
||||
break;
|
||||
*/
|
||||
|
||||
/* Post thes mouse events to the main window, it's nessesary because in difference to the
|
||||
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
|
||||
|
@ -145,7 +114,6 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
|||
case WM_CLOSE:
|
||||
Fifo_ExitLoopNonBlocking();
|
||||
//Shutdown();
|
||||
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
|
||||
// Simple hack to easily exit without stopping. Hope to fix the stopping errors soon.
|
||||
//ExitProcess(0);
|
||||
return 0;
|
||||
|
@ -270,4 +238,67 @@ void SetSize(int width, int height)
|
|||
::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
|
||||
}
|
||||
|
||||
void ToggleFullscreen(HWND hParent)
|
||||
{
|
||||
if (m_hParent == NULL)
|
||||
{
|
||||
int w_fs = 640, h_fs = 480;
|
||||
if (g_Config.bFullscreen)
|
||||
{
|
||||
//Get out of fullscreen
|
||||
g_ActiveConfig.bFullscreen = false;
|
||||
|
||||
// FullScreen - > Desktop
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
|
||||
// Re-Enable the cursor
|
||||
ShowCursor(TRUE);
|
||||
|
||||
RECT rcdesktop;
|
||||
RECT rc = {0, 0, 640, 480};
|
||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
|
||||
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
|
||||
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
||||
// SetWindowPos to the center of the screen
|
||||
SetWindowPos(hParent, NULL, X, Y, 640, 480, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||
|
||||
// Set new window style FS -> Windowed
|
||||
SetWindowLong(hParent, GWL_STYLE, WS_OVERLAPPEDWINDOW);
|
||||
|
||||
// Eventually show the window!
|
||||
EmuWindow::Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get into fullscreen
|
||||
g_ActiveConfig.bFullscreen = true;
|
||||
DEVMODE dmScreenSettings;
|
||||
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
|
||||
RECT rcdesktop;
|
||||
GetWindowRect(GetDesktopWindow(), &rcdesktop);
|
||||
|
||||
// Desktop -> FullScreen
|
||||
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
|
||||
dmScreenSettings.dmPelsWidth = rcdesktop.right;
|
||||
dmScreenSettings.dmPelsHeight = rcdesktop.bottom;
|
||||
dmScreenSettings.dmBitsPerPel = 32;
|
||||
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
|
||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
|
||||
return ;
|
||||
// Disable the cursor
|
||||
ShowCursor(FALSE);
|
||||
|
||||
// SetWindowPos to the upper-left corner of the screen
|
||||
SetWindowPos(hParent, NULL, 0, 0, rcdesktop.right, rcdesktop.bottom, SWP_NOREPOSITION | SWP_NOZORDER);
|
||||
|
||||
// Set new window style -> PopUp
|
||||
SetWindowLong(hParent, GWL_STYLE, WS_POPUP);
|
||||
|
||||
// Eventually show the window!
|
||||
EmuWindow::Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title);
|
|||
void Show();
|
||||
void Close();
|
||||
void SetSize(int displayWidth, int displayHeight);
|
||||
void ToggleFullscreen(HWND hParent);
|
||||
bool IsSizing();
|
||||
|
||||
}
|
||||
|
|
|
@ -165,6 +165,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
|
|||
{
|
||||
// And stops the emulation when already in Windowed mode
|
||||
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue