1
0
mirror of synced 2024-11-15 07:17:35 +01:00

Update FordRacing.cpp

This commit is contained in:
00C0FFEE 2019-04-30 11:25:36 +02:00 committed by GitHub
parent 3a0a066067
commit 6abe98b2f9

View File

@ -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<BYTE>(0x4B3E61, 0x01, true);
injector::WriteMemory<BYTE>(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
#endif