Skip to content

Instantly share code, notes, and snippets.

@hirokuma
Created July 17, 2011 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirokuma/1087031 to your computer and use it in GitHub Desktop.
Save hirokuma/1087031 to your computer and use it in GitHub Desktop.
libusb-1.0 search endpoint
for(int inf = 0; inf < pConfig->bNumInterfaces; inf++) {
const libusb_interface& inter = pConfig->interface[inf];
for(int alt = 0; alt < inter.num_altsetting; alt++) {
const libusb_interface_descriptor& idesc = inter.altsetting[alt];
for(int desc = 0; desc < idesc.bNumEndpoints; desc++) {
const libusb_endpoint_descriptor& EndPnt = idesc.endpoint[desc];
assert(EndPnt.bDescriptorType == LIBUSB_DT_ENDPOINT);
if(EndPnt.bEndpointAddress & LIBUSB_ENDPOINT_IN) {
m_EndPntIn = EndPnt.bEndpointAddress;
}
else {
m_EndPntOut = EndPnt.bEndpointAddress;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment