diff options
| author | smiRaphi <neogt404@gmail.com> | 2026-02-28 01:06:59 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-02-28 01:06:59 +0100 |
| commit | 4a833e7206ea0a603def7f9a8538b1dc032eea8e (patch) | |
| tree | 2adba9fd28ce829d4abe4724fce86e0727744ba1 /src/yuzu/bootmanager.cpp | |
| parent | 06a08de68a95506a9cbe4633c58f6bdb5ded0c70 (diff) | |
[desktop] port IR Camera to Qt6 & fix camera saving on windows (#3630)
The camera was previously saved without escaping the name which made the values unusable after a settings load, for whatever reason replacing the backslashes when saving with / doesn't work but replacing them with | does.
Also note that the OBS virtual cam (and any other cameras that only have directshow drivers) won't work because Qt6 dropped support for that and the ffmpeg backend doesn't seem to support it either.
Closes #3468
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3630
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: DraVee <dravee@eden-emu.dev>
Co-authored-by: smiRaphi <neogt404@gmail.com>
Co-committed-by: smiRaphi <neogt404@gmail.com>
Diffstat (limited to 'src/yuzu/bootmanager.cpp')
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1b88f4133f..72a5157fc4 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -13,10 +13,11 @@ #include <QtCore/qglobal.h> #include "common/settings_enums.h" #include "qt_common/config/uisettings.h" -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#if YUZU_USE_QT_MULTIMEDIA #include <QCamera> -#include <QCameraImageCapture> -#include <QCameraInfo> +#include <QImageCapture> +#include <QMediaCaptureSession> +#include <QMediaDevices> #endif #include <QCursor> #include <QEvent> @@ -756,24 +757,25 @@ void GRenderWindow::TouchEndEvent() { } void GRenderWindow::InitializeCamera() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#if YUZU_USE_QT_MULTIMEDIA constexpr auto camera_update_ms = std::chrono::milliseconds{50}; // (50ms, 20Hz) if (!Settings::values.enable_ir_sensor) { return; } bool camera_found = false; - const QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); - for (const QCameraInfo& cameraInfo : cameras) { - if (Settings::values.ir_sensor_device.GetValue() == cameraInfo.deviceName().toStdString() || - Settings::values.ir_sensor_device.GetValue() == "Auto") { - camera = std::make_unique<QCamera>(cameraInfo); - if (!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder) && - !camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) { - LOG_ERROR(Frontend, - "Camera doesn't support CaptureViewfinder or CaptureStillImage"); + std::string current_device = Settings::values.ir_sensor_device.GetValue(); +#ifdef _WIN32 + std::replace(current_device.begin(), current_device.end(), '|', '\\'); +#endif + const QList<QCameraDevice> cameras = QMediaDevices::videoInputs(); + for (const QCameraDevice& cameraDevice : cameras) { + if (current_device == cameraDevice.id().toStdString() || current_device == "auto") { + if (cameraDevice.videoFormats().isEmpty()) { + LOG_ERROR(Frontend, "Camera doesn't provide any video formats."); continue; } + camera = std::make_unique<QCamera>(cameraDevice); camera_found = true; break; } @@ -783,27 +785,16 @@ void GRenderWindow::InitializeCamera() { return; } - camera_capture = std::make_unique<QCameraImageCapture>(camera.get()); - - if (!camera_capture->isCaptureDestinationSupported( - QCameraImageCapture::CaptureDestination::CaptureToBuffer)) { - LOG_ERROR(Frontend, "Camera doesn't support saving to buffer"); - return; - } + capture_session = std::make_unique<QMediaCaptureSession>(); + camera_capture = std::make_unique<QImageCapture>(); + capture_session->setCamera(camera.get()); + capture_session->setImageCapture(camera_capture.get()); const auto camera_width = input_subsystem->GetCamera()->getImageWidth(); const auto camera_height = input_subsystem->GetCamera()->getImageHeight(); camera_data.resize(camera_width * camera_height); - camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); - connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, + connect(camera_capture.get(), &QImageCapture::imageCaptured, this, &GRenderWindow::OnCameraCapture); - camera->unload(); - if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder)) { - camera->setCaptureMode(QCamera::CaptureViewfinder); - } else if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) { - camera->setCaptureMode(QCamera::CaptureStillImage); - } - camera->load(); camera->start(); pending_camera_snapshots = 0; @@ -817,18 +808,18 @@ void GRenderWindow::InitializeCamera() { } void GRenderWindow::FinalizeCamera() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#if YUZU_USE_QT_MULTIMEDIA if (camera_timer) { camera_timer->stop(); } if (camera) { - camera->unload(); + camera->stop(); } #endif } void GRenderWindow::RequestCameraCapture() { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#if YUZU_USE_QT_MULTIMEDIA if (!Settings::values.enable_ir_sensor) { return; } @@ -849,7 +840,7 @@ void GRenderWindow::RequestCameraCapture() { } void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#if YUZU_USE_QT_MULTIMEDIA // TODO: Capture directly in the format and resolution needed const auto camera_width = input_subsystem->GetCamera()->getImageWidth(); const auto camera_height = input_subsystem->GetCamera()->getImageHeight(); |
