dinput: Hold the HID joystick CS when updating the device state.

The read buffer is only used by the reading thread but the device state
is not, we should only update it while holding the CS.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-10-08 15:36:00 +02:00 committed by Alexandre Julliard
parent 1014cfcff8
commit 2b61d8dd97
1 changed files with 2 additions and 0 deletions

View File

@ -1603,6 +1603,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface )
}
}
EnterCriticalSection( &impl->base.crit );
do
{
count = impl->usages_count;
@ -1638,6 +1639,7 @@ static HRESULT hid_joystick_read_state( IDirectInputDevice8W *iface )
memset( &impl->read_ovl, 0, sizeof(impl->read_ovl) );
impl->read_ovl.hEvent = impl->base.read_event;
} while (ReadFile( impl->device, report_buf, report_len, &count, &impl->read_ovl ));
LeaveCriticalSection( &impl->base.crit );
return DI_OK;
}