bluetooth.odin 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // +build windows
  2. package sys_windows
  3. foreign import "system:bthprops.lib"
  4. HBLUETOOTH_DEVICE_FIND :: distinct HANDLE
  5. HBLUETOOTH_RADIO_FIND :: distinct HANDLE
  6. BLUETOOTH_FIND_RADIO_PARAMS :: struct {
  7. dw_size: DWORD,
  8. }
  9. BLUETOOTH_RADIO_INFO :: struct {
  10. dw_size: DWORD, // Size of this structure
  11. address: BLUETOOTH_ADDRESS, // Address of radio
  12. name: [BLUETOOTH_MAX_NAME_SIZE]u16, // Name of the radio
  13. device_class: ULONG, // Bluetooth "Class of Device". See: https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Baseband.pdf
  14. lmp_minor_version: USHORT, // This member contains data specific to individual Bluetooth device manufacturers.
  15. manufacturer: USHORT, // Manufacturer of the Bluetooth radio, expressed as a BTH_MFG_Xxx value. See https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
  16. }
  17. BLUETOOTH_DEVICE_SEARCH_PARAMS :: struct {
  18. dw_size: DWORD, // Size of this structure
  19. return_authenticated: BOOL, // Return authenticated devices
  20. return_remembered: BOOL, // Return remembered devices
  21. return_unknown: BOOL, // Return unknown devices
  22. return_connected: BOOL, // Return connected devices
  23. issue_inquiry: BOOL, // Issue a new inquiry
  24. timeout_multiplier: UCHAR, // Timeout for the inquiry, expressed in increments of 1.28 seconds
  25. radio: HANDLE, // Handle to radio to enumerate - NULL == all radios will be searched
  26. }
  27. BLUETOOTH_ADDRESS :: struct #raw_union {
  28. addr: u64,
  29. val: [6]u8, // The first 3 bytes can be used to find the Manufacturer using http://standards-oui.ieee.org/oui/oui.txt
  30. }
  31. BLUETOOTH_MAX_NAME_SIZE :: 248
  32. BLUETOOTH_DEVICE_INFO :: struct {
  33. dw_size: DWORD, // Size in bytes of this structure - must be the size_of(BLUETOOTH_DEVICE_INFO)
  34. address: BLUETOOTH_ADDRESS, // Bluetooth address
  35. device_class: ULONG, // Bluetooth "Class of Device". See: https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Baseband.pdf
  36. connected: BOOL, // Device connected/in use
  37. remembered: BOOL, // Device remembered
  38. authenticated: BOOL, // Device authenticated/paired/bonded
  39. last_seen: SYSTEMTIME, // Last time the device was seen
  40. last_used: SYSTEMTIME, // Last time the device was used for other than RNR, inquiry, or SDP
  41. name: [BLUETOOTH_MAX_NAME_SIZE]u16, // Name of the device
  42. }
  43. @(default_calling_convention="stdcall")
  44. foreign bthprops {
  45. /*
  46. Version
  47. */
  48. BluetoothIsVersionAvailable :: proc(major: u8, minor: u8) -> BOOL ---
  49. /*
  50. Radio enumeration
  51. */
  52. BluetoothFindFirstRadio :: proc(find_radio_params: ^BLUETOOTH_FIND_RADIO_PARAMS, radio: ^HANDLE) -> HBLUETOOTH_RADIO_FIND ---
  53. BluetoothFindNextRadio :: proc(handle: HBLUETOOTH_RADIO_FIND, radio: ^HANDLE) -> BOOL ---
  54. BluetoothFindRadioClose :: proc(handle: HBLUETOOTH_RADIO_FIND) -> BOOL ---
  55. BluetoothGetRadioInfo :: proc(radio: HANDLE, radio_info: ^BLUETOOTH_RADIO_INFO) -> DWORD ---
  56. /*
  57. Device enumeration
  58. */
  59. BluetoothFindFirstDevice :: proc(search_params: ^BLUETOOTH_DEVICE_SEARCH_PARAMS, device_info: ^BLUETOOTH_DEVICE_INFO) -> HBLUETOOTH_DEVICE_FIND ---
  60. BluetoothFindNextDevice :: proc(handle: HBLUETOOTH_DEVICE_FIND, device_info: ^BLUETOOTH_DEVICE_INFO) -> BOOL ---
  61. BluetoothFindDeviceClose :: proc(handle: HBLUETOOTH_DEVICE_FIND) -> BOOL ---
  62. BluetoothGetDeviceInfo :: proc(radio: HANDLE, device_info: ^BLUETOOTH_DEVICE_INFO) -> DWORD ---
  63. BluetoothDisplayDeviceProperties :: proc(hwnd_parent: HWND, device_info: ^BLUETOOTH_DEVICE_INFO) -> BOOL ---
  64. }