From d03e34d9e497b26d908d99ce1d7c064b7ed994d0 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sat, 26 Oct 2024 10:53:14 +0800 Subject: [PATCH] Handle windows missing function for nusb --- src/host.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/host.rs b/src/host.rs index 94f009b..ee36279 100644 --- a/src/host.rs +++ b/src/host.rs @@ -283,14 +283,18 @@ impl UsbDeviceHandler for NusbUsbHostDeviceHandler { index: setup.index, }; // control - if setup.request_type & 0x80 == 0 { - // control out - handle.control_out_blocking(control, req, timeout).ok(); - } else { - // control in - if let Ok(len) = handle.control_in_blocking(control, &mut buffer, timeout) { - return Ok(Vec::from(&buffer[..len])); + if cfg!(not(target_os = "windows")) { + if setup.request_type & 0x80 == 0 { + // control out + handle.control_out_blocking(control, req, timeout).ok(); + } else { + // control in + if let Ok(len) = handle.control_in_blocking(control, &mut buffer, timeout) { + return Ok(Vec::from(&buffer[..len])); + } } + } else { + warn!("Not supported in windows") } Ok(vec![]) }