Created
June 4, 2010 10:57
-
-
Save acdimalev/425278 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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