From 80b462e553ed3a5cee2c5a86244937f94fd2513f Mon Sep 17 00:00:00 2001
From: Narr the Reg <juangerman-13@hotmail.com>
Date: Fri, 5 Aug 2022 13:40:44 -0500
Subject: [PATCH] hid: core: Delay the stop vibration command when testing

---
 src/core/hid/emulated_controller.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 8c3895937..3552ad07c 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -1,6 +1,7 @@
 // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
 // SPDX-License-Identifier: GPL-2.0-or-later
 
+#include "common/thread.h"
 #include "core/hid/emulated_controller.h"
 #include "core/hid/input_converter.h"
 
@@ -949,6 +950,9 @@ bool EmulatedController::TestVibration(std::size_t device_index) {
     // Send a slight vibration to test for rumble support
     output_devices[device_index]->SetVibration(test_vibration);
 
+    // Wait for about 15ms to ensure the controller is ready for the stop command
+    std::this_thread::sleep_for(std::chrono::milliseconds(15));
+
     // Stop any vibration and return the result
     return output_devices[device_index]->SetVibration(zero_vibration) ==
            Common::Input::VibrationError::None;