USB: Pass a top-level window to DirectInput

Fixes Force Feedback not initializing properly
This commit is contained in:
Silent 2020-12-24 12:29:09 +01:00 committed by jackun
parent fa18568d62
commit 2465b0e278
2 changed files with 5 additions and 11 deletions

View File

@ -1077,9 +1077,7 @@ s32 PADopen(void* pDsp)
"Non-PAD Error", MB_OK | MB_ICONERROR);
return -1;
}
hWndTop = hWnd;
while (GetWindowLong(hWndTop, GWL_STYLE) & WS_CHILD)
hWndTop = GetParent(hWndTop);
hWndTop = GetAncestor(hWnd, GA_ROOT);
if (!hWndGSProc.SetWndHandle(hWnd))
{

View File

@ -46,7 +46,6 @@ namespace usb_pad
static std::atomic<int> refCount(0);
static bool useRamp = false;
HWND hWin = NULL;
DWORD pid = 0;
DWORD old = 0;
@ -903,12 +902,6 @@ namespace usb_pad
return NULL;
}
void GetID(TCHAR* name)
{
hWin = ::FindWindow(name, NULL);
::GetWindowThreadProcessId(hWin, &pid);
}
bool FindFFDevice(int port)
{
InputMapped im;
@ -942,6 +935,8 @@ namespace usb_pad
//use direct input
void InitDI(int port, const char* dev_type)
{
HWND hWin = nullptr;
if (gsWnd)
{
hWin = gsWnd;
@ -955,7 +950,8 @@ namespace usb_pad
}
}
InitDirectInput(hWin, port);
// DirectInput needs a top-level window
InitDirectInput(GetAncestor(hWin, GA_ROOT), port);
LoadDInputConfig(port, dev_type);
FindFFDevice(port);
}