mirror of
https://github.com/CTCaer/hidapi.git
synced 2024-11-27 04:00:29 +00:00
all: make hid_enumerate() able to match any vendor or any product
Passing product_id=0 will match any product of a given vendor. This patch makes it also possible to use vendor_id=0 to match any vendor for a given product id. Windows code added to Ludovic's patch by Alan Ott.
This commit is contained in:
parent
b20777fc0c
commit
ec24f93100
@ -112,6 +112,8 @@ extern "C" {
|
|||||||
|
|
||||||
This function returns a linked list of all the HID devices
|
This function returns a linked list of all the HID devices
|
||||||
attached to the system which match vendor_id and product_id.
|
attached to the system which match vendor_id and product_id.
|
||||||
|
If @p vendor_id is set to 0 then any vendor matches.
|
||||||
|
If @p product_id is set to 0 then any product matches.
|
||||||
If @p vendor_id and @p product_id are both set to 0, then
|
If @p vendor_id and @p product_id are both set to 0, then
|
||||||
all HID devices will be returned.
|
all HID devices will be returned.
|
||||||
|
|
||||||
|
@ -474,8 +474,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
|||||||
interface_num = intf_desc->bInterfaceNumber;
|
interface_num = intf_desc->bInterfaceNumber;
|
||||||
|
|
||||||
/* Check the VID/PID against the arguments */
|
/* Check the VID/PID against the arguments */
|
||||||
if ((vendor_id == 0x0 && product_id == 0x0) ||
|
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
|
||||||
(vendor_id == dev_vid && product_id == dev_pid)) {
|
(product_id == 0x0 || product_id == dev_pid)) {
|
||||||
struct hid_device_info *tmp;
|
struct hid_device_info *tmp;
|
||||||
|
|
||||||
/* VID/PID match. Create the record. */
|
/* VID/PID match. Create the record. */
|
||||||
|
@ -431,8 +431,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the VID/PID against the arguments */
|
/* Check the VID/PID against the arguments */
|
||||||
if ((vendor_id == 0x0 && product_id == 0x0) ||
|
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
|
||||||
(vendor_id == dev_vid && product_id == dev_pid)) {
|
(product_id == 0x0 || product_id == dev_pid)) {
|
||||||
struct hid_device_info *tmp;
|
struct hid_device_info *tmp;
|
||||||
|
|
||||||
/* VID/PID match. Create the record. */
|
/* VID/PID match. Create the record. */
|
||||||
|
@ -444,8 +444,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
|||||||
dev_pid = get_product_id(dev);
|
dev_pid = get_product_id(dev);
|
||||||
|
|
||||||
/* Check the VID/PID against the arguments */
|
/* Check the VID/PID against the arguments */
|
||||||
if ((vendor_id == 0x0 && product_id == 0x0) ||
|
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
|
||||||
(vendor_id == dev_vid && product_id == dev_pid)) {
|
(product_id == 0x0 || product_id == dev_pid)) {
|
||||||
struct hid_device_info *tmp;
|
struct hid_device_info *tmp;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
@ -371,8 +371,8 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor
|
|||||||
|
|
||||||
/* Check the VID/PID to see if we should add this
|
/* Check the VID/PID to see if we should add this
|
||||||
device to the enumeration list. */
|
device to the enumeration list. */
|
||||||
if ((vendor_id == 0x0 && product_id == 0x0) ||
|
if ((vendor_id == 0x0 || attrib.VendorID == vendor_id) &&
|
||||||
(attrib.VendorID == vendor_id && attrib.ProductID == product_id)) {
|
(product_id == 0x0 || attrib.ProductID == product_id)) {
|
||||||
|
|
||||||
#define WSTR_LEN 512
|
#define WSTR_LEN 512
|
||||||
const char *str;
|
const char *str;
|
||||||
|
Loading…
Reference in New Issue
Block a user