Skip to content

Instantly share code, notes, and snippets.

@acdimalev
Created June 4, 2010 10:57
Show Gist options
  • Save acdimalev/425278 to your computer and use it in GitHub Desktop.
Save acdimalev/425278 to your computer and use it in GitHub Desktop.
// Snippet ported from xboxdrv
{ // find endpoints
struct usb_config_descriptor *config;
struct usb_interface *interface;
struct usb_interface_descriptor *altsetting;
struct usb_endpoint_descriptor *endpoing;
for (
config = dev->config;
config != dev->config + dev->descriptor.bNumConfigurations;
config = config + 1
) {
for (
interface = config->interface;
interface != config->interface + config->bNumInterfaces;
interface = interface + 1
) {
for {
altsetting = interface->altsetting;
altsetting != interface->altsetting + interface->num_altsetting;
altsetting = altsetting + 1
) {
for (
endpoint = altsetting->endpoint;
endpoint != altsetting->endpoint + altsetting->bNumEndpoints;
endpoint = endpoint + 1
) {
if (
altsetting->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
altsetting->bInterfaceSubClass == 93 &&
altsetting->bInterfaceProtocol == 1
) {
if (endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) {
endpoint_in = int(endpoint->bEndpointAddress & USB_ENDPOINT_ADDRESS_MASK);
} else {
endpoint_out = int(endpoint->bEndpointAddress & USB_ENDPOINT_ADDRESS_MASK);
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment