dinput/tests: Make overlapped format tests more robust.
commit5cb70e73f070def227f47bb307c1d5a483fc898c
authorArkadiusz Hiler <ahiler@codeweavers.com>
Thu, 5 Aug 2021 10:55:29 +0000 (5 13:55 +0300)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 5 Aug 2021 18:43:28 +0000 (5 20:43 +0200)
tree1ed92166269bcd313669924686bc2ca6f83c4c12
parenta439f7202a9c8f06deb43f81d0f8704caf408162
dinput/tests: Make overlapped format tests more robust.

Both Acquire() and event processing with DirectInput seem to be
asynchronous. In most cases we can just keep hammering GetDeviceData()
until the event gets processed.

Things get pretty racy around Acquire() though. If we fire event right
after the device is acquired we can find ourselves in one of the three
situations:

1. Event happened after acquiring has completed - the wait will suffice.

2. Event happened before acquiring did any real work - the device will
   pick up the state as if the event was processed, but there's nothing
   in GetDeviceData(). Because of that we cannot fail on wait.

3. Event happened somewhere in the middle of acquiring - we ended up
   both missing the event for GetDeviceData() and we have outdated
   state. Sending event again will register as if the button was not
   already pressed.

This change covers all three scenarios.

Signed-off-by: Arkadiusz Hiler <ahiler@codeweavers.com>
Signed-off-by: RĂ©mi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
dlls/dinput/tests/device.c