Returns a list of devices as (Kind, Serial Number) that could be found using HidApi. WARNING:** To refresh the list, use [refresh_device_list]
(hidapi: &HidApi)
| 54 | /// |
| 55 | /// **WARNING:** To refresh the list, use [refresh_device_list] |
| 56 | pub fn list_devices(hidapi: &HidApi) -> Vec<(Kind, String)> { |
| 57 | hidapi |
| 58 | .device_list() |
| 59 | .filter_map(|d| { |
| 60 | if !is_vendor_familiar(&d.vendor_id()) { |
| 61 | return None; |
| 62 | } |
| 63 | |
| 64 | if let Some(serial) = d.serial_number() { |
| 65 | Some((Kind::from_vid_pid(d.vendor_id(), d.product_id())?, serial.to_string())) |
| 66 | } else { |
| 67 | None |
| 68 | } |
| 69 | }) |
| 70 | .collect::<HashSet<_>>() |
| 71 | .into_iter() |
| 72 | .collect() |
| 73 | } |
| 74 | |
| 75 | /// Type of input that the device produced |
| 76 | #[derive(Clone, Debug)] |
no test coverage detected