diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-06-28 19:35:51 -0500 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2022-07-23 19:40:25 -0500 |
commit | 403bdc4dafe89a463f3d93b9a389a1010ca5ff16 (patch) | |
tree | 88df3fada076b04c2ab2da8972d1d785f492b520 /src/yuzu/bootmanager.cpp | |
parent | 097785e19e3865ac1060b9fae564a3a1e36c695d (diff) |
yuzu: Add webcam support and rebase to latest master
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
-rw-r--r-- | src/yuzu/bootmanager.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 7740858097..0ee3820a2d 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -830,6 +830,10 @@ void GRenderWindow::InitializeCamera() { camera->unload(); camera->setCaptureMode(QCamera::CaptureViewfinder); camera->load(); + camera->start(); + + pending_camera_snapshots = 0; + is_virtual_camera = false; camera_timer = std::make_unique<QTimer>(); connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); }); @@ -851,11 +855,17 @@ void GRenderWindow::RequestCameraCapture() { return; } - // Idealy one should only call capture but Qt refuses to take a second capture without - // stopping the camera - camera->stop(); - camera->start(); + // If the camera doesn't capture, test for virtual cameras + if (pending_camera_snapshots > 5) { + is_virtual_camera = true; + } + // Virtual cameras like obs need to reset the camera every capture + if (is_virtual_camera) { + camera->stop(); + camera->start(); + } + pending_camera_snapshots++; camera_capture->capture(); } @@ -870,6 +880,7 @@ void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { camera_data.resize(camera_width * camera_height); std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32)); input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data); + pending_camera_snapshots = 0; } bool GRenderWindow::event(QEvent* event) { |