From c55147b24a2752bd86aa559d2397a9dc54feb582 Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Wed, 25 Jan 2023 16:03:54 -0500
Subject: input_common: Make use of StoppableTimedWait

---
 src/input_common/drivers/joycon.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'src/input_common/drivers/joycon.cpp')

diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index 40cda400d8..cedc94e639 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -5,6 +5,7 @@
 
 #include "common/param_package.h"
 #include "common/polyfill_ranges.h"
+#include "common/polyfill_thread.h"
 #include "common/settings.h"
 #include "common/thread.h"
 #include "input_common/drivers/joycon.h"
@@ -67,7 +68,8 @@ void Joycons::Setup() {
 void Joycons::ScanThread(std::stop_token stop_token) {
     constexpr u16 nintendo_vendor_id = 0x057e;
     Common::SetCurrentThreadName("JoyconScanThread");
-    while (!stop_token.stop_requested()) {
+
+    do {
         SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0);
         SDL_hid_device_info* cur_dev = devs;
 
@@ -81,8 +83,7 @@ void Joycons::ScanThread(std::stop_token stop_token) {
         }
 
         SDL_hid_free_enumeration(devs);
-        std::this_thread::sleep_for(std::chrono::seconds(5));
-    }
+    } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5}));
 }
 
 bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {
-- 
cgit v1.2.3-70-g09d2