LilyPad: GSDX10 + fullscreen + escape workaround that's lamer than the last one, but seems to work much better and should cause no issues with GSDX+DX9, other than a slight delay.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@722 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
mattmenke 2009-03-09 04:22:37 +00:00
parent 120971ec4f
commit 0c9abd6765
4 changed files with 62 additions and 63 deletions

View File

@ -703,6 +703,17 @@ ExtraWndProcResult HideCursorProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
return CONTINUE_BLISSFULLY_AND_RELEASE_PROC;
}
char restoreFullScreen = 0;
DWORD WINAPI MaximizeWindowThreadProc(void *lpParameter) {
Sleep(100);
keybd_event(VK_LMENU, MapVirtualKey(VK_LMENU, MAPVK_VK_TO_VSC), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC), 0, 0);
Sleep(10);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(VK_LMENU, MapVirtualKey(VK_LMENU, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
return 0;
}
s32 CALLBACK PADopen(void *pDsp) {
if (openCount++) return 0;
@ -733,6 +744,13 @@ s32 CALLBACK PADopen(void *pDsp) {
}
}
if (restoreFullScreen) {
if (!IsWindowMaximized(hWnd)) {
HANDLE hThread = CreateThread(0, 0, MaximizeWindowThreadProc, hWnd, 0, 0);
if (hThread) CloseHandle(hThread);
}
restoreFullScreen = 0;
}
memset(&pads[0].sum, 0, sizeof(pads[0].sum));
memset(&pads[0].lockedSum, 0, sizeof(pads[0].lockedSum));
pads[0].lockedState = 0;
@ -1059,21 +1077,7 @@ void CALLBACK PADabout() {
s32 CALLBACK PADtest() {
return 0;
}
// For escape fullscreen hack. This doesn't work when called from another thread, for some reason.
// That includes a new thread, independent of GS and PCSX2 thread, so use this to make sure it's
// called from the right spot.
ExtraWndProcResult KillFullScreenProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) {
// Prevent infinite recursion. Could also just remove this function from the list,
// but CONTINUE_BLISSFULLY_AND_RELEASE_PROC is a safer way to do that.
static int inFunction = 0;
if (!inFunction) {
inFunction = 1;
ShowWindow(hWnd, 0);
inFunction = 0;
}
return CONTINUE_BLISSFULLY_AND_RELEASE_PROC;
}
#include <time.h>
DWORD WINAPI RenameWindowThreadProc(void *lpParameter) {
wchar_t newTitle[200];
@ -1088,52 +1092,48 @@ DWORD WINAPI RenameWindowThreadProc(void *lpParameter) {
return 0;
}
/*DWORD WINAPI MaximizeWindowThreadProc(void *lpParameter) {
while ((HWND)lpParameter == hWnd || hWnd) {
Sleep(10);
// For escape fullscreen hack. This doesn't work when called from another thread, for some reason.
// That includes a new thread, independent of GS and PCSX2 thread, so use this to make sure it's
// called from the right spot.
ExtraWndProcResult KillFullScreenProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *output) {
// Prevent infinite recursion. Could also just remove this function from the list,
// but CONTINUE_BLISSFULLY_AND_RELEASE_PROC is a safer way to do that.
static int inFunction = 0;
if (!inFunction) {
inFunction = 1;
ShowWindow(hWnd, SW_MINIMIZE);
inFunction = 0;
}
Sleep(100);
keybd_event(VK_LMENU, MapVirtualKey(VK_LMENU, MAPVK_VK_TO_VSC), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC), 0, 0);
Sleep(10);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
keybd_event(VK_LMENU, MapVirtualKey(VK_LMENU, MAPVK_VK_TO_VSC), KEYEVENTF_KEYUP, 0);
return 0;
}//*/
return CONTINUE_BLISSFULLY_AND_RELEASE_PROC;
}
keyEvent* CALLBACK PADkeyEvent() {
if (!config.GSThreadUpdates) {
Update(2);
}
static int shiftDown = 0;
static char shiftDown = 0;
static keyEvent ev;
if (!GetQueuedKeyEvent(&ev)) return 0;
if ((ev.key == VK_ESCAPE || ev.key == -2) && ev.evt == KEYPRESS && config.escapeFullscreenHack) {
if (IsWindowMaximized(hWnd)) {
if ((ev.key == VK_ESCAPE || (int)ev.key == -2) && ev.evt == KEYPRESS && config.escapeFullscreenHack) {
static int t;
if ((int)ev.key != -2 && IsWindowMaximized(hWnd)) {
t = timeGetTime();
QueueKeyEvent(-2, KEYPRESS);
if (ev.key != -2)
EatWndProc(hWnd, KillFullScreenProc);
HANDLE hThread = CreateThread(0, 0, MaximizeWindowThreadProc, 0, 0, 0);
if (hThread) CloseHandle(hThread);
//ShowWindowAsync(hWnd, SW_HIDE);
restoreFullScreen = 1;
return 0;
}
if (ev.key != VK_ESCAPE) {
if (timeGetTime() - t < 1000) {
QueueKeyEvent(-2, KEYPRESS);
return 0;
}
}
ev.key = VK_ESCAPE;
}
/*
if ((ev.key == VK_F9 || ev.key == -1) && ev.evt == KEYPRESS) {
if (IsWindowMaximized(hWnd)) {
QueueKeyEvent(-1, KEYPRESS);
if (ev.key == VK_F9)
EatWndProc(hWnd, KillFullScreenProc);
return 0;
}
return 0;
if (ev.key == -1) {
HANDLE hThread = CreateThread(0, 0, MaximizeWindowThreadProc, hWnd, 0, 0);
if (hThread) CloseHandle(hThread);
}
ev.key = VK_F9;
}//*/
if (ev.key == VK_F2 && ev.evt == KEYPRESS) {
saveStateIndex += 1 - 2*shiftDown;
saveStateIndex = (saveStateIndex+10)%10;

View File

@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// TEXTINCLUDE
//
1 TEXTINCLUDE
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
2 TEXTINCLUDE
BEGIN
"#include <winres.h>\r\n"
"\0"
END
3 TEXTINCLUDE
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
@ -264,14 +264,13 @@ BEGIN
GROUPBOX "Hacks",IDC_STATIC,216,211,201,73
CONTROL "Send escape on window close",IDC_CLOSE_HACK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,223,113,10
CONTROL "Exit emulator on window close",IDC_CLOSE_HACK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,235,112,10
CONTROL "Safe fullscreen exit on escape\n(Doesn't like GSDX with DX9)",IDC_ESCAPE_FULLSCREEN_HACK,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,224,247,110,18
CONTROL "Use GS thread\n(Recommended)",IDC_GS_THREAD_INPUT,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,224,265,107,16
CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,223,80,10
CONTROL "Always hide cursor",IDC_FORCE_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,235,71,10
CONTROL "Save state # in title",IDC_SAVE_STATE_TITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,247,79,10
CONTROL "Guitar Hero 2 Hack",IDC_GH2_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,259,76,10
CONTROL "Disable screensaver",IDC_DISABLE_SCREENSAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,247,80,10
CONTROL "Safe fullscreen exit on escape (For GSDX+DX10)",IDC_ESCAPE_FULLSCREEN_HACK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,259,171,10
CONTROL "Use GS thread (Recommended)",IDC_GS_THREAD_INPUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,224,271,116,10
CONTROL "Always hide cursor",IDC_FORCE_HIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,223,71,10
CONTROL "Save state # in title",IDC_SAVE_STATE_TITLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,235,79,10
CONTROL "Guitar Hero 2 Hack",IDC_GH2_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,336,247,76,10
GROUPBOX "Debugging",IDC_STATIC,216,285,79,25
CONTROL "Enable logging",IDC_DEBUG_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,223,296,63,10
PUSHBUTTON "Load",ID_LOAD,313,295,48,15
@ -303,7 +302,7 @@ END
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
GUIDELINES DESIGNINFO
BEGIN
IDD_CONFIG, DIALOG
BEGIN

View File

@ -78,7 +78,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
AdditionalDependencies="Winmm.lib setupapi.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateManifest="false"
@ -275,7 +275,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ntdll.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
AdditionalDependencies="Winmm.lib ntdll.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateManifest="false"

View File

@ -72,7 +72,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="setupapi.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
AdditionalDependencies="Winmm.lib setupapi.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
OutputFile="$(OutDir)\$(ProjectName)-dbg.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
@ -167,7 +167,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
AdditionalDependencies="Winmm.lib ole32.lib advapi32.lib user32.lib kernel32.lib Comdlg32.lib dinput8.lib dxguid.lib comctl32.lib"
LinkIncremental="1"
SuppressStartupBanner="true"
ModuleDefinitionFile=".\LilyPad.def"