diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index c414e440ac..73d4387cb5 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -18,6 +18,7 @@ #include "Core/Core.h" #include "Core/Config.h" #include "Core/CoreParameter.h" +#include "Core/System.h" #include "EmuThread.h" #include "DSoundStream.h" #include "WindowsHost.h" @@ -127,6 +128,7 @@ void WindowsHost::SetDebugMode(bool mode) disasmWindow[i]->SetDebugMode(mode); } +extern BOOL g_bFullScreen; void WindowsHost::PollControllers(InputState &input_state) { diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index e35320d38a..5a52b35c60 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -42,11 +42,12 @@ #define ENABLE_TOUCH 0 -static BOOL g_bFullScreen = FALSE; +BOOL g_bFullScreen = FALSE; static RECT g_normalRC = {0}; extern InputState input_state; - +#define TIMER_CURSORUPDATE 1 +#define CURSORUPDATE_INTERVAL_MS 500 extern unsigned short analog_ctrl_map[]; extern unsigned int key_pad_map[]; extern const char * getVirtualKeyName(unsigned char key); @@ -200,6 +201,7 @@ namespace MainWindow hwndMain = CreateWindowEx(0,szWindowClass, "", style, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, NULL, NULL, hInstance, NULL); + SetTimer(hwndMain, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); SetPlaying(0); if (!hwndMain) return FALSE; @@ -233,6 +235,7 @@ namespace MainWindow #endif SetFocus(hwndMain); + SetFocus(hwndDisplay); return TRUE; } @@ -388,6 +391,18 @@ namespace MainWindow ResizeDisplay(); break; + case WM_TIMER: + // Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode. + if (g_bFullScreen && globalUIState == UISTATE_INGAME) { + ShowCursor(FALSE); + SetCursor(0); + } else { + ShowCursor(TRUE); + SetCursor(LoadCursor(NULL, IDC_ARROW)); + } + SetTimer(hWnd, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); + return 0; + case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); @@ -1112,7 +1127,7 @@ namespace MainWindow { ShowCursor(TRUE); SetCursor(LoadCursor(NULL, IDC_ARROW)); - ClipCursor(NULL); + // put caption and border styles back DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME; @@ -1138,7 +1153,7 @@ namespace MainWindow { ShowCursor(FALSE); SetCursor(NULL); - ClipCursor(&g_normalRC); + // keep in mind normal window rectangle ::GetWindowRect(hWnd, &g_normalRC);