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>
This commit is contained in:
parent
da998cb206
commit
890d1b812a
|
@ -1719,7 +1719,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
|
|||
|
||||
/* Force creation of the message queue */
|
||||
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
|
||||
SetEvent(*(LPHANDLE)param);
|
||||
SetEvent(param);
|
||||
|
||||
while (GetMessageW( &msg, 0, 0, 0 ))
|
||||
{
|
||||
|
@ -1785,6 +1785,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
|
|||
}
|
||||
|
||||
static DWORD hook_thread_id;
|
||||
static HANDLE hook_thread_event;
|
||||
|
||||
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));
|
||||
if (!list_empty(&direct_input_list) && !hook_thread)
|
||||
{
|
||||
HANDLE event;
|
||||
|
||||
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);
|
||||
}
|
||||
hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||
hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id);
|
||||
LeaveCriticalSection(&dinput_hook_crit);
|
||||
CloseHandle(event);
|
||||
}
|
||||
else if (list_empty(&direct_input_list) && hook_thread)
|
||||
{
|
||||
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;
|
||||
PostThreadMessageW(tid, WM_USER+0x10, 0, 0);
|
||||
LeaveCriticalSection(&dinput_hook_crit);
|
||||
|
@ -1861,6 +1859,13 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
|
|||
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 );
|
||||
|
||||
LeaveCriticalSection(&dinput_hook_crit);
|
||||
|
|
Loading…
Reference in New Issue