From b152b383a2fd7706834b4f2a8752e7059a302d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 20 Dec 2024 13:43:30 +0800 Subject: [PATCH] Bluetooth (Windows): optimise 1. don't report disconnected devices if `showDisconnected == false` 2. don't report unknown devices 3. don't report errors when no devices found --- src/detection/bluetooth/bluetooth_windows.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/detection/bluetooth/bluetooth_windows.c b/src/detection/bluetooth/bluetooth_windows.c index d59a31623..5da75fc83 100644 --- a/src/detection/bluetooth/bluetooth_windows.c +++ b/src/detection/bluetooth/bluetooth_windows.c @@ -20,13 +20,14 @@ const char* ffDetectBluetooth(FFBluetoothOptions* options, FFlist* devices /* FF }; HBLUETOOTH_DEVICE_FIND hFind = ffBluetoothFindFirstDevice(&(BLUETOOTH_DEVICE_SEARCH_PARAMS) { .fReturnConnected = TRUE, - .fReturnRemembered = TRUE, - .fReturnAuthenticated = TRUE, - .fReturnUnknown = TRUE, + .fReturnRemembered = options->showDisconnected, + .fReturnAuthenticated = options->showDisconnected, .dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS) }, &btdi); if(!hFind) { + if (GetLastError() == ERROR_NO_MORE_ITEMS) + return NULL; return "BluetoothFindFirstDevice() failed"; }