fix keyboard and mass storgae stream
This commit is contained in:
@@ -37,6 +37,7 @@ var (
|
||||
usbdevfsSetInterface = ior('U', 4, unsafe.Sizeof(usbdevfsSetIntf{}))
|
||||
usbdevfsSetConfig = ior('U', 5, 4)
|
||||
usbdevfsSubmitURB = ior('U', 10, unsafe.Sizeof(usbdevfsURB{}))
|
||||
usbdevfsResetEP = ior('U', 3, 4)
|
||||
usbdevfsDiscardURB = io_('U', 11)
|
||||
usbdevfsReapURB = iow('U', 12, unsafe.Sizeof(uintptr(0)))
|
||||
usbdevfsReapURBNDelay = iow('U', 13, unsafe.Sizeof(uintptr(0)))
|
||||
@@ -348,6 +349,27 @@ func (h *DeviceHandle) DiscardURB(urb *usbdevfsURB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DiscardURBByPtr cancels a submitted URB given its raw pointer.
|
||||
// Use this when the URB type is not accessible (e.g. from another package).
|
||||
func (h *DeviceHandle) DiscardURBByPtr(ptr unsafe.Pointer) error {
|
||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(h.fd), usbdevfsDiscardURB, uintptr(ptr))
|
||||
if errno != 0 {
|
||||
return fmt.Errorf("USBDEVFS_DISCARDURB: %w", errno)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetEndpoint resets the host-side data toggle for an endpoint without
|
||||
// sending any USB traffic to the device. Use after SET_CONFIGURATION to
|
||||
// sync host controller toggle state with the device.
|
||||
func (h *DeviceHandle) ResetEndpoint(endpoint uint32) error {
|
||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(h.fd), usbdevfsResetEP, uintptr(unsafe.Pointer(&endpoint)))
|
||||
if errno != 0 {
|
||||
return fmt.Errorf("USBDEVFS_RESETEP(%d): %w", endpoint, errno)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SubmitISOURBParams holds parameters for async ISO URB submission
|
||||
type SubmitISOURBParams struct {
|
||||
Endpoint uint8
|
||||
|
||||
Reference in New Issue
Block a user