Revert "Try all interfaces"

This reverts commit 02c7cc3fc804edd8d11f990e1db685899543d00e.
This commit is contained in:
Lennard Kittner
2026-04-22 11:05:48 +02:00
parent a5369fbb1d
commit d8abc9c734

View File

@@ -87,34 +87,34 @@ pub fn connect_compatible_device() -> Result<Box<dyn Device>, DeviceError> {
debug_println!("Found device selecting handler"); debug_println!("Found device selecting handler");
// On Linux and MacOS we can just take the first // On Linux and MacOS we can just take the first
// #[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
// { {
// let state = states let state = states
// .into_iter() .into_iter()
// .next() .next()
// .ok_or(DeviceError::NoDeviceFound())?; .ok_or(DeviceError::NoDeviceFound())?;
// println!( println!(
// "Connecting to {}", "Connecting to {}",
// state state
// .device_properties .device_properties
// .device_name .device_name
// .clone() .clone()
// .unwrap_or("???".to_string()) .unwrap_or("???".to_string())
// ); );
// let entry = DEVICE_REGISTER let entry = DEVICE_REGISTER
// .iter() .iter()
// .find(|e| { .find(|e| {
// e.vendor_ids.contains(&state.device_properties.vendor_id) e.vendor_ids.contains(&state.device_properties.vendor_id)
// && e.product_ids.contains(&state.device_properties.product_id) && e.product_ids.contains(&state.device_properties.product_id)
// }) })
// .ok_or(DeviceError::NoDeviceFound())?; .ok_or(DeviceError::NoDeviceFound())?;
//
// let mut device = (entry.factory)(state); let mut device = (entry.factory)(state);
// device.init_capabilities(); device.init_capabilities();
// Ok(device) Ok(device)
// } }
// On Windows we have to check which interface can be used // On Windows we have to check which interface can be used
// #[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
let mut device = None; let mut device = None;
for state in states { for state in states {
@@ -140,7 +140,7 @@ pub fn connect_compatible_device() -> Result<Box<dyn Device>, DeviceError> {
let probe_packet = test_device let probe_packet = test_device
.get_query_packets() .get_query_packets()
.into_iter() .into_iter()
.nth(2) .next()
.expect("Why is there a device without packets ???"); .expect("Why is there a device without packets ???");
test_device.prepare_write(); test_device.prepare_write();
@@ -151,16 +151,6 @@ pub fn connect_compatible_device() -> Result<Box<dyn Device>, DeviceError> {
debug_println!("Failed to open: {_e:?}"); debug_println!("Failed to open: {_e:?}");
continue; continue;
} else { } else {
std::thread::sleep(RESPONSE_DELAY);
if let Some(events) = test_device.wait_for_updates(Duration::from_secs(1)) {
for event in events {
debug_println!("got response {event:?}");
}
} else {
continue;
}
device = Some(test_device); device = Some(test_device);
break; break;
} }