From 7a75615d9e0f790c5076bf6baf9067122c20ca3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 28 Jul 2024 13:06:29 +0800 Subject: [PATCH] BluetoothRadio (macOS): add dirty support --- CMakeLists.txt | 2 +- .../bluetoothradio/bluetoothradio_apple.m | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/detection/bluetoothradio/bluetoothradio_apple.m diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e8f6f86..3e6e85963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -631,7 +631,7 @@ elseif(APPLE) src/detection/battery/battery_apple.c src/detection/bios/bios_apple.c src/detection/bluetooth/bluetooth_apple.m - src/detection/bluetoothradio/bluetoothradio_nosupport.c + src/detection/bluetoothradio/bluetoothradio_apple.m src/detection/board/board_apple.c src/detection/bootmgr/bootmgr_apple.c src/detection/brightness/brightness_apple.c diff --git a/src/detection/bluetoothradio/bluetoothradio_apple.m b/src/detection/bluetoothradio/bluetoothradio_apple.m new file mode 100644 index 000000000..c68e9eee1 --- /dev/null +++ b/src/detection/bluetoothradio/bluetoothradio_apple.m @@ -0,0 +1,26 @@ +#include "bluetoothradio.h" + +#import + +const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothResult */) +{ + IOBluetoothHostController* ctrl = IOBluetoothHostController.defaultController; + if(!ctrl) + return "IOBluetoothHostController.defaultController failed"; + + FFBluetoothRadioResult* device = ffListAdd(devices); + ffStrbufInitS(&device->name, ctrl.nameAsString.UTF8String); + ffStrbufInitS(&device->address, ctrl.addressAsString.UTF8String); + device->lmpVersion = 0; + device->hciVersion = 0; + device->lmpSubversion = 0; + device->hciRevision = 0; + + #ifdef __aarch64__ + device->vendor = "Apple"; + #else + device->vendor = "Unknown"; // Hackintosh? + #endif + + return NULL; +}