summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar german772022-12-18 00:10:20 -0600
committerGravatar german772022-12-18 00:13:18 -0600
commitf999d268f99b77e35a5f83933765de62c52d1cb1 (patch)
tree8133375ed58b43b8298c692d98f0436ccfaa4c5a
parentbootmanager: Encapsulate all QCamera code (diff)
downloadyuzu-f999d268f99b77e35a5f83933765de62c52d1cb1.tar.gz
yuzu-f999d268f99b77e35a5f83933765de62c52d1cb1.tar.xz
yuzu-f999d268f99b77e35a5f83933765de62c52d1cb1.zip
bootmanager: Use proper camera size
-rw-r--r--src/input_common/drivers/camera.h1
-rw-r--r--src/yuzu/bootmanager.cpp16
-rw-r--r--src/yuzu/bootmanager.h2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/input_common/drivers/camera.h b/src/input_common/drivers/camera.h
index 38fb1ae4c..ead3e0fde 100644
--- a/src/input_common/drivers/camera.h
+++ b/src/input_common/drivers/camera.h
@@ -25,6 +25,7 @@ public:
25 Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_, 25 Common::Input::CameraError SetCameraFormat(const PadIdentifier& identifier_,
26 Common::Input::CameraFormat camera_format) override; 26 Common::Input::CameraFormat camera_format) override;
27 27
28private:
28 Common::Input::CameraStatus status{}; 29 Common::Input::CameraStatus status{};
29}; 30};
30 31
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index ffd3f0028..1368b20d5 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -764,7 +764,9 @@ void GRenderWindow::InitializeCamera() {
764 return; 764 return;
765 } 765 }
766 766
767 camera_data.resize(CAMERA_WIDTH * CAMERA_HEIGHT); 767 const auto camera_width = input_subsystem->GetCamera()->getImageWidth();
768 const auto camera_height = input_subsystem->GetCamera()->getImageHeight();
769 camera_data.resize(camera_width * camera_height);
768 camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); 770 camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
769 connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, 771 connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
770 &GRenderWindow::OnCameraCapture); 772 &GRenderWindow::OnCameraCapture);
@@ -822,12 +824,18 @@ void GRenderWindow::RequestCameraCapture() {
822void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { 824void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) {
823#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA 825#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
824 // TODO: Capture directly in the format and resolution needed 826 // TODO: Capture directly in the format and resolution needed
827 const auto camera_width = input_subsystem->GetCamera()->getImageWidth();
828 const auto camera_height = input_subsystem->GetCamera()->getImageHeight();
825 const auto converted = 829 const auto converted =
826 img.scaled(CAMERA_WIDTH, CAMERA_HEIGHT, Qt::AspectRatioMode::IgnoreAspectRatio, 830 img.scaled(static_cast<int>(camera_width), static_cast<int>(camera_height),
831 Qt::AspectRatioMode::IgnoreAspectRatio,
827 Qt::TransformationMode::SmoothTransformation) 832 Qt::TransformationMode::SmoothTransformation)
828 .mirrored(false, true); 833 .mirrored(false, true);
829 std::memcpy(camera_data.data(), converted.bits(), CAMERA_WIDTH * CAMERA_HEIGHT * sizeof(u32)); 834 if (camera_data.size() != camera_width * camera_height) {
830 input_subsystem->GetCamera()->SetCameraData(CAMERA_WIDTH, CAMERA_HEIGHT, camera_data); 835 camera_data.resize(camera_width * camera_height);
836 }
837 std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32));
838 input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data);
831 pending_camera_snapshots = 0; 839 pending_camera_snapshots = 0;
832#endif 840#endif
833} 841}
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h
index 514437359..b24141fd9 100644
--- a/src/yuzu/bootmanager.h
+++ b/src/yuzu/bootmanager.h
@@ -243,8 +243,6 @@ private:
243 InputCommon::TasInput::TasState last_tas_state; 243 InputCommon::TasInput::TasState last_tas_state;
244 244
245#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA 245#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA
246 static constexpr std::size_t CAMERA_WIDTH = 320;
247 static constexpr std::size_t CAMERA_HEIGHT = 240;
248 bool is_virtual_camera; 246 bool is_virtual_camera;
249 int pending_camera_snapshots; 247 int pending_camera_snapshots;
250 std::vector<u32> camera_data; 248 std::vector<u32> camera_data;