Instead of message notifications only. We have to remove the events from devices that are automatically unacquired whenever a read failed. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/dinput/dinput_main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 5226a07e500..cd40eabb373 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -1311,16 +1311,9 @@ static DWORD WINAPI dinput_thread_proc( void *params ) goto done; } - events_count = 0; EnterCriticalSection( &dinput_hook_crit ); kbd_cnt = list_count( &acquired_keyboard_list ); mice_cnt = list_count( &acquired_mouse_list ); - LIST_FOR_EACH_ENTRY( impl, &acquired_device_list, struct dinput_device, entry ) - { - if (!impl->read_event || !impl->vtbl->read) continue; - if (events_count >= ARRAY_SIZE(events)) break; - events[events_count++] = impl->read_event; - } LeaveCriticalSection( &dinput_hook_crit ); if (kbd_cnt && !kbd_hook) @@ -1341,8 +1334,20 @@ static DWORD WINAPI dinput_thread_proc( void *params ) SetEvent(finished_event); } + + events_count = 0; + EnterCriticalSection( &dinput_hook_crit ); + LIST_FOR_EACH_ENTRY( impl, &acquired_device_list, struct dinput_device, entry ) + { + if (!impl->read_event || !impl->vtbl->read) continue; + if (events_count >= ARRAY_SIZE(events)) break; + events[events_count++] = impl->read_event; + } + LeaveCriticalSection( &dinput_hook_crit ); } + if (ret != events_count) ERR("Unexpected termination, ret %#x\n", ret); + done: DestroyWindow( di_em_win ); di_em_win = NULL; -- 2.34.1