本文整理汇总了C++中USBDevice::getDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ USBDevice::getDevice方法的具体用法?C++ USBDevice::getDevice怎么用?C++ USBDevice::getDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USBDevice
的用法示例。
在下文中一共展示了USBDevice::getDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usbDeviceLeft
void FCServer::usbDeviceLeft(libusb_device *device)
{
/*
* Is this a device we recognize? If so, delete it.
*/
for (std::vector<USBDevice*>::iterator i = mUSBDevices.begin(), e = mUSBDevices.end(); i != e; ++i) {
USBDevice *dev = *i;
if (dev->getDevice() == device) {
usbDeviceLeft(i);
break;
}
}
}
示例2: usbHotplugPoll
bool FCServer::usbHotplugPoll()
{
/*
* For platforms without libusbx hotplug support,
* see if we can fake it by polling for new devices. This can
* happen on a different thread, and it probably should.
*
* We also use this for recovering from transient errors when opening
* devices. E.g. a device is reported as added by the hotplug system
* but it isn't actually ready to use in userspace yet.
*
* Returns true on success.
*/
libusb_device **list;
ssize_t listSize;
listSize = libusb_get_device_list(mUSB, &list);
if (listSize < 0) {
std::clog << "Error polling for USB devices: " << libusb_strerror(libusb_error(listSize)) << "\n";
return false;
}
// Take the lock after get_device_list completes
mEventMutex.lock();
// Look for devices that were added
for (ssize_t listItem = 0; listItem < listSize; ++listItem) {
bool isNew = true;
for (std::vector<USBDevice*>::iterator i = mUSBDevices.begin(), e = mUSBDevices.end(); i != e; ++i) {
USBDevice *dev = *i;
if (dev->getDevice() == list[listItem]) {
isNew = false;
}
}
if (isNew) {
usbDeviceArrived(list[listItem]);
}
}
// Look for devices that were removed
for (std::vector<USBDevice*>::iterator i = mUSBDevices.begin(), e = mUSBDevices.end(); i != e; ++i) {
USBDevice *dev = *i;
libusb_device *usbdev = dev->getDevice();
bool isRemoved = true;
for (ssize_t listItem = 0; listItem < listSize; ++listItem) {
if (list[listItem] == usbdev) {
isRemoved = false;
}
}
if (isRemoved) {
usbDeviceLeft(i);
}
}
mEventMutex.unlock();
libusb_free_device_list(list, true);
return true;
}