mirror of
https://github.com/shadps4-emu/ext-libusb.git
synced 2026-01-31 00:55:21 +01:00
core: Add helper find_alt_endpoint()
This commit is contained in:
committed by
Tormod Volden
parent
6c2149662a
commit
94eb23991b
@@ -1081,6 +1081,33 @@ out:
|
||||
return r;
|
||||
}
|
||||
|
||||
static const struct libusb_endpoint_descriptor *find_alt_endpoint(
|
||||
struct libusb_config_descriptor *config,
|
||||
int iface_idx, int altsetting_idx, unsigned char endpoint)
|
||||
{
|
||||
if (iface_idx >= config->bNumInterfaces) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct libusb_interface *iface = &config->interface[iface_idx];
|
||||
|
||||
if (altsetting_idx >= iface->num_altsetting) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct libusb_interface_descriptor *altsetting
|
||||
= &iface->altsetting[altsetting_idx];
|
||||
int ep_idx;
|
||||
|
||||
for (ep_idx = 0; ep_idx < altsetting->bNumEndpoints; ep_idx++) {
|
||||
const struct libusb_endpoint_descriptor *ep =
|
||||
&altsetting->endpoint[ep_idx];
|
||||
if (ep->bEndpointAddress == endpoint)
|
||||
return ep;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_endpoint_max_packet_size(libusb_device *dev,
|
||||
const struct libusb_endpoint_descriptor *ep)
|
||||
{
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 11773
|
||||
#define LIBUSB_NANO 11774
|
||||
|
||||
Reference in New Issue
Block a user