mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-13 17:28:35 +02:00
[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>
This commit is contained in:
parent
06a08de68a
commit
4a833e7206
7 changed files with 90 additions and 94 deletions
|
|
@ -1,11 +1,16 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Text : Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <memory>
|
||||
#include <QtCore>
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
#include <QCameraImageCapture>
|
||||
#include <QCameraInfo>
|
||||
#if YUZU_USE_QT_MULTIMEDIA
|
||||
#include <QCamera>
|
||||
#include <QImageCapture>
|
||||
#include <QMediaCaptureSession>
|
||||
#include <QMediaDevices>
|
||||
#endif
|
||||
#include <QStandardItemModel>
|
||||
#include <QTimer>
|
||||
|
|
@ -36,22 +41,20 @@ ConfigureCamera::ConfigureCamera(QWidget* parent, InputCommon::InputSubsystem* i
|
|||
ConfigureCamera::~ConfigureCamera() = default;
|
||||
|
||||
void ConfigureCamera::PreviewCamera() {
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
#if YUZU_USE_QT_MULTIMEDIA
|
||||
const auto index = ui->ir_sensor_combo_box->currentIndex();
|
||||
bool camera_found = false;
|
||||
const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
||||
for (const QCameraInfo& cameraInfo : cameras) {
|
||||
if (input_devices[index] == cameraInfo.deviceName().toStdString() ||
|
||||
input_devices[index] == "Auto") {
|
||||
LOG_INFO(Frontend, "Selected Camera {} {}", cameraInfo.description().toStdString(),
|
||||
cameraInfo.deviceName().toStdString());
|
||||
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");
|
||||
const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
|
||||
for (const QCameraDevice& cameraDevice : cameras) {
|
||||
if (input_devices[index] == cameraDevice.id().toStdString() ||
|
||||
input_devices[index] == "auto") {
|
||||
LOG_INFO(Frontend, "Selected Camera {} {}", cameraDevice.description().toStdString(),
|
||||
cameraDevice.id().toStdString());
|
||||
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;
|
||||
}
|
||||
|
|
@ -66,24 +69,12 @@ void ConfigureCamera::PreviewCamera() {
|
|||
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;
|
||||
}
|
||||
|
||||
camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
|
||||
connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
|
||||
capture_session = std::make_unique<QMediaCaptureSession>();
|
||||
camera_capture = std::make_unique<QImageCapture>();
|
||||
capture_session->setCamera(camera.get());
|
||||
capture_session->setImageCapture(camera_capture.get());
|
||||
connect(camera_capture.get(), &QImageCapture::imageCaptured, this,
|
||||
&ConfigureCamera::DisplayCapturedFrame);
|
||||
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_snapshots = 0;
|
||||
|
|
@ -129,24 +120,31 @@ void ConfigureCamera::RetranslateUI() {
|
|||
}
|
||||
|
||||
void ConfigureCamera::ApplyConfiguration() {
|
||||
const auto index = ui->ir_sensor_combo_box->currentIndex();
|
||||
Settings::values.ir_sensor_device.SetValue(input_devices[index]);
|
||||
std::string current_device = input_devices[ui->ir_sensor_combo_box->currentIndex()];
|
||||
#ifdef _WIN32
|
||||
// for whatever reason replacing with / isn't enough so we use | for saving
|
||||
std::replace(current_device.begin(), current_device.end(), '\\', '|');
|
||||
#endif
|
||||
Settings::values.ir_sensor_device.SetValue(current_device);
|
||||
}
|
||||
|
||||
void ConfigureCamera::LoadConfiguration() {
|
||||
input_devices.clear();
|
||||
ui->ir_sensor_combo_box->clear();
|
||||
input_devices.push_back("Auto");
|
||||
input_devices.push_back("auto");
|
||||
ui->ir_sensor_combo_box->addItem(tr("Auto"));
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
const auto cameras = QCameraInfo::availableCameras();
|
||||
for (const QCameraInfo& cameraInfo : cameras) {
|
||||
input_devices.push_back(cameraInfo.deviceName().toStdString());
|
||||
ui->ir_sensor_combo_box->addItem(cameraInfo.description());
|
||||
#if YUZU_USE_QT_MULTIMEDIA
|
||||
const auto cameras = QMediaDevices::videoInputs();
|
||||
for (const QCameraDevice& cameraDevice : cameras) {
|
||||
input_devices.push_back(cameraDevice.id().toStdString());
|
||||
ui->ir_sensor_combo_box->addItem(cameraDevice.description());
|
||||
}
|
||||
#endif
|
||||
|
||||
const auto current_device = Settings::values.ir_sensor_device.GetValue();
|
||||
std::string current_device = Settings::values.ir_sensor_device.GetValue();
|
||||
#ifdef _WIN32
|
||||
std::replace(current_device.begin(), current_device.end(), '|', '\\');
|
||||
#endif
|
||||
|
||||
const auto devices_it = std::find_if(
|
||||
input_devices.begin(), input_devices.end(),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// Text : Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
|
@ -8,7 +11,8 @@
|
|||
|
||||
class QTimer;
|
||||
class QCamera;
|
||||
class QCameraImageCapture;
|
||||
class QImageCapture;
|
||||
class QMediaCaptureSession;
|
||||
|
||||
namespace InputCommon {
|
||||
class InputSubsystem;
|
||||
|
|
@ -46,9 +50,10 @@ private:
|
|||
|
||||
bool is_virtual_camera;
|
||||
int pending_snapshots;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||
#if YUZU_USE_QT_MULTIMEDIA
|
||||
std::unique_ptr<QCamera> camera;
|
||||
std::unique_ptr<QCameraImageCapture> camera_capture;
|
||||
std::unique_ptr<QImageCapture> camera_capture;
|
||||
std::unique_ptr<QMediaCaptureSession> capture_session;
|
||||
#endif
|
||||
std::unique_ptr<QTimer> camera_timer;
|
||||
std::vector<std::string> input_devices;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
|
|
@ -201,7 +201,7 @@ void ConfigureInputAdvanced::UpdateUIEnabled() {
|
|||
ui->debug_configure->setEnabled(ui->debug_enabled->isChecked());
|
||||
ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked());
|
||||
ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->isChecked());
|
||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) || !defined(YUZU_USE_QT_MULTIMEDIA)
|
||||
#if !defined(YUZU_USE_QT_MULTIMEDIA)
|
||||
ui->enable_ir_sensor->setEnabled(false);
|
||||
ui->camera_configure->setEnabled(false);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue