1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

block all keys except Esc while a dvd video is playing

This commit is contained in:
FunkyFr3sh 2023-10-16 02:08:38 +02:00
parent b63410c444
commit 4d7fc88d37
6 changed files with 18 additions and 3 deletions

View File

@ -136,6 +136,7 @@ typedef struct CNCDDRAW
void* last_freed_palette; /* Dungeon Keeper hack */
void* last_freed_surface; /* Nox hack */
BOOL child_window_exists;
BOOL video_window_exists;
BOOL got_child_windows;
DWORD last_set_window_pos_tick; /* WINE hack */
SPEEDLIMITER ticks_limiter;

View File

@ -540,7 +540,7 @@ DWORD WINAPI d3d9_render_main(void)
if (g_config.fixchilds)
{
g_ddraw->child_window_exists = FALSE;
g_ddraw->child_window_exists = g_ddraw->video_window_exists = FALSE;
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)

View File

@ -83,7 +83,7 @@ DWORD WINAPI gdi_render_main(void)
if (g_config.fixchilds)
{
g_ddraw->child_window_exists = FALSE;
g_ddraw->child_window_exists = g_ddraw->video_window_exists = FALSE;
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
}

View File

@ -769,7 +769,7 @@ static void ogl_render()
if (g_config.fixchilds)
{
g_ddraw->child_window_exists = FALSE;
g_ddraw->child_window_exists = g_ddraw->video_window_exists = FALSE;
EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary);
if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height)

View File

@ -476,6 +476,8 @@ BOOL CALLBACK util_enum_child_proc(HWND hwnd, LPARAM lparam)
strcmp(class_name, "Afx:400000:3") == 0 ||
strcmp(class_name, "MCIWndClass") == 0)
{
g_ddraw->video_window_exists = TRUE;
LONG style = real_GetWindowLongA(hwnd, GWL_EXSTYLE);
if (!(style & WS_EX_TRANSPARENT))

View File

@ -709,6 +709,12 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
}
case WM_KEYDOWN:
{
if (g_ddraw->video_window_exists)
{
if (wParam != VK_ESCAPE)
return 0;
}
if (g_config.hotkeys.unlock_cursor1 &&
(wParam == VK_CONTROL || wParam == g_config.hotkeys.unlock_cursor1))
{
@ -733,6 +739,12 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
}
case WM_KEYUP:
{
if (g_ddraw->video_window_exists)
{
if (wParam != VK_ESCAPE)
return 0;
}
if (g_config.hotkeys.screenshot && wParam == g_config.hotkeys.screenshot)
ss_take_screenshot(g_ddraw->primary);