Otherwise we may later write the cancelled status to invalid memory.
Also use a manual-reset event, as it should be for overlapped I/O, so all waiters are waken up on cancel.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Supersedes: 216572-216573
dlls/xinput1_3/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/xinput1_3/main.c b/dlls/xinput1_3/main.c index 81d11e5d38f..1f9d4881751 100644 --- a/dlls/xinput1_3/main.c +++ b/dlls/xinput1_3/main.c @@ -354,6 +354,7 @@ static void controller_disable(struct xinput_controller *controller) controller->enabled = FALSE;
CancelIoEx(controller->device, &controller->hid.read_ovl); + WaitForSingleObject(controller->hid.read_ovl.hEvent, INFINITE); SetEvent(update_event); }
@@ -365,7 +366,7 @@ static BOOL controller_init(struct xinput_controller *controller, PHIDP_PREPARSE controller->hid.caps = *caps; if (!(controller->hid.feature_report_buf = calloc(1, controller->hid.caps.FeatureReportByteLength))) goto failed; if (!controller_check_caps(controller, device, preparsed)) goto failed; - if (!(event = CreateEventA(NULL, FALSE, FALSE, NULL))) goto failed; + if (!(event = CreateEventW(NULL, TRUE, FALSE, NULL))) goto failed;
TRACE("Found gamepad %s\n", debugstr_w(device_path));