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 1a47fb9c9..09959d154 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -752,6 +752,7 @@ void GRenderWindow::InitializeCamera() { | |||
| 752 | return; | 752 | return; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | camera_data.resize(CAMERA_WIDTH * CAMERA_HEIGHT); | ||
| 755 | camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); | 756 | camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer); |
| 756 | connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, | 757 | connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, |
| 757 | &GRenderWindow::OnCameraCapture); | 758 | &GRenderWindow::OnCameraCapture); |
| @@ -807,16 +808,13 @@ void GRenderWindow::RequestCameraCapture() { | |||
| 807 | } | 808 | } |
| 808 | 809 | ||
| 809 | void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { | 810 | void GRenderWindow::OnCameraCapture(int requestId, const QImage& img) { |
| 810 | constexpr std::size_t camera_width = 320; | 811 | // TODO: Capture directly in the format and resolution needed |
| 811 | constexpr std::size_t camera_height = 240; | ||
| 812 | const auto converted = | 812 | const auto converted = |
| 813 | img.scaled(camera_width, camera_height, Qt::AspectRatioMode::IgnoreAspectRatio, | 813 | img.scaled(CAMERA_WIDTH, CAMERA_HEIGHT, Qt::AspectRatioMode::IgnoreAspectRatio, |
| 814 | Qt::TransformationMode::SmoothTransformation) | 814 | Qt::TransformationMode::SmoothTransformation) |
| 815 | .mirrored(false, true); | 815 | .mirrored(false, true); |
| 816 | std::vector<u32> camera_data{}; | 816 | std::memcpy(camera_data.data(), converted.bits(), CAMERA_WIDTH * CAMERA_HEIGHT * sizeof(u32)); |
| 817 | camera_data.resize(camera_width * camera_height); | 817 | input_subsystem->GetCamera()->SetCameraData(CAMERA_WIDTH, CAMERA_HEIGHT, camera_data); |
| 818 | std::memcpy(camera_data.data(), converted.bits(), camera_width * camera_height * sizeof(u32)); | ||
| 819 | input_subsystem->GetCamera()->SetCameraData(camera_width, camera_height, camera_data); | ||
| 820 | pending_camera_snapshots = 0; | 818 | pending_camera_snapshots = 0; |
| 821 | } | 819 | } |
| 822 | 820 | ||
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index f4deae4ee..4dec2da2a 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -246,6 +246,9 @@ private: | |||
| 246 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA | 246 | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA |
| 247 | std::unique_ptr<QCamera> camera; | 247 | std::unique_ptr<QCamera> camera; |
| 248 | std::unique_ptr<QCameraImageCapture> camera_capture; | 248 | std::unique_ptr<QCameraImageCapture> camera_capture; |
| 249 | static constexpr std::size_t CAMERA_WIDTH = 320; | ||
| 250 | static constexpr std::size_t CAMERA_HEIGHT = 240; | ||
| 251 | std::vector<u32> camera_data; | ||
| 249 | #endif | 252 | #endif |
| 250 | std::unique_ptr<QTimer> camera_timer; | 253 | std::unique_ptr<QTimer> camera_timer; |
| 251 | 254 | ||