MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / getHotplugBasedDeviceList

Function getHotplugBasedDeviceList

plugins/usb/usb-helpers.cpp:138–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static std::vector<USBDeviceInfo> getHotplugBasedDeviceList()
139{
140 static std::vector<USBDeviceInfo> devices;
141 static bool hotplugSetupDone = false;
142
143 if (!hotplugSetupDone) {
144 hotplugSetupDone = true;
145 devices = pollUSBDevices();
146
147 int ret = libusb_hotplug_register_callback(
148 nullptr,
149 LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED |
150 LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
151 0, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
152 LIBUSB_HOTPLUG_MATCH_ANY, hotplugCallback, &devices,
153 nullptr);
154 if (ret != LIBUSB_SUCCESS) {
155 hotplugsAreSupported = false;
156 } else {
157 blog(LOG_WARNING, LOG_PREFIX "hotplug supported!");
158 }
159 }
160
161 std::lock_guard<std::mutex> lock(mutex);
162 return devices;
163}
164
165static std::vector<USBDeviceInfo> getPollingBasedDeviceList()
166{

Callers

nothing calls this directly

Calls 1

pollUSBDevicesFunction · 0.85

Tested by

no test coverage detected