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

dinput: Start and cancel reading HID reports while holding the CS.

parent a382646e
......@@ -699,14 +699,18 @@ static HRESULT WINAPI hid_joystick_Acquire( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
if ((hr = IDirectInputDevice2WImpl_Acquire( iface )) != DI_OK) return hr;
memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
impl->read_ovl.hEvent = impl->base.read_event;
if (ReadFile( impl->device, impl->input_report_buf, report_len, NULL, &impl->read_ovl ))
impl->base.read_callback( iface );
EnterCriticalSection( &impl->base.crit );
hr = IDirectInputDevice2WImpl_Acquire( iface );
if (hr == DI_OK)
{
memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
impl->read_ovl.hEvent = impl->base.read_event;
if (ReadFile( impl->device, impl->input_report_buf, report_len, NULL, &impl->read_ovl ))
impl->base.read_callback( iface );
}
LeaveCriticalSection( &impl->base.crit );
return DI_OK;
return hr;
}
static HRESULT WINAPI hid_joystick_Unacquire( IDirectInputDevice8W *iface )
......@@ -717,12 +721,16 @@ static HRESULT WINAPI hid_joystick_Unacquire( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
if ((hr = IDirectInputDevice2WImpl_Unacquire( iface )) != DI_OK) return hr;
ret = CancelIoEx( impl->device, &impl->read_ovl );
if (!ret) WARN( "CancelIoEx failed, last error %u\n", GetLastError() );
EnterCriticalSection( &impl->base.crit );
if (impl->base.acquired)
{
ret = CancelIoEx( impl->device, &impl->read_ovl );
if (!ret) WARN( "CancelIoEx failed, last error %u\n", GetLastError() );
}
hr = IDirectInputDevice2WImpl_Unacquire( iface );
LeaveCriticalSection( &impl->base.crit );
return DI_OK;
return hr;
}
static HRESULT WINAPI hid_joystick_GetDeviceState( IDirectInputDevice8W *iface, DWORD len, void *ptr )
......
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