Commit c93813e1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Call device read_callback while holding the internal CS.

And remove the device from the list of acquired devices if the callback indicates a read error. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent bbb68aea
......@@ -1289,11 +1289,11 @@ static LRESULT CALLBACK callwndproc_proc( int code, WPARAM wparam, LPARAM lparam
static DWORD WINAPI hook_thread_proc(void *param)
{
static HHOOK kbd_hook, mouse_hook;
IDirectInputDeviceImpl *impl;
IDirectInputDevice8W *iface;
IDirectInputDeviceImpl *impl, *next;
SIZE_T events_count = 0;
HANDLE finished_event;
HANDLE events[128];
HRESULT hr;
DWORD ret;
MSG msg;
......@@ -1310,24 +1310,17 @@ static DWORD WINAPI hook_thread_proc(void *param)
if (ret < events_count)
{
iface = NULL;
EnterCriticalSection( &dinput_hook_crit );
LIST_FOR_EACH_ENTRY( impl, &acquired_device_list, IDirectInputDeviceImpl, entry )
LIST_FOR_EACH_ENTRY_SAFE( impl, next, &acquired_device_list, IDirectInputDeviceImpl, entry )
{
if (impl->read_event == events[ret])
{
iface = &impl->IDirectInputDevice8W_iface;
IDirectInputDevice8_AddRef( iface );
hr = impl->read_callback( &impl->IDirectInputDevice8W_iface );
if (FAILED(hr)) list_remove( &impl->entry );
break;
}
}
LeaveCriticalSection( &dinput_hook_crit );
if (iface)
{
impl->read_callback( iface );
IDirectInputDevice8_Release( iface );
}
}
while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment