forked from Mirrors/wine-wine
dinput: Do not wait for hook thread startup in IDirectInput8::Initialize.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=21403
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 890d1b812a
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
parent
346b743bc1
commit
6eb596c5e8
|
@ -1719,7 +1719,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
|
||||||
|
|
||||||
/* Force creation of the message queue */
|
/* Force creation of the message queue */
|
||||||
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
|
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
|
||||||
SetEvent(*(LPHANDLE)param);
|
SetEvent(param);
|
||||||
|
|
||||||
while (GetMessageW( &msg, 0, 0, 0 ))
|
while (GetMessageW( &msg, 0, 0, 0 ))
|
||||||
{
|
{
|
||||||
|
@ -1785,6 +1785,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD hook_thread_id;
|
static DWORD hook_thread_id;
|
||||||
|
static HANDLE hook_thread_event;
|
||||||
|
|
||||||
static CRITICAL_SECTION_DEBUG dinput_critsect_debug =
|
static CRITICAL_SECTION_DEBUG dinput_critsect_debug =
|
||||||
{
|
{
|
||||||
|
@ -1803,24 +1804,21 @@ static BOOL check_hook_thread(void)
|
||||||
TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list));
|
TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list));
|
||||||
if (!list_empty(&direct_input_list) && !hook_thread)
|
if (!list_empty(&direct_input_list) && !hook_thread)
|
||||||
{
|
{
|
||||||
HANDLE event;
|
hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||||
|
hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id);
|
||||||
event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
||||||
hook_thread = CreateThread(NULL, 0, hook_thread_proc, &event, 0, &hook_thread_id);
|
|
||||||
if (event && hook_thread)
|
|
||||||
{
|
|
||||||
HANDLE handles[2];
|
|
||||||
handles[0] = event;
|
|
||||||
handles[1] = hook_thread;
|
|
||||||
WaitForMultipleObjects(2, handles, FALSE, INFINITE);
|
|
||||||
}
|
|
||||||
LeaveCriticalSection(&dinput_hook_crit);
|
LeaveCriticalSection(&dinput_hook_crit);
|
||||||
CloseHandle(event);
|
|
||||||
}
|
}
|
||||||
else if (list_empty(&direct_input_list) && hook_thread)
|
else if (list_empty(&direct_input_list) && hook_thread)
|
||||||
{
|
{
|
||||||
DWORD tid = hook_thread_id;
|
DWORD tid = hook_thread_id;
|
||||||
|
|
||||||
|
if (hook_thread_event) /* if thread is not started yet */
|
||||||
|
{
|
||||||
|
WaitForSingleObject(hook_thread_event, INFINITE);
|
||||||
|
CloseHandle(hook_thread_event);
|
||||||
|
hook_thread_event = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
hook_thread_id = 0;
|
hook_thread_id = 0;
|
||||||
PostThreadMessageW(tid, WM_USER+0x10, 0, 0);
|
PostThreadMessageW(tid, WM_USER+0x10, 0, 0);
|
||||||
LeaveCriticalSection(&dinput_hook_crit);
|
LeaveCriticalSection(&dinput_hook_crit);
|
||||||
|
@ -1861,6 +1859,13 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
|
||||||
callwndproc_hook = NULL;
|
callwndproc_hook = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hook_thread_event) /* if thread is not started yet */
|
||||||
|
{
|
||||||
|
WaitForSingleObject(hook_thread_event, INFINITE);
|
||||||
|
CloseHandle(hook_thread_event);
|
||||||
|
hook_thread_event = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 );
|
PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 );
|
||||||
|
|
||||||
LeaveCriticalSection(&dinput_hook_crit);
|
LeaveCriticalSection(&dinput_hook_crit);
|
||||||
|
|
Loading…
Reference in New Issue