mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-26 19:32:40 -06:00
Qt6: Disable IR Sensor when compiling with Qt6
Gating the IR Sensor code behind a macro like so `#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA` The YUZU_USE_QT_MULTIMEDIA flag is implemented in later commit Also the locale fix in src/yuzu/main.cpp is now gated against Qt6, as it causes compilation error
This commit is contained in:
parent
405d685101
commit
ad3ee5c52b
6 changed files with 25 additions and 0 deletions
|
@ -4,8 +4,10 @@
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
#include <QCameraImageCapture>
|
#include <QCameraImageCapture>
|
||||||
#include <QCameraInfo>
|
#include <QCameraInfo>
|
||||||
|
#endif
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -707,6 +709,7 @@ void GRenderWindow::TouchEndEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::InitializeCamera() {
|
void GRenderWindow::InitializeCamera() {
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
constexpr auto camera_update_ms = std::chrono::milliseconds{50}; // (50ms, 20Hz)
|
constexpr auto camera_update_ms = std::chrono::milliseconds{50}; // (50ms, 20Hz)
|
||||||
if (!Settings::values.enable_ir_sensor) {
|
if (!Settings::values.enable_ir_sensor) {
|
||||||
return;
|
return;
|
||||||
|
@ -760,18 +763,22 @@ void GRenderWindow::InitializeCamera() {
|
||||||
connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); });
|
connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); });
|
||||||
// This timer should be dependent of camera resolution 5ms for every 100 pixels
|
// This timer should be dependent of camera resolution 5ms for every 100 pixels
|
||||||
camera_timer->start(camera_update_ms);
|
camera_timer->start(camera_update_ms);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::FinalizeCamera() {
|
void GRenderWindow::FinalizeCamera() {
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
if (camera_timer) {
|
if (camera_timer) {
|
||||||
camera_timer->stop();
|
camera_timer->stop();
|
||||||
}
|
}
|
||||||
if (camera) {
|
if (camera) {
|
||||||
camera->unload();
|
camera->unload();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::RequestCameraCapture() {
|
void GRenderWindow::RequestCameraCapture() {
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
if (!Settings::values.enable_ir_sensor) {
|
if (!Settings::values.enable_ir_sensor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -788,6 +795,7 @@ void GRenderWindow::RequestCameraCapture() {
|
||||||
|
|
||||||
pending_camera_snapshots++;
|
pending_camera_snapshots++;
|
||||||
camera_capture->capture();
|
camera_capture->capture();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) {
|
void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) {
|
||||||
|
|
|
@ -241,8 +241,10 @@ private:
|
||||||
|
|
||||||
bool is_virtual_camera;
|
bool is_virtual_camera;
|
||||||
int pending_camera_snapshots;
|
int pending_camera_snapshots;
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
std::unique_ptr<QCamera> camera;
|
std::unique_ptr<QCamera> camera;
|
||||||
std::unique_ptr<QCameraImageCapture> camera_capture;
|
std::unique_ptr<QCameraImageCapture> camera_capture;
|
||||||
|
#endif
|
||||||
std::unique_ptr<QTimer> camera_timer;
|
std::unique_ptr<QTimer> camera_timer;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QtCore>
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
#include <QCameraImageCapture>
|
#include <QCameraImageCapture>
|
||||||
#include <QCameraInfo>
|
#include <QCameraInfo>
|
||||||
|
#endif
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -33,6 +36,7 @@ ConfigureCamera::ConfigureCamera(QWidget* parent, InputCommon::InputSubsystem* i
|
||||||
ConfigureCamera::~ConfigureCamera() = default;
|
ConfigureCamera::~ConfigureCamera() = default;
|
||||||
|
|
||||||
void ConfigureCamera::PreviewCamera() {
|
void ConfigureCamera::PreviewCamera() {
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
const auto index = ui->ir_sensor_combo_box->currentIndex();
|
const auto index = ui->ir_sensor_combo_box->currentIndex();
|
||||||
bool camera_found = false;
|
bool camera_found = false;
|
||||||
const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
const QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
||||||
|
@ -101,6 +105,7 @@ void ConfigureCamera::PreviewCamera() {
|
||||||
});
|
});
|
||||||
|
|
||||||
camera_timer->start(250);
|
camera_timer->start(250);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureCamera::DisplayCapturedFrame(int requestId, const QImage& img) {
|
void ConfigureCamera::DisplayCapturedFrame(int requestId, const QImage& img) {
|
||||||
|
@ -133,11 +138,13 @@ void ConfigureCamera::LoadConfiguration() {
|
||||||
ui->ir_sensor_combo_box->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"));
|
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();
|
const auto cameras = QCameraInfo::availableCameras();
|
||||||
for (const QCameraInfo& cameraInfo : cameras) {
|
for (const QCameraInfo& cameraInfo : cameras) {
|
||||||
input_devices.push_back(cameraInfo.deviceName().toStdString());
|
input_devices.push_back(cameraInfo.deviceName().toStdString());
|
||||||
ui->ir_sensor_combo_box->addItem(cameraInfo.description());
|
ui->ir_sensor_combo_box->addItem(cameraInfo.description());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto current_device = Settings::values.ir_sensor_device.GetValue();
|
const auto current_device = Settings::values.ir_sensor_device.GetValue();
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,10 @@ private:
|
||||||
|
|
||||||
bool is_virtual_camera;
|
bool is_virtual_camera;
|
||||||
int pending_snapshots;
|
int pending_snapshots;
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
|
||||||
std::unique_ptr<QCamera> camera;
|
std::unique_ptr<QCamera> camera;
|
||||||
std::unique_ptr<QCameraImageCapture> camera_capture;
|
std::unique_ptr<QCameraImageCapture> camera_capture;
|
||||||
|
#endif
|
||||||
std::unique_ptr<QTimer> camera_timer;
|
std::unique_ptr<QTimer> camera_timer;
|
||||||
std::vector<std::string> input_devices;
|
std::vector<std::string> input_devices;
|
||||||
std::unique_ptr<Ui::ConfigureCamera> ui;
|
std::unique_ptr<Ui::ConfigureCamera> ui;
|
||||||
|
|
|
@ -194,4 +194,8 @@ void ConfigureInputAdvanced::UpdateUIEnabled() {
|
||||||
ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked());
|
ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked());
|
||||||
ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked());
|
ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked());
|
||||||
ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->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)
|
||||||
|
ui->enable_ir_sensor->setEnabled(false);
|
||||||
|
ui->camera_configure->setEnabled(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -4194,10 +4194,12 @@ int main(int argc, char* argv[]) {
|
||||||
// so we can see if we get \u3008 instead
|
// so we can see if we get \u3008 instead
|
||||||
// TL;DR all other number formats are consecutive in unicode code points
|
// TL;DR all other number formats are consecutive in unicode code points
|
||||||
// This bug is fixed in Qt6, specifically 6.0.0-alpha1
|
// This bug is fixed in Qt6, specifically 6.0.0-alpha1
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
const QLocale locale = QLocale::system();
|
const QLocale locale = QLocale::system();
|
||||||
if (QStringLiteral("\u3008") == locale.toString(1)) {
|
if (QStringLiteral("\u3008") == locale.toString(1)) {
|
||||||
QLocale::setDefault(QLocale::system().name());
|
QLocale::setDefault(QLocale::system().name());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Qt changes the locale and causes issues in float conversion using std::to_string() when
|
// Qt changes the locale and causes issues in float conversion using std::to_string() when
|
||||||
// generating shaders
|
// generating shaders
|
||||||
|
|
Loading…
Reference in a new issue