From abd059c379181cd7483b1568f4b1b512ff857f91 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Tue, 3 Jun 2025 21:46:28 +0330 Subject: [PATCH] Make sure hid_enumerate isn't called simultaneously in different threads --- rpcs3/Input/hid_pad_handler.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpcs3/Input/hid_pad_handler.cpp b/rpcs3/Input/hid_pad_handler.cpp index a972cd4fbe..697922965d 100644 --- a/rpcs3/Input/hid_pad_handler.cpp +++ b/rpcs3/Input/hid_pad_handler.cpp @@ -199,7 +199,11 @@ void hid_pad_handler::enumerate_devices() } } } -#else +#endif + + std::lock_guard lock(m_enumeration_mutex); + +#ifndef ANDROID for (const auto& [vid, pid] : m_ids) { hid_device_info* dev_info = hid_enumerate(vid, pid); @@ -230,7 +234,6 @@ void hid_pad_handler::enumerate_devices() #endif hid_log.notice("%s enumeration found %d devices (%f ms)", m_type, device_paths.size(), timer.GetElapsedTimeInMilliSec()); - std::lock_guard lock(m_enumeration_mutex); m_new_enumerated_devices = device_paths; m_enumerated_serials = std::move(serials);