diff --git a/src/common/win32/EmuShared.cpp b/src/common/win32/EmuShared.cpp index cca37b254..0f6dd5b4a 100644 --- a/src/common/win32/EmuShared.cpp +++ b/src/common/win32/EmuShared.cpp @@ -152,9 +152,9 @@ EmuShared::EmuShared() m_bDebugging = false; m_bEmulating_status = false; m_bFirstLaunch = false; + m_bClipCursor = false; // Reserve space (default to 0) - m_bReserved2 = false; m_bReserved3 = false; m_bReserved4 = false; m_Reserved5 = 0; diff --git a/src/common/win32/EmuShared.h b/src/common/win32/EmuShared.h index f00fb99e2..dcad678a2 100644 --- a/src/common/win32/EmuShared.h +++ b/src/common/win32/EmuShared.h @@ -244,6 +244,12 @@ class EmuShared : public Mutex void GetStorageLocation(char *path) { Lock(); strncpy(path, m_core.szStorageLocation, MAX_PATH); Unlock(); } void SetStorageLocation(const char *path) { Lock(); strncpy(m_core.szStorageLocation, path, MAX_PATH); Unlock(); } + // ****************************************************************** + // * ClipCursor flag Accessors + // ****************************************************************** + void GetClipCursorFlag(bool *value) { Lock(); *value = m_bClipCursor; Unlock(); } + void SetClipCursorFlag(const bool *value) { Lock(); m_bClipCursor = *value; Unlock(); } + // ****************************************************************** // * Reset specific variables to default for kernel mode. // ****************************************************************** @@ -292,7 +298,7 @@ class EmuShared : public Mutex int m_Reserved7[4]; #endif bool m_bFirstLaunch; - bool m_bReserved2; + bool m_bClipCursor; bool m_bReserved3; bool m_bReserved4; unsigned int m_dwKrnlProcID; // Only used for kernel mode level. diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index d193ccd4d..27a1a3bd2 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -1856,6 +1856,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar { case WM_DESTROY: { + CxbxReleaseCursor(); DeleteObject(g_hBgBrush); PostQuitMessage(0); return D3D_OK; // = 0 @@ -1943,6 +1944,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar else if (wParam == VK_F3) { g_bClipCursor = !g_bClipCursor; + g_EmuShared->SetClipCursorFlag(&g_bClipCursor); if (g_bClipCursor) { CxbxClipCursor(hWnd); @@ -2037,6 +2039,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar break; case WM_CLOSE: + CxbxReleaseCursor(); DestroyWindow(hWnd); CxbxKrnlShutDown(); break; diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index d8debf2a9..0312491c3 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -681,6 +681,9 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res //g_EmuShared->SetIsReady(true); } + /* Initialize ClipCursor flag from EmuShared */ + g_EmuShared->GetClipCursorFlag(&g_bClipCursor); + /* Initialize popup message management from kernel side. */ log_init_popup_msg();