Skip to content

Commit 54a5764

Browse files
committed
windows: Enable RAW_IO when creating an IN endpoint
1 parent 61237c7 commit 54a5764

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/platform/windows_winusb/device.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use std::{
1616
use log::{debug, error, warn};
1717
use windows_sys::Win32::{
1818
Devices::Usb::{
19-
WinUsb_ControlTransfer, WinUsb_Free, WinUsb_GetAssociatedInterface, WinUsb_Initialize,
20-
WinUsb_ReadPipe, WinUsb_ResetPipe, WinUsb_SetCurrentAlternateSetting, WinUsb_WritePipe,
21-
WINUSB_INTERFACE_HANDLE, WINUSB_SETUP_PACKET,
19+
self, WinUsb_ControlTransfer, WinUsb_Free, WinUsb_GetAssociatedInterface,
20+
WinUsb_Initialize, WinUsb_ReadPipe, WinUsb_ResetPipe, WinUsb_SetCurrentAlternateSetting,
21+
WinUsb_SetPipePolicy, WinUsb_WritePipe, WINUSB_INTERFACE_HANDLE, WINUSB_SETUP_PACKET,
2222
},
2323
Foundation::{GetLastError, ERROR_IO_PENDING, ERROR_NOT_FOUND, FALSE, HANDLE, TRUE},
2424
System::IO::{CancelIoEx, OVERLAPPED},
@@ -497,6 +497,23 @@ impl WindowsInterface {
497497
}
498498
state.endpoints.set(address);
499499

500+
if Direction::from_address(address) == Direction::In {
501+
unsafe {
502+
let enable: u8 = 1;
503+
let r = WinUsb_SetPipePolicy(
504+
self.winusb_handle,
505+
address,
506+
Usb::RAW_IO,
507+
size_of_val(&enable) as u32,
508+
&enable as *const _ as *const c_void,
509+
);
510+
if r != TRUE {
511+
let err = GetLastError();
512+
warn!("Failed to enable RAW_IO on endpoint {address:02X}: error {err:x}",);
513+
}
514+
}
515+
}
516+
500517
Ok(WindowsEndpoint {
501518
inner: Arc::new(EndpointInner {
502519
address,

0 commit comments

Comments
 (0)