summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/joycon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/joycon.cpp')
-rw-r--r--src/input_common/drivers/joycon.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/input_common/drivers/joycon.cpp b/src/input_common/drivers/joycon.cpp
index 40cda400d..4fcfb4510 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 {
@@ -667,12 +668,10 @@ std::string Joycons::JoyconName(Joycon::ControllerType type) const {
667 return "Right Joycon"; 668 return "Right Joycon";
668 case Joycon::ControllerType::Pro: 669 case Joycon::ControllerType::Pro:
669 return "Pro Controller"; 670 return "Pro Controller";
670 case Joycon::ControllerType::Grip:
671 return "Grip Controller";
672 case Joycon::ControllerType::Dual: 671 case Joycon::ControllerType::Dual:
673 return "Dual Joycon"; 672 return "Dual Joycon";
674 default: 673 default:
675 return "Unknown Joycon"; 674 return "Unknown Switch Controller";
676 } 675 }
677} 676}
678} // namespace InputCommon 677} // namespace InputCommon