From 41d930b1e1c116b6a952654f744ee69b6ab0740a Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 20:37:21 +0800 Subject: [PATCH] Bluetooth (Haiku): WIP --- CMakeLists.txt | 3 ++- src/detection/bluetooth/bluetooth_haiku.cpp | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/detection/bluetooth/bluetooth_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a21434a3..73c421d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1134,7 +1134,7 @@ elseif(Haiku) src/detection/cpucache/cpucache_shared.c src/detection/cpuusage/cpuusage_haiku.c src/detection/cursor/cursor_nosupport.c - src/detection/bluetooth/bluetooth_nosupport.c + src/detection/bluetooth/bluetooth_haiku.cpp src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/disk/disk_haiku.cpp src/detection/dns/dns_linux.c @@ -1649,6 +1649,7 @@ elseif(Haiku) PRIVATE "bnetapi" PRIVATE "media" PRIVATE "device" + PRIVATE "bluetooth" PRIVATE "be" PRIVATE "gnu" ) diff --git a/src/detection/bluetooth/bluetooth_haiku.cpp b/src/detection/bluetooth/bluetooth_haiku.cpp new file mode 100644 index 00000000..ed24521d --- /dev/null +++ b/src/detection/bluetooth/bluetooth_haiku.cpp @@ -0,0 +1,26 @@ +extern "C" { +#include "bluetooth.h" +} + +#include + +const char* ffDetectBluetooth(FF_MAYBE_UNUSED FFBluetoothOptions* options, FFlist* devices /* FFBluetoothResult */) +{ + using namespace Bluetooth; + LocalDevice* dev = LocalDevice::GetLocalDevice(); + if (!dev) return NULL; + + BString devClass; + dev->GetDeviceClass().DumpDeviceClass(devClass); + + FFBluetoothResult* device = (FFBluetoothResult*) ffListAdd(devices); + ffStrbufInitS(&device->name, dev->GetFriendlyName()); + ffStrbufInitS(&device->address, bdaddrUtils::ToString(dev->GetBluetoothAddress()).String()); + ffStrbufInitS(&device->type, devClass.String()); + device->battery = 0; + device->connected = true; + + // TODO: more devices? + + return NULL; +}