diff options
Diffstat (limited to 'device/bluetooth/bluetooth_device.cc')
-rw-r--r-- | device/bluetooth/bluetooth_device.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc index c85af11..5696632 100644 --- a/device/bluetooth/bluetooth_device.cc +++ b/device/bluetooth/bluetooth_device.cc @@ -171,6 +171,39 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const { break; } + // Some bluetooth devices, e.g., Microsoft Universal Foldable Keyboard, + // do not expose its bluetooth class. Use its appearance as a work-around. + // https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml + uint16_t appearance = GetAppearance(); + // appearance: 10-bit category and 6-bit sub-category + switch ((appearance & 0xffc0) >> 6) { + case 0x01: + // Generic phone + return DEVICE_PHONE; + case 0x02: + // Generic computer + return DEVICE_COMPUTER; + case 0x0f: + // HID subtype + switch (appearance & 0x3f) { + case 0x01: + // Keyboard. + return DEVICE_KEYBOARD; + case 0x02: + // Mouse + return DEVICE_MOUSE; + case 0x03: + // Joystick + return DEVICE_JOYSTICK; + case 0x04: + // Gamepad + return DEVICE_GAMEPAD; + case 0x05: + // Digitizer tablet + return DEVICE_TABLET; + } + } + return DEVICE_UNKNOWN; } |