2026-09-26 17:12:00

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie
2026-09-26 17:12:00 +00:00
parent 37fe911952
commit 2f53c0ef6b
+12 -11
View File
@@ -83,20 +83,21 @@ void Joycons::ScanThread(std::stop_token stop_token) {
constexpr u16 nintendo_vendor_id = 0x057e; constexpr u16 nintendo_vendor_id = 0x057e;
Common::SetCurrentThreadName("JoyconScanThread"); Common::SetCurrentThreadName("JoyconScanThread");
auto last_ret = 0u;
do { do {
SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0); auto ret = SDL_hid_device_change_count();
SDL_hid_device_info* cur_dev = devs; if (last_ret == 0u || last_ret != ret) {
last_ret = ret;
while (cur_dev) { SDL_hid_device_info* devs = SDL_hid_enumerate(nintendo_vendor_id, 0x0);
if (IsDeviceNew(cur_dev)) { for (auto* cur_dev = devs; cur_dev; cur_dev = cur_dev->next) {
LOG_DEBUG(Input, "Device Found,type : {:04X} {:04X}", cur_dev->vendor_id, if (IsDeviceNew(cur_dev)) {
cur_dev->product_id); LOG_DEBUG(Input, "Device Found,type : {:04X} {:04X}", cur_dev->vendor_id, cur_dev->product_id);
RegisterNewDevice(cur_dev); RegisterNewDevice(cur_dev);
}
cur_dev = cur_dev->next;
} }
cur_dev = cur_dev->next; SDL_hid_free_enumeration(devs);
} }
SDL_hid_free_enumeration(devs);
} while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5})); } while (Common::StoppableTimedWait(stop_token, std::chrono::seconds{5}));
} }