Added interface_class, interface_subclass, and interface_protocol to USB device info
Currently only filled in for libusb
This commit is contained in:
parent
55ed69fc9a
commit
003a9b9666
3 changed files with 21 additions and 6 deletions
|
@ -1057,9 +1057,9 @@ CopyHIDDeviceInfo(struct hid_device_info *pSrc, struct SDL_hid_device_info *pDst
|
||||||
pDst->usage_page = pSrc->usage_page;
|
pDst->usage_page = pSrc->usage_page;
|
||||||
pDst->usage = pSrc->usage;
|
pDst->usage = pSrc->usage;
|
||||||
pDst->interface_number = pSrc->interface_number;
|
pDst->interface_number = pSrc->interface_number;
|
||||||
//pDst->interface_class = pSrc->interface_class;
|
pDst->interface_class = pSrc->interface_class;
|
||||||
//pDst->interface_subclass = pSrc->interface_subclass;
|
pDst->interface_subclass = pSrc->interface_subclass;
|
||||||
//pDst->interface_protocol = pSrc->interface_protocol;
|
pDst->interface_protocol = pSrc->interface_protocol;
|
||||||
pDst->next = NULL;
|
pDst->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,12 @@ extern "C" {
|
||||||
Since version 0.13.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 13, 0)
|
Since version 0.13.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 13, 0)
|
||||||
*/
|
*/
|
||||||
hid_bus_type bus_type;
|
hid_bus_type bus_type;
|
||||||
|
|
||||||
|
/** Additional information about the USB interface.
|
||||||
|
(libusb only) */
|
||||||
|
int interface_class;
|
||||||
|
int interface_subclass;
|
||||||
|
int interface_protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DEFINED_HID_TYPES */
|
#endif /* DEFINED_HID_TYPES */
|
||||||
|
|
|
@ -150,6 +150,9 @@ struct hid_device_ {
|
||||||
int config_number;
|
int config_number;
|
||||||
/* The interface number of the HID */
|
/* The interface number of the HID */
|
||||||
int interface;
|
int interface;
|
||||||
|
int interface_class;
|
||||||
|
int interface_subclass;
|
||||||
|
int interface_protocol;
|
||||||
|
|
||||||
uint16_t report_descriptor_size;
|
uint16_t report_descriptor_size;
|
||||||
|
|
||||||
|
@ -652,7 +655,7 @@ static void invasive_fill_device_info_usage(struct hid_device_info *cur_dev, lib
|
||||||
* Create and fill up most of hid_device_info fields.
|
* Create and fill up most of hid_device_info fields.
|
||||||
* usage_page/usage is not filled up.
|
* usage_page/usage is not filled up.
|
||||||
*/
|
*/
|
||||||
static struct hid_device_info * create_device_info_for_device(libusb_device *device, libusb_device_handle *handle, struct libusb_device_descriptor *desc, int config_number, int interface_num)
|
static struct hid_device_info * create_device_info_for_device(libusb_device *device, libusb_device_handle *handle, struct libusb_device_descriptor *desc, int config_number, int interface_num, int interface_class, int interface_subclass, int interface_protocol)
|
||||||
{
|
{
|
||||||
struct hid_device_info *cur_dev = calloc(1, sizeof(struct hid_device_info));
|
struct hid_device_info *cur_dev = calloc(1, sizeof(struct hid_device_info));
|
||||||
if (cur_dev == NULL) {
|
if (cur_dev == NULL) {
|
||||||
|
@ -666,6 +669,9 @@ static struct hid_device_info * create_device_info_for_device(libusb_device *dev
|
||||||
cur_dev->release_number = desc->bcdDevice;
|
cur_dev->release_number = desc->bcdDevice;
|
||||||
|
|
||||||
cur_dev->interface_number = interface_num;
|
cur_dev->interface_number = interface_num;
|
||||||
|
cur_dev->interface_class = interface_class;
|
||||||
|
cur_dev->interface_subclass = interface_subclass;
|
||||||
|
cur_dev->interface_protocol = interface_protocol;
|
||||||
|
|
||||||
cur_dev->bus_type = HID_API_BUS_USB;
|
cur_dev->bus_type = HID_API_BUS_USB;
|
||||||
|
|
||||||
|
@ -798,7 +804,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tmp = create_device_info_for_device(dev, handle, &desc, conf_desc->bConfigurationValue, intf_desc->bInterfaceNumber);
|
tmp = create_device_info_for_device(dev, handle, &desc, conf_desc->bConfigurationValue, intf_desc->bInterfaceNumber, intf_desc->bInterfaceClass, intf_desc->bInterfaceSubClass, intf_desc->bInterfaceProtocol);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
#ifdef INVASIVE_GET_USAGE
|
#ifdef INVASIVE_GET_USAGE
|
||||||
/* TODO: have a runtime check for this section. */
|
/* TODO: have a runtime check for this section. */
|
||||||
|
@ -1090,6 +1096,9 @@ static int hidapi_initialize_device(hid_device *dev, int config_number, const st
|
||||||
/* Store off the USB information */
|
/* Store off the USB information */
|
||||||
dev->config_number = config_number;
|
dev->config_number = config_number;
|
||||||
dev->interface = intf_desc->bInterfaceNumber;
|
dev->interface = intf_desc->bInterfaceNumber;
|
||||||
|
dev->interface_class = intf_desc->bInterfaceClass;
|
||||||
|
dev->interface_subclass = intf_desc->bInterfaceSubClass;
|
||||||
|
dev->interface_protocol = intf_desc->bInterfaceProtocol;
|
||||||
|
|
||||||
dev->report_descriptor_size = get_report_descriptor_size_from_interface_descriptors(intf_desc);
|
dev->report_descriptor_size = get_report_descriptor_size_from_interface_descriptors(intf_desc);
|
||||||
|
|
||||||
|
@ -1607,7 +1616,7 @@ HID_API_EXPORT struct hid_device_info *HID_API_CALL hid_get_device_info(hid_devi
|
||||||
libusb_device *usb_device = libusb_get_device(dev->device_handle);
|
libusb_device *usb_device = libusb_get_device(dev->device_handle);
|
||||||
libusb_get_device_descriptor(usb_device, &desc);
|
libusb_get_device_descriptor(usb_device, &desc);
|
||||||
|
|
||||||
dev->device_info = create_device_info_for_device(usb_device, dev->device_handle, &desc, dev->config_number, dev->interface);
|
dev->device_info = create_device_info_for_device(usb_device, dev->device_handle, &desc, dev->config_number, dev->interface, dev->interface_class, dev->interface_subclass, dev->interface_protocol);
|
||||||
// device error already set by create_device_info_for_device, if any
|
// device error already set by create_device_info_for_device, if any
|
||||||
|
|
||||||
if (dev->device_info) {
|
if (dev->device_info) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue