3 #if (_MSC_FULL_VER < 180031101) 4 #error At least Visual Studio 2013 Update 4 is required to compile this backend 19 #include "../tm2/tm-boot.h" 30 #ifdef COM_MULTITHREADED 31 CoInitializeEx(
nullptr, COINIT_MULTITHREADED);
33 CoInitializeEx(
nullptr, COINIT_APARTMENTTHREADED );
36 MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET);
53 return std::make_shared<retry_controls_work_around>(
54 std::make_shared<wmf_uvc_device>(
info, shared_from_this()));
59 return std::make_shared<wmf_backend>();
64 std::vector<uvc_device_info>
devices;
70 devices.push_back(device_info);
82 return std::make_shared<platform::command_transfer_usb>(
dev);
92 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
99 std::shared_ptr<const wmf_backend>
backend)
100 : _backend(
std::
move(backend)),
108 _connected_sensors.push_back(std::make_shared<wmf_hid_sensor>(hid_dev_info, sensor));
115 LOG_ERROR(
"hid device is no longer connected!");
121 return std::make_shared<wmf_hid_device>(
info, shared_from_this());
126 std::vector<hid_device_info>
devices;
130 devices.push_back(info);
140 return std::make_shared<os_time_service>();
148 _data._backend = backend;
149 _data._stopped =
false;
156 std::lock_guard<std::mutex>
lock(_m);
158 _data._stopped =
false;
160 _thread = std::thread([
this]() {
run(); });
165 std::lock_guard<std::mutex>
lock(_m);
168 _data._stopped =
true;
169 if (_thread.joinable()) _thread.join();
188 WNDCLASS windowClass = {};
189 LPCWSTR SzWndClass = TEXT(
"MINWINAPP");
190 windowClass.lpfnWndProc = &on_win_event;
191 windowClass.lpszClassName = SzWndClass;
192 UnregisterClass(SzWndClass,
nullptr);
194 if (!RegisterClass(&windowClass))
197 _data.hWnd = CreateWindow(SzWndClass,
nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE,
nullptr,
nullptr, &_data);
203 while (!_data._stopped)
205 if (PeekMessage(&msg, _data.hWnd, 0, 0, PM_REMOVE))
207 TranslateMessage(&msg);
208 DispatchMessage(&msg);
211 std::this_thread::sleep_for(std::chrono::milliseconds(50));
214 UnregisterDeviceNotification(_data.hdevnotifyHW);
215 UnregisterDeviceNotification(_data.hdevnotifyUVC);
216 UnregisterDeviceNotification(_data.hdevnotify_sensor);
217 DestroyWindow(_data.hWnd);
227 SetWindowLongPtr(hWnd, GWLP_USERDATA, LONG_PTR(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams));
228 if (!DoRegisterDeviceInterfaceToHwnd(hWnd))
231 auto data =
reinterpret_cast<extra_data*
>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
232 data->_stopped =
true;
235 case WM_DEVICECHANGE:
241 case DBT_DEVICEARRIVAL:
243 auto data =
reinterpret_cast<extra_data*
>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
250 case DBT_DEVICEREMOVECOMPLETE:
252 auto data =
reinterpret_cast<extra_data*
>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
254 std::wstring temp =
reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE*
>(lParam)->dbcc_name;
256 path.reserve(temp.length());
257 for (
wchar_t ch : temp) {
258 if (ch != L
'{') path.push_back(std::tolower(((
char*)&ch)[0]));
263 {
return info.device_path.substr(0,
info.device_path.find_first_of(
"{")) == path; }),
next.uvc_devices.end());
266 next.usb_devices =
data->_backend->query_usb_devices();
269 auto sub =
info.device_path.substr(0,
info.device_path.find_first_of(
"{"));
273 }),
next.hid_devices.end());
285 lRet = DefWindowProc(hWnd, message, wParam, lParam);
294 auto data =
reinterpret_cast<extra_data*
>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
297 const GUID classGuid = { 0x175695cd, 0x30d9, 0x4f87, 0x8b, 0xe3, 0x5a, 0x82, 0x70, 0xf4, 0x9a, 0x31 };
298 DEV_BROADCAST_DEVICEINTERFACE devBroadcastDeviceInterface;
299 devBroadcastDeviceInterface.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
300 devBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
301 devBroadcastDeviceInterface.dbcc_classguid = classGuid;
302 devBroadcastDeviceInterface.dbcc_reserved = 0;
304 data->hdevnotifyHW = RegisterDeviceNotification(hWnd,
305 &devBroadcastDeviceInterface,
306 DEVICE_NOTIFY_WINDOW_HANDLE);
314 DEV_BROADCAST_DEVICEINTERFACE di = { 0 };
315 di.dbcc_size =
sizeof(di);
316 di.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
317 di.dbcc_classguid = KSCATEGORY_CAPTURE;
319 data->hdevnotifyUVC = RegisterDeviceNotification(hWnd,
321 DEVICE_NOTIFY_WINDOW_HANDLE);
322 if (
data->hdevnotifyUVC ==
nullptr)
324 UnregisterDeviceNotification(
data->hdevnotifyHW);
330 DEV_BROADCAST_DEVICEINTERFACE di_sensor = { 0 };
331 di_sensor.dbcc_size =
sizeof(di_sensor);
332 di_sensor.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
335 data->hdevnotify_sensor = RegisterDeviceNotification(hWnd,
337 DEVICE_NOTIFY_WINDOW_HANDLE);
338 if (
data->hdevnotify_sensor ==
nullptr)
340 UnregisterDeviceNotification(
data->hdevnotify_sensor);
347 { 0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30} };
349 DEV_BROADCAST_DEVICEINTERFACE
hid_sensor = { 0 };
351 hid_sensor.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
354 data->hdevnotify_sensor = RegisterDeviceNotification(hWnd,
356 DEVICE_NOTIFY_WINDOW_HANDLE);
357 if (
data->hdevnotify_sensor ==
nullptr)
359 UnregisterDeviceNotification(
data->hdevnotify_sensor);
365 const GUID usbClassGuid = { 0xa5dcbf10, 0x6530, 0x11d2, 0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed };
366 DEV_BROADCAST_DEVICEINTERFACE usvDevBroadcastDeviceInterface;
367 usvDevBroadcastDeviceInterface.dbcc_size =
sizeof(DEV_BROADCAST_DEVICEINTERFACE);
368 usvDevBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
369 usvDevBroadcastDeviceInterface.dbcc_classguid = usbClassGuid;
370 usvDevBroadcastDeviceInterface.dbcc_reserved = 0;
372 data->hdevnotifyUSB = RegisterDeviceNotification(hWnd,
373 &usvDevBroadcastDeviceInterface,
374 DEVICE_NOTIFY_WINDOW_HANDLE);
387 return std::make_shared<win_event_device_watcher>(
this);
398 return device_serial;
static const textual_icon lock
GLenum GLuint GLenum GLsizei const GLchar * message
GLsizei const GLchar *const * path
GLsizei const GLchar *const * string
static const textual_icon stop
def info(name, value, persistent=False)
#define GUID_DEVINTERFACE_HID
#define KSCATEGORY_SENSOR_CAMERA
def run(include_folder_path, addon_folder_path)
void next(auto_any_t cur, type2type< T, C > *)
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
GLuint GLenum GLenum transform