From 6abe98b2f9099d106f37c064a00342e4afb20fb7 Mon Sep 17 00:00:00 2001 From: 00C0FFEE <49476850+00C0FFEE@users.noreply.github.com> Date: Tue, 30 Apr 2019 11:25:36 +0200 Subject: [PATCH] Update FordRacing.cpp --- .../Functions/Games/Europa-R/FordRacing.cpp | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/OpenParrot/src/Functions/Games/Europa-R/FordRacing.cpp b/OpenParrot/src/Functions/Games/Europa-R/FordRacing.cpp index c5b4352..1b1ab96 100644 --- a/OpenParrot/src/Functions/Games/Europa-R/FordRacing.cpp +++ b/OpenParrot/src/Functions/Games/Europa-R/FordRacing.cpp @@ -2,6 +2,8 @@ #include "Utility/InitFunction.h" #include "Functions/Global.h" #if _M_IX86 + + signed int FordRacingControlInit() { // start input thread @@ -32,6 +34,44 @@ int __stdcall FordRacingFfbFunc(DWORD device, DWORD data) return 0; } +HWND hWndFORD; + +BOOL(__stdcall *g_origDefWindowProcA)(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +DWORD WINAPI DefWindowProcAFord(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + hWndFORD = hWnd; + return g_origDefWindowProcA(hWnd, message, wParam, lParam); +} + +DWORD WINAPI FordFocus(LPVOID lpParam) +{ + while (true) + { + POINT point; + // LEFT-CLICK MOVES WINDOW FROM TOP-LEFT CORNER + if (GetAsyncKeyState(VK_LBUTTON) & 0x8000) + { + SetWindowPos(hWndFORD, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + GetCursorPos(&point); + LPARAM blah = MAKELPARAM(point.x, point.y); + int xClick = LOWORD(blah); + int yClick = HIWORD(blah); + SetWindowPos(hWndFORD, HWND_TOPMOST, xClick, yClick, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + } + // RIGHT-CLICK MINIMIZES WINDOW + if (GetAsyncKeyState(VK_RBUTTON) & 0x8000) + { + ShowWindow(hWndFORD, SW_MINIMIZE); + } + // ESCAPE QUITS GAME + if (0 != GetAsyncKeyState(VK_ESCAPE)) + { + exit(0); + } + + } +} + static InitFunction fordRacingFunc([]() { @@ -52,8 +92,17 @@ static InitFunction fordRacingFunc([]() if (ToBool(config["General"]["Windowed"])) { // TODO: fix mouse to work without alt-tab, make window moveable + // NOW FIXED: left-click and drag to move window , right-click to minimize window , ESC to close injector::MakeNOP(0x466A70 + 0x1BB, 5); + injector::WriteMemory(0x4B3E61, 0x01, true); + injector::WriteMemory(0x4B3F35, 0xEB, true); + + CreateThread(NULL, 0, FordFocus, NULL, 0, NULL); + + MH_Initialize(); + MH_CreateHookApi(L"user32.dll", "DefWindowProcA", &DefWindowProcAFord, (void**)&g_origDefWindowProcA); + MH_EnableHook(MH_ALL_HOOKS); } }, GameID::FordRacing); -#endif \ No newline at end of file +#endif