Skip to content

Commit

Permalink
Add list of known-incompatible devices with NC 700
Browse files Browse the repository at this point in the history
Bose Noise Cancelling Headphones 700 don't work with this tool. We
already note that in the README, so let's also reflect it in code by
omitting them from listings and preventing any commands from targeting
them.
  • Loading branch information
tchebb committed Jul 30, 2022
1 parent fb42c80 commit d4f613f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/device_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const COMPATIBLE_DEVICES: &[DeviceIds] = &[
bose_dev(0x40fe, 0x400d),
];

// Use UsbId instead of DeviceIds since some incompatible devices don't have a concept of DFU mode.
const INCOMPATIBLE_DEVICES: &[UsbId] = &[
// Bose Noise Cancelling Headphones 700
bose_pid(0x40fc),
];

const fn bose_dev(normal_pid: u16, dfu_pid: u16) -> DeviceIds {
DeviceIds {
normal_mode: UsbId {
Expand All @@ -21,6 +27,10 @@ const fn bose_dev(normal_pid: u16, dfu_pid: u16) -> DeviceIds {
}
}

const fn bose_pid(pid: u16) -> UsbId {
UsbId { vid: BOSE_VID, pid }
}

/// Find a device's compatibility and mode based on its USB ID.
pub fn identify_device(id: UsbId, usage_page: u16) -> DeviceCompat {
// On macOS, Windows, and Linux/hidraw, each usage page is exposed as a separate device and we
Expand All @@ -36,6 +46,11 @@ pub fn identify_device(id: UsbId, usage_page: u16) -> DeviceCompat {
}
}

// Next, see if it's known to be incompatible.
if INCOMPATIBLE_DEVICES.contains(&id) {
return DeviceCompat::Incompatible;
}

// If not, mark it as untested if it has Bose's VID.
if id.vid == BOSE_VID {
DeviceCompat::Untested(DeviceMode::Unknown)
Expand Down

0 comments on commit d4f613f

Please sign in to comment.