From 94be0e466e7e34c7fe77af4512982c21b7f49082 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 13 Oct 2025 18:37:13 -0500 Subject: [PATCH] WiimoteReal/IOLinux: Reopen Bluetooth device if it was unplugged between scans. --- Source/Core/Core/HW/WiimoteReal/IOLinux.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp index 3fe5f09403..7d60334d72 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp @@ -60,7 +60,16 @@ WiimoteScannerLinux::WiimoteScannerLinux() bool WiimoteScannerLinux::Open() { if (IsReady()) - return true; + { + // Verify that the device socket is still valid (checking for POLLERR). + pollfd pfd{.fd = m_device_sock}; + if (UnixUtil::RetryOnEINTR(poll, &pfd, 1, 0) >= 0 && pfd.revents == 0) + return true; + + // This happens if the Bluetooth adapter was unplugged between scans. + WARN_LOG_FMT(WIIMOTE, "Existing Bluetooth socket was invalid. Attempting to reopen."); + Close(); + } // Get the id of the first Bluetooth device. m_device_id = hci_get_route(nullptr);