Add the interface number to hid_device_info on Linux/libusb implementation.

The interface number is added to the hid_device_info struct. Since the
Linux/libusb implementation can't put the Usage and Usage Page in the
hid_device_info struct because it requires detaching the kernel driver, the
interface number is added instead so that users with composite HID devices
can differentiate between the interfaces on the device.
This commit is contained in:
Alan Ott
2011-01-18 22:52:06 -05:00
parent a0f8bec509
commit a93cdfbeac
6 changed files with 21 additions and 2 deletions
+7 -2
View File
@@ -62,10 +62,15 @@ extern "C" {
wchar_t *manufacturer_string;
/** Product string */
wchar_t *product_string;
/** Usage Page for this Device/Interface */
/** Usage Page for this Device/Interface
(Windows/Mac only). */
unsigned short usage_page;
/** Usage for this Device/Interface */
/** Usage for this Device/Interface
(Windows/Mac only).*/
unsigned short usage;
/** The USB interface which this logical device
represents (Linux/libusb implementation only). */
int interface;
/** Pointer to the next device */
struct hid_device_info *next;
+1
View File
@@ -51,6 +51,7 @@ int main(int argc, char* argv[])
printf(" Manufacturer: %ls\n", cur_dev->manufacturer_string);
printf(" Product: %ls\n", cur_dev->product_string);
printf(" Release: %hx\n", cur_dev->release_number);
printf(" Interface: %d\n", cur_dev->interface);
printf("\n");
cur_dev = cur_dev->next;
}
+3
View File
@@ -527,6 +527,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
/* Release Number */
cur_dev->release_number = desc.bcdDevice;
/* Interface Number */
cur_dev->interface = interface_num;
}
}
} /* altsettings */
+4
View File
@@ -299,6 +299,10 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
/* Release Number */
str = udev_device_get_sysattr_value(dev, "bcdDevice");
cur_dev->release_number = (str)? strtol(str, NULL, 16): 0x0;
/* Interface Number (Unsupported on Linux/hidraw) */
cur_dev->interface = -1;
}
else
goto next;
+3
View File
@@ -364,6 +364,9 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
/* Release Number */
cur_dev->release_number = get_int_property(dev, CFSTR(kIOHIDVersionNumberKey));
/* Interface Number (Unsupported on Mac)*/
cur_dev->interface = -1;
}
}
+3
View File
@@ -359,6 +359,9 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
/* Release Number */
cur_dev->release_number = attrib.VersionNumber;
/* Interface Number (Unsupported on Windows)*/
cur_dev->interface = -1;
}
cont_close: