summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/joycon.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2023-01-27 18:28:03 -0800
committerGravatar GitHub2023-01-27 18:28:03 -0800
commit2efe42fc9367588d5ffa1e5e2f25d77bd8ddc49e (patch)
treecdd5d8f93e9f79f5e8e38515f178520c07a27f3b /src/input_common/drivers/joycon.cpp
parentMerge pull request #9539 from Wollnashorn/opengl-fsr (diff)
parentinput_common: Make use of StoppableTimedWait (diff)
downloadyuzu-2efe42fc9367588d5ffa1e5e2f25d77bd8ddc49e.tar.gz
yuzu-2efe42fc9367588d5ffa1e5e2f25d77bd8ddc49e.tar.xz
yuzu-2efe42fc9367588d5ffa1e5e2f25d77bd8ddc49e.zip
Merge pull request #9677 from Morph1984/sleep-one
polyfill_thread: Implement StoppableTimedWait
Diffstat (limited to '')
-rw-r--r--src/input_common/drivers/joycon.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index 40cda400d..cedc94e63 100644
--- a/src/input_common/drivers/joycon.cpp
+++ b/src/input_common/drivers/joycon.cpp
@@ -5,6 +5,7 @@
5 5
6#include "common/param_package.h" 6#include "common/param_package.h"
7#include "common/polyfill_ranges.h" 7#include "common/polyfill_ranges.h"
8#include "common/polyfill_thread.h"
8#include "common/settings.h" 9#include "common/settings.h"
9#include "common/thread.h" 10#include "common/thread.h"
10#include "input_common/drivers/joycon.h" 11#include "input_common/drivers/joycon.h"
@@ -67,7 +68,8 @@ void Joycons::Setup() {
67void Joycons::ScanThread(std::stop_token stop_token) { 68void Joycons::ScanThread(std::stop_token stop_token) {
68 constexpr u16 nintendo_vendor_id = 0x057e; 69 constexpr u16 nintendo_vendor_id = 0x057e;
69 Common::SetCurrentThreadName("JoyconScanThread"); 70 Common::SetCurrentThreadName("JoyconScanThread");
70 while (!stop_token.stop_requested()) { 71
72 do {
71 SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); 73 SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0);
72 SDL_hid_device_info* cur_dev = devs; 74 SDL_hid_device_info* cur_dev = devs;
73 75
@@ -81,8 +83,7 @@ void Joycons::ScanThread(std::stop_token stop_token) {
81 } 83 }
82 84
83 SDL_hid_free_enumeration(devs); 85 SDL_hid_free_enumeration(devs);
84 std::this_thread::sleep_for(std::chrono::seconds(5)); 86 } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5}));
85 }
86} 87}
87 88
88bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const { 89bool Joycons::IsDeviceNew(SDL_hid_device_info* device_info) const {