Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bulk transfer type in addition to interrupt #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions raw_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func enumerateRawWithRef(vendorID uint16, productID uint16) ([]DeviceInfo, error
if alt.bInterfaceClass == C.LIBUSB_CLASS_HID {
continue
}
// Find the endpoints that can speak libusb interrupts
var ends []C.struct_libusb_endpoint_descriptor
*(*reflect.SliceHeader)(unsafe.Pointer(&ends)) = reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(alt.endpoint)),
Expand All @@ -129,14 +128,18 @@ func enumerateRawWithRef(vendorID uint16, productID uint16) ([]DeviceInfo, error
}
var reader, writer *uint8
for _, end := range ends {
// Skip any non-interrupt endpoints
if end.bmAttributes != C.LIBUSB_TRANSFER_TYPE_INTERRUPT {
continue
maskedAttributes := end.bmAttributes & C.LIBUSB_TRANSFER_TYPE_MASK
is_interrupt := maskedAttributes == C.LIBUSB_TRANSFER_TYPE_INTERRUPT
is_bulk := maskedAttributes == C.LIBUSB_TRANSFER_TYPE_BULK

if !is_interrupt && !is_bulk {
continue // Skip non-interrupt and non-bulk endpoints
}

if end.bEndpointAddress&C.LIBUSB_ENDPOINT_IN == C.LIBUSB_ENDPOINT_IN {
reader = new(uint8)
*reader = uint8(end.bEndpointAddress)
} else {
} else if end.bEndpointAddress&C.LIBUSB_ENDPOINT_OUT == C.LIBUSB_ENDPOINT_OUT {
writer = new(uint8)
*writer = uint8(end.bEndpointAddress)
}
Expand Down