mirror of https://git.suyu.dev/suyu/suyu
service: irs: Split processors and implement ImageTransferProcessor
parent
57311b2c8b
commit
4539700595
@ -0,0 +1,36 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/clustering_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
ClusteringProcessor::ClusteringProcessor(Core::IrSensor::DeviceFormat& device_format)
|
||||
: device(device_format) {
|
||||
device.mode = Core::IrSensor::IrSensorMode::ClusteringProcessor;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
ClusteringProcessor::~ClusteringProcessor() = default;
|
||||
|
||||
void ClusteringProcessor::StartProcessor() {}
|
||||
|
||||
void ClusteringProcessor::SuspendProcessor() {}
|
||||
|
||||
void ClusteringProcessor::StopProcessor() {}
|
||||
|
||||
void ClusteringProcessor::SetConfig(Core::IrSensor::PackedClusteringProcessorConfig config) {
|
||||
current_config.camera_config.exposure_time = config.camera_config.exposure_time;
|
||||
current_config.camera_config.gain = config.camera_config.gain;
|
||||
current_config.camera_config.is_negative_used = config.camera_config.is_negative_used;
|
||||
current_config.camera_config.light_target =
|
||||
static_cast<Core::IrSensor::CameraLightTarget>(config.camera_config.light_target);
|
||||
current_config.pixel_count_min = config.pixel_count_min;
|
||||
current_config.pixel_count_max = config.pixel_count_max;
|
||||
current_config.is_external_light_filter_enabled = config.is_external_light_filter_enabled;
|
||||
current_config.object_intensity_min = config.object_intensity_min;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,74 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class ClusteringProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit ClusteringProcessor(Core::IrSensor::DeviceFormat& device_format);
|
||||
~ClusteringProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedClusteringProcessorConfig config);
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::ClusteringProcessorConfig
|
||||
struct ClusteringProcessorConfig {
|
||||
Core::IrSensor::CameraConfig camera_config;
|
||||
Core::IrSensor::IrsRect window_of_interest;
|
||||
u32 pixel_count_min;
|
||||
u32 pixel_count_max;
|
||||
u32 object_intensity_min;
|
||||
bool is_external_light_filter_enabled;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
};
|
||||
static_assert(sizeof(ClusteringProcessorConfig) == 0x30,
|
||||
"ClusteringProcessorConfig is an invalid size");
|
||||
|
||||
// This is nn::irsensor::AdaptiveClusteringProcessorConfig
|
||||
struct AdaptiveClusteringProcessorConfig {
|
||||
Core::IrSensor::AdaptiveClusteringMode mode;
|
||||
Core::IrSensor::AdaptiveClusteringTargetDistance target_distance;
|
||||
};
|
||||
static_assert(sizeof(AdaptiveClusteringProcessorConfig) == 0x8,
|
||||
"AdaptiveClusteringProcessorConfig is an invalid size");
|
||||
|
||||
// This is nn::irsensor::ClusteringData
|
||||
struct ClusteringData {
|
||||
f32 average_intensity;
|
||||
Core::IrSensor::IrsCentroid centroid;
|
||||
u32 pixel_count;
|
||||
Core::IrSensor::IrsRect bound;
|
||||
};
|
||||
static_assert(sizeof(ClusteringData) == 0x18, "ClusteringData is an invalid size");
|
||||
|
||||
// This is nn::irsensor::ClusteringProcessorState
|
||||
struct ClusteringProcessorState {
|
||||
s64 sampling_number;
|
||||
u64 timestamp;
|
||||
u8 object_count;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
Core::IrSensor::CameraAmbientNoiseLevel ambient_noise_level;
|
||||
std::array<ClusteringData, 0x10> data;
|
||||
};
|
||||
static_assert(sizeof(ClusteringProcessorState) == 0x198,
|
||||
"ClusteringProcessorState is an invalid size");
|
||||
|
||||
ClusteringProcessorConfig current_config{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
};
|
||||
} // namespace Service::HID
|
@ -0,0 +1,154 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/hid_core.h"
|
||||
#include "core/hle/service/hid/irsensor/image_transfer_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
ImageTransferProcessor::ImageTransferProcessor(Core::HID::HIDCore& hid_core_,
|
||||
Core::IrSensor::DeviceFormat& device_format,
|
||||
std::size_t npad_index)
|
||||
: device{device_format} {
|
||||
npad_device = hid_core_.GetEmulatedControllerByIndex(npad_index);
|
||||
|
||||
Core::HID::ControllerUpdateCallback engine_callback{
|
||||
.on_change = [this](Core::HID::ControllerTriggerType type) { OnControllerUpdate(type); },
|
||||
.is_npad_service = true,
|
||||
};
|
||||
callback_key = npad_device->SetCallback(engine_callback);
|
||||
|
||||
device.mode = Core::IrSensor::IrSensorMode::ImageTransferProcessor;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
ImageTransferProcessor::~ImageTransferProcessor() {
|
||||
npad_device->DeleteCallback(callback_key);
|
||||
};
|
||||
|
||||
void ImageTransferProcessor::StartProcessor() {
|
||||
is_active = true;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Available;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Ready;
|
||||
device.state.start = 0;
|
||||
device.state.count = 1;
|
||||
processor_state.sampling_number = 0;
|
||||
processor_state.ambient_noise_level = Core::IrSensor::CameraAmbientNoiseLevel::Low;
|
||||
}
|
||||
|
||||
void ImageTransferProcessor::SuspendProcessor() {}
|
||||
|
||||
void ImageTransferProcessor::StopProcessor() {}
|
||||
|
||||
void ImageTransferProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType type) {
|
||||
if (type != Core::HID::ControllerTriggerType::IrSensor) {
|
||||
return;
|
||||
}
|
||||
if (!is_transfer_memory_set) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto camera_data = npad_device->GetCamera();
|
||||
|
||||
// This indicates how much ambient light is precent
|
||||
processor_state.ambient_noise_level = Core::IrSensor::CameraAmbientNoiseLevel::Low;
|
||||
processor_state.sampling_number = camera_data.sample;
|
||||
|
||||
if (camera_data.format != current_config.origin_format) {
|
||||
LOG_WARNING(Service_IRS, "Wrong Input format {} expected {}", camera_data.format,
|
||||
current_config.origin_format);
|
||||
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format));
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_config.origin_format > current_config.trimming_format) {
|
||||
LOG_WARNING(Service_IRS, "Origin format {} is smaller than trimming format {}",
|
||||
current_config.origin_format, current_config.trimming_format);
|
||||
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<u8> window_data{};
|
||||
const auto origin_width = GetDataWidth(current_config.origin_format);
|
||||
const auto origin_height = GetDataHeight(current_config.origin_format);
|
||||
const auto trimming_width = GetDataWidth(current_config.trimming_format);
|
||||
const auto trimming_height = GetDataHeight(current_config.trimming_format);
|
||||
window_data.resize(GetDataSize(current_config.trimming_format));
|
||||
|
||||
if (trimming_width + current_config.trimming_start_x > origin_width ||
|
||||
trimming_height + current_config.trimming_start_y > origin_height) {
|
||||
LOG_WARNING(Service_IRS,
|
||||
"Trimming area ({}, {}, {}, {}) is outside of origin area ({}, {})",
|
||||
current_config.trimming_start_x, current_config.trimming_start_y,
|
||||
trimming_width, trimming_height, origin_width, origin_height);
|
||||
memset(transfer_memory, 0, GetDataSize(current_config.trimming_format));
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::size_t y = 0; y < trimming_height; y++) {
|
||||
for (std::size_t x = 0; x < trimming_width; x++) {
|
||||
const std::size_t window_index = (y * trimming_width) + x;
|
||||
const std::size_t origin_index =
|
||||
((y + current_config.trimming_start_y) * origin_width) + x +
|
||||
current_config.trimming_start_x;
|
||||
window_data[window_index] = camera_data.data[origin_index];
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(transfer_memory, window_data.data(), GetDataSize(current_config.trimming_format));
|
||||
|
||||
if (!IsProcessorActive()) {
|
||||
StartProcessor();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageTransferProcessor::SetConfig(Core::IrSensor::PackedImageTransferProcessorConfig config) {
|
||||
current_config.camera_config.exposure_time = config.camera_config.exposure_time;
|
||||
current_config.camera_config.gain = config.camera_config.gain;
|
||||
current_config.camera_config.is_negative_used = config.camera_config.is_negative_used;
|
||||
current_config.camera_config.light_target =
|
||||
static_cast<Core::IrSensor::CameraLightTarget>(config.camera_config.light_target);
|
||||
current_config.origin_format =
|
||||
static_cast<Core::IrSensor::ImageTransferProcessorFormat>(config.format);
|
||||
current_config.trimming_format =
|
||||
static_cast<Core::IrSensor::ImageTransferProcessorFormat>(config.format);
|
||||
current_config.trimming_start_x = 0;
|
||||
current_config.trimming_start_y = 0;
|
||||
|
||||
npad_device->SetCameraFormat(current_config.origin_format);
|
||||
}
|
||||
|
||||
void ImageTransferProcessor::SetConfig(
|
||||
Core::IrSensor::PackedImageTransferProcessorExConfig config) {
|
||||
current_config.camera_config.exposure_time = config.camera_config.exposure_time;
|
||||
current_config.camera_config.gain = config.camera_config.gain;
|
||||
current_config.camera_config.is_negative_used = config.camera_config.is_negative_used;
|
||||
current_config.camera_config.light_target =
|
||||
static_cast<Core::IrSensor::CameraLightTarget>(config.camera_config.light_target);
|
||||
current_config.origin_format =
|
||||
static_cast<Core::IrSensor::ImageTransferProcessorFormat>(config.origin_format);
|
||||
current_config.trimming_format =
|
||||
static_cast<Core::IrSensor::ImageTransferProcessorFormat>(config.trimming_format);
|
||||
current_config.trimming_start_x = config.trimming_start_x;
|
||||
current_config.trimming_start_y = config.trimming_start_y;
|
||||
|
||||
npad_device->SetCameraFormat(current_config.origin_format);
|
||||
}
|
||||
|
||||
void ImageTransferProcessor::SetTransferMemoryPointer(u8* t_mem) {
|
||||
is_transfer_memory_set = true;
|
||||
transfer_memory = t_mem;
|
||||
}
|
||||
|
||||
Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState(
|
||||
std::vector<u8>& data) const {
|
||||
const auto size = GetDataSize(current_config.trimming_format);
|
||||
data.resize(size);
|
||||
memcpy(data.data(), transfer_memory, size);
|
||||
return processor_state;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,73 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Core::HID {
|
||||
class EmulatedController;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Service::HID {
|
||||
class ImageTransferProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit ImageTransferProcessor(Core::HID::HIDCore& hid_core_,
|
||||
Core::IrSensor::DeviceFormat& device_format,
|
||||
std::size_t npad_index);
|
||||
~ImageTransferProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedImageTransferProcessorConfig config);
|
||||
void SetConfig(Core::IrSensor::PackedImageTransferProcessorExConfig config);
|
||||
|
||||
// Transfer memory where the image data will be stored
|
||||
void SetTransferMemoryPointer(u8* t_mem);
|
||||
|
||||
Core::IrSensor::ImageTransferProcessorState GetState(std::vector<u8>& data) const;
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::ImageTransferProcessorConfig
|
||||
struct ImageTransferProcessorConfig {
|
||||
Core::IrSensor::CameraConfig camera_config;
|
||||
Core::IrSensor::ImageTransferProcessorFormat format;
|
||||
};
|
||||
static_assert(sizeof(ImageTransferProcessorConfig) == 0x20,
|
||||
"ImageTransferProcessorConfig is an invalid size");
|
||||
|
||||
// This is nn::irsensor::ImageTransferProcessorExConfig
|
||||
struct ImageTransferProcessorExConfig {
|
||||
Core::IrSensor::CameraConfig camera_config;
|
||||
Core::IrSensor::ImageTransferProcessorFormat origin_format;
|
||||
Core::IrSensor::ImageTransferProcessorFormat trimming_format;
|
||||
u16 trimming_start_x;
|
||||
u16 trimming_start_y;
|
||||
bool is_external_light_filter_enabled;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
};
|
||||
static_assert(sizeof(ImageTransferProcessorExConfig) == 0x28,
|
||||
"ImageTransferProcessorExConfig is an invalid size");
|
||||
|
||||
void OnControllerUpdate(Core::HID::ControllerTriggerType type);
|
||||
|
||||
ImageTransferProcessorExConfig current_config{};
|
||||
Core::IrSensor::ImageTransferProcessorState processor_state{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
Core::HID::EmulatedController* npad_device;
|
||||
int callback_key{};
|
||||
|
||||
u8* transfer_memory = nullptr;
|
||||
bool is_transfer_memory_set = false;
|
||||
};
|
||||
} // namespace Service::HID
|
@ -0,0 +1,29 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/ir_led_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
IrLedProcessor::IrLedProcessor(Core::IrSensor::DeviceFormat& device_format)
|
||||
: device(device_format) {
|
||||
device.mode = Core::IrSensor::IrSensorMode::IrLedProcessor;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
IrLedProcessor::~IrLedProcessor() = default;
|
||||
|
||||
void IrLedProcessor::StartProcessor() {}
|
||||
|
||||
void IrLedProcessor::SuspendProcessor() {}
|
||||
|
||||
void IrLedProcessor::StopProcessor() {}
|
||||
|
||||
void IrLedProcessor::SetConfig(Core::IrSensor::PackedIrLedProcessorConfig config) {
|
||||
current_config.light_target =
|
||||
static_cast<Core::IrSensor::CameraLightTarget>(config.light_target);
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,47 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class IrLedProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit IrLedProcessor(Core::IrSensor::DeviceFormat& device_format);
|
||||
~IrLedProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedIrLedProcessorConfig config);
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::IrLedProcessorConfig
|
||||
struct IrLedProcessorConfig {
|
||||
Core::IrSensor::CameraLightTarget light_target;
|
||||
};
|
||||
static_assert(sizeof(IrLedProcessorConfig) == 0x4, "IrLedProcessorConfig is an invalid size");
|
||||
|
||||
struct IrLedProcessorState {
|
||||
s64 sampling_number;
|
||||
u64 timestamp;
|
||||
std::array<u8, 0x8> data;
|
||||
};
|
||||
static_assert(sizeof(IrLedProcessorState) == 0x18, "IrLedProcessorState is an invalid size");
|
||||
|
||||
IrLedProcessorConfig current_config{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
};
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,36 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/moment_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
MomentProcessor::MomentProcessor(Core::IrSensor::DeviceFormat& device_format)
|
||||
: device(device_format) {
|
||||
device.mode = Core::IrSensor::IrSensorMode::MomentProcessor;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
MomentProcessor::~MomentProcessor() = default;
|
||||
|
||||
void MomentProcessor::StartProcessor() {}
|
||||
|
||||
void MomentProcessor::SuspendProcessor() {}
|
||||
|
||||
void MomentProcessor::StopProcessor() {}
|
||||
|
||||
void MomentProcessor::SetConfig(Core::IrSensor::PackedMomentProcessorConfig config) {
|
||||
current_config.camera_config.exposure_time = config.camera_config.exposure_time;
|
||||
current_config.camera_config.gain = config.camera_config.gain;
|
||||
current_config.camera_config.is_negative_used = config.camera_config.is_negative_used;
|
||||
current_config.camera_config.light_target =
|
||||
static_cast<Core::IrSensor::CameraLightTarget>(config.camera_config.light_target);
|
||||
current_config.window_of_interest = config.window_of_interest;
|
||||
current_config.preprocess =
|
||||
static_cast<Core::IrSensor::MomentProcessorPreprocess>(config.preprocess);
|
||||
current_config.preprocess_intensity_threshold = config.preprocess_intensity_threshold;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,61 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class MomentProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit MomentProcessor(Core::IrSensor::DeviceFormat& device_format);
|
||||
~MomentProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedMomentProcessorConfig config);
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::MomentProcessorConfig
|
||||
struct MomentProcessorConfig {
|
||||
Core::IrSensor::CameraConfig camera_config;
|
||||
Core::IrSensor::IrsRect window_of_interest;
|
||||
Core::IrSensor::MomentProcessorPreprocess preprocess;
|
||||
u32 preprocess_intensity_threshold;
|
||||
};
|
||||
static_assert(sizeof(MomentProcessorConfig) == 0x28,
|
||||
"MomentProcessorConfig is an invalid size");
|
||||
|
||||
// This is nn::irsensor::MomentStatistic
|
||||
struct MomentStatistic {
|
||||
f32 average_intensity;
|
||||
Core::IrSensor::IrsCentroid centroid;
|
||||
};
|
||||
static_assert(sizeof(MomentStatistic) == 0xC, "MomentStatistic is an invalid size");
|
||||
|
||||
// This is nn::irsensor::MomentProcessorState
|
||||
struct MomentProcessorState {
|
||||
s64 sampling_number;
|
||||
u64 timestamp;
|
||||
Core::IrSensor::CameraAmbientNoiseLevel ambient_noise_level;
|
||||
INSERT_PADDING_BYTES(4);
|
||||
std::array<MomentStatistic, 0x30> stadistic;
|
||||
};
|
||||
static_assert(sizeof(MomentProcessorState) == 0x258, "MomentProcessorState is an invalid size");
|
||||
|
||||
MomentProcessorConfig current_config{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
};
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,28 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/pointing_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
PointingProcessor::PointingProcessor(Core::IrSensor::DeviceFormat& device_format)
|
||||
: device(device_format) {
|
||||
device.mode = Core::IrSensor::IrSensorMode::PointingProcessorMarker;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
PointingProcessor::~PointingProcessor() = default;
|
||||
|
||||
void PointingProcessor::StartProcessor() {}
|
||||
|
||||
void PointingProcessor::SuspendProcessor() {}
|
||||
|
||||
void PointingProcessor::StopProcessor() {}
|
||||
|
||||
void PointingProcessor::SetConfig(Core::IrSensor::PackedPointingProcessorConfig config) {
|
||||
current_config.window_of_interest = config.window_of_interest;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,62 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class PointingProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit PointingProcessor(Core::IrSensor::DeviceFormat& device_format);
|
||||
~PointingProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedPointingProcessorConfig config);
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::PointingProcessorConfig
|
||||
struct PointingProcessorConfig {
|
||||
Core::IrSensor::IrsRect window_of_interest;
|
||||
};
|
||||
static_assert(sizeof(PointingProcessorConfig) == 0x8,
|
||||
"PointingProcessorConfig is an invalid size");
|
||||
|
||||
struct PointingProcessorMarkerData {
|
||||
u8 pointing_status;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
u32 unknown;
|
||||
float unkown_float1;
|
||||
float position_x;
|
||||
float position_y;
|
||||
float unkown_float2;
|
||||
Core::IrSensor::IrsRect window_of_interest;
|
||||
};
|
||||
static_assert(sizeof(PointingProcessorMarkerData) == 0x20,
|
||||
"PointingProcessorMarkerData is an invalid size");
|
||||
|
||||
struct PointingProcessorMarkerState {
|
||||
s64 sampling_number;
|
||||
u64 timestamp;
|
||||
std::array<PointingProcessorMarkerData, 0x3> data;
|
||||
};
|
||||
static_assert(sizeof(PointingProcessorMarkerState) == 0x70,
|
||||
"PointingProcessorMarkerState is an invalid size");
|
||||
|
||||
PointingProcessorConfig current_config{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
};
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,67 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
ProcessorBase::ProcessorBase() {}
|
||||
ProcessorBase::~ProcessorBase() = default;
|
||||
|
||||
bool ProcessorBase::IsProcessorActive() const {
|
||||
return is_active;
|
||||
}
|
||||
|
||||
std::size_t ProcessorBase::GetDataSize(Core::IrSensor::ImageTransferProcessorFormat format) const {
|
||||
switch (format) {
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size320x240:
|
||||
return 320 * 240;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size160x120:
|
||||
return 160 * 120;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size80x60:
|
||||
return 80 * 60;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size40x30:
|
||||
return 40 * 30;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size20x15:
|
||||
return 20 * 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t ProcessorBase::GetDataWidth(Core::IrSensor::ImageTransferProcessorFormat format) const {
|
||||
switch (format) {
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size320x240:
|
||||
return 320;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size160x120:
|
||||
return 160;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size80x60:
|
||||
return 80;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size40x30:
|
||||
return 40;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size20x15:
|
||||
return 20;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t ProcessorBase::GetDataHeight(
|
||||
Core::IrSensor::ImageTransferProcessorFormat format) const {
|
||||
switch (format) {
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size320x240:
|
||||
return 240;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size160x120:
|
||||
return 120;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size80x60:
|
||||
return 60;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size40x30:
|
||||
return 30;
|
||||
case Core::IrSensor::ImageTransferProcessorFormat::Size20x15:
|
||||
return 15;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,33 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class ProcessorBase {
|
||||
public:
|
||||
explicit ProcessorBase();
|
||||
virtual ~ProcessorBase();
|
||||
|
||||
virtual void StartProcessor() = 0;
|
||||
virtual void SuspendProcessor() = 0;
|
||||
virtual void StopProcessor() = 0;
|
||||
|
||||
bool IsProcessorActive() const;
|
||||
|
||||
protected:
|
||||
/// Returns the number of bytes the image uses
|
||||
std::size_t GetDataSize(Core::IrSensor::ImageTransferProcessorFormat format) const;
|
||||
|
||||
/// Returns the width of the image
|
||||
std::size_t GetDataWidth(Core::IrSensor::ImageTransferProcessorFormat format) const;
|
||||
|
||||
/// Returns the height of the image
|
||||
std::size_t GetDataHeight(Core::IrSensor::ImageTransferProcessorFormat format) const;
|
||||
|
||||
bool is_active{false};
|
||||
};
|
||||
} // namespace Service::HID
|
@ -0,0 +1,31 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "core/hle/service/hid/irsensor/tera_plugin_processor.h"
|
||||
|
||||
namespace Service::HID {
|
||||
TeraPluginProcessor::TeraPluginProcessor(Core::IrSensor::DeviceFormat& device_format)
|
||||
: device(device_format) {
|
||||
device.mode = Core::IrSensor::IrSensorMode::TeraPluginProcessor;
|
||||
device.camera_status = Core::IrSensor::IrCameraStatus::Unconnected;
|
||||
device.camera_internal_status = Core::IrSensor::IrCameraInternalStatus::Stopped;
|
||||
device.state.start = 0;
|
||||
device.state.count = 0;
|
||||
}
|
||||
|
||||
TeraPluginProcessor::~TeraPluginProcessor() = default;
|
||||
|
||||
void TeraPluginProcessor::StartProcessor() {}
|
||||
|
||||
void TeraPluginProcessor::SuspendProcessor() {}
|
||||
|
||||
void TeraPluginProcessor::StopProcessor() {}
|
||||
|
||||
void TeraPluginProcessor::SetConfig(Core::IrSensor::PackedTeraPluginProcessorConfig config) {
|
||||
current_config.mode = config.mode;
|
||||
current_config.unknown_1 = config.unknown_1;
|
||||
current_config.unknown_2 = config.unknown_2;
|
||||
current_config.unknown_3 = config.unknown_3;
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
@ -0,0 +1,53 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hid/irs_types.h"
|
||||
#include "core/hle/service/hid/irsensor/processor_base.h"
|
||||
|
||||
namespace Service::HID {
|
||||
class TeraPluginProcessor final : public ProcessorBase {
|
||||
public:
|
||||
explicit TeraPluginProcessor(Core::IrSensor::DeviceFormat& device_format);
|
||||
~TeraPluginProcessor() override;
|
||||
|
||||
// Called when the processor is initialized
|
||||
void StartProcessor() override;
|
||||
|
||||
// Called when the processor is suspended
|
||||
void SuspendProcessor() override;
|
||||
|
||||
// Called when the processor is stopped
|
||||
void StopProcessor() override;
|
||||
|
||||
// Sets config parameters of the camera
|
||||
void SetConfig(Core::IrSensor::PackedTeraPluginProcessorConfig config);
|
||||
|
||||
private:
|
||||
// This is nn::irsensor::TeraPluginProcessorConfig
|
||||
struct TeraPluginProcessorConfig {
|
||||
u8 mode;
|
||||
u8 unknown_1;
|
||||
u8 unknown_2;
|
||||
u8 unknown_3;
|
||||
};
|
||||
static_assert(sizeof(TeraPluginProcessorConfig) == 0x4,
|
||||
"TeraPluginProcessorConfig is an invalid size");
|
||||
|
||||
struct TeraPluginProcessorState {
|
||||
s64 sampling_number;
|
||||
u64 timestamp;
|
||||
Core::IrSensor::CameraAmbientNoiseLevel ambient_noise_level;
|
||||
std::array<u8, 0x12c> data;
|
||||
};
|
||||
static_assert(sizeof(TeraPluginProcessorState) == 0x140,
|
||||
"TeraPluginProcessorState is an invalid size");
|
||||
|
||||
TeraPluginProcessorConfig current_config{};
|
||||
Core::IrSensor::DeviceFormat& device;
|
||||
};
|
||||
|
||||
} // namespace Service::HID
|
Loading…
Reference in New Issue