hid_enumerate() works well on Windows and was able to find the correct port by dev->product_string.
However, on Mac, hid_enumerate() gives three instances of hid_device_info and they all include same product_string and none of them are what I expected.
This is the code.
struct hid_device_info *devs, *cur_dev;
devs = hid_enumerate(0x0, 0x0);
cur_dev = devs;
while (cur_dev) {
struct hid_device_info *dev = cur_dev;
cur_dev = cur_dev->next;
if (dev->vendor_id != VID || dev->product_id != PID) {
continue;
}
if (szPath && szPath[0] != 0x00) {
// only check for the existence of device
if (strcmp(dev->path, szPath) == 0) {
ret = true;
break;
}
} else {
if (std::wstring(dev->product_string) == L"transport") {
ret = true;
if (szPath && size > 0) {
// save path
strncpy(szPath, dev->path, size);
break;
}
}
}
}
I debugged the app and found that string "transport" in dev->path as a substring in it.
Of course, windows code is a little bit different but logic is same as this.
I'd like to know what the problem is and how I can solve this.
hid_enumerate() works well on Windows and was able to find the correct port by dev->product_string.
However, on Mac, hid_enumerate() gives three instances of hid_device_info and they all include same product_string and none of them are what I expected.
This is the code.
I debugged the app and found that string "transport" in dev->path as a substring in it.
Of course, windows code is a little bit different but logic is same as this.
I'd like to know what the problem is and how I can solve this.