diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/input_common/drivers/camera.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/camera.h | 4 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.h | 3 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/input_common/drivers/camera.cpp b/src/input_common/drivers/camera.cpp index dceea67e0..fad9177dc 100644 --- a/src/input_common/drivers/camera.cpp +++ b/src/input_common/drivers/camera.cpp | |||
| @@ -17,7 +17,7 @@ Camera::Camera(std::string input_engine_) : InputEngine(std::move(input_engine_) | |||
| 17 | PreSetController(identifier); | 17 | PreSetController(identifier); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | void Camera::SetCameraData(std::size_t width, std::size_t height, std::vector<u32> data) { | 20 | void Camera::SetCameraData(std::size_t width, std::size_t height, std::span<const u32> data) { |
| 21 | const std::size_t desired_width = getImageWidth(); | 21 | const std::size_t desired_width = getImageWidth(); |
| 22 | const std::size_t desired_height = getImageHeight(); | 22 | const std::size_t desired_height = getImageHeight(); |
| 23 | status.data.resize(desired_width * desired_height); | 23 | status.data.resize(desired_width * desired_height); |
diff --git a/src/input_common/drivers/camera.h b/src/input_common/drivers/camera.h index b8a7c75e5..38fb1ae4c 100644 --- a/src/input_common/drivers/camera.h +++ b/src/input_common/drivers/camera.h | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <span> | ||
| 7 | |||
| 6 | #include "input_common/input_engine.h" | 8 | #include "input_common/input_engine.h" |
| 7 | 9 | ||
| 8 | namespace InputCommon { | 10 | namespace InputCommon { |
| @@ -15,7 +17,7 @@ class Camera final : public InputEngine { | |||
| 15 | public: | 17 | public: |
| 16 | explicit Camera(std::string input_engine_); | 18 | explicit Camera(std::string input_engine_); |
| 17 | 19 | ||
| 18 | void SetCameraData(std::size_t width, std::size_t height, std::vector<u32> data); | 20 | void SetCameraData(std::size_t width, std::size_t height, std::span<const u32> data); |
| 19 | 21 | ||
| 20 | std::size_t getImageWidth() const; | 22 | std::size_t getImageWidth() const; |
| 21 | std::size_t getImageHeight() const; | 23 | std::size_t getImageHeight() const; |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 642f96690..6afbdaf12 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -757,6 +757,7 @@ void GRenderWindow::InitializeCamera() { | |||
| 757 | return; | 757 | return; |
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | camera_data.resize(CAMERA_WIDTH * CAMERA_HEIGHT); | ||
| 760 | camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); | 761 | camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); |
| 761 | connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, | 762 | connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, |
| 762 | &GRenderWindow::OnCameraCapture); | 763 | &GRenderWindow::OnCameraCapture); |
| @@ -812,16 +813,13 @@ void GRenderWindow::RequestCameraCapture() { | |||
| 812 | } | 813 | } |
| 813 | 814 | ||
| 814 | void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { | 815 | void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { |
| 815 | constexpr std::size_t camera_width = 320; | 816 | // TODO: Capture directly in the format and resolution needed |
| 816 | constexpr std::size_t camera_height = 240; | ||
| 817 | const auto converted = | 817 | const auto converted = |
| 818 | img.scaled(camera_width, camera_height, Qt::AspectRatioMode::IgnoreAspectRatio, | 818 | img.scaled(CAMERA_WIDTH, CAMERA_HEIGHT, Qt::AspectRatioMode::IgnoreAspectRatio, |
| 819 | Qt::TransformationMode::SmoothTransformation) | 819 | Qt::TransformationMode::SmoothTransformation) |
| 820 | .mirrored(false, true); | 820 | .mirrored(false, true); |
| 821 | std::vector<u32> camera_data{}; | 821 | std::memcpy(camera_data.data(), converted.bits(), CAMERA_WIDTH * CAMERA_HEIGHT * sizeof(u32)); |
| 822 | camera_data.resize(camera_width * camera_height); | 822 | input_subsystem->GetCamera()->SetCameraData(CAMERA_WIDTH, CAMERA_HEIGHT, camera_data); |
| 823 | std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32)); | ||
| 824 | input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data); | ||
| 825 | pending_camera_snapshots = 0; | 823 | pending_camera_snapshots = 0; |
| 826 | } | 824 | } |
| 827 | 825 | ||
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index f0edad6e4..5bbcf61f7 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -247,6 +247,9 @@ private: | |||
| 247 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA | 247 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA |
| 248 | std::unique_ptr<QCamera> camera; | 248 | std::unique_ptr<QCamera> camera; |
| 249 | std::unique_ptr<QCameraImageCapture> camera_capture; | 249 | std::unique_ptr<QCameraImageCapture> camera_capture; |
| 250 | static constexpr std::size_t CAMERA_WIDTH = 320; | ||
| 251 | static constexpr std::size_t CAMERA_HEIGHT = 240; | ||
| 252 | std::vector<u32> camera_data; | ||
| 250 | #endif | 253 | #endif |
| 251 | std::unique_ptr<QTimer> camera_timer; | 254 | std::unique_ptr<QTimer> camera_timer; |
| 252 | 255 | ||