VERY experimental Nintendo Switch 2 emulator
C++
service: irs: Move to IRS namespace and minor fixes
german77cd16f9801a4a
diff --git a/CMakeModules/CopyYuzuQt5Deps.cmake b/CMakeModules/CopyYuzuQt5Deps.cmakeindex 4702a504c6..6c5044caa7 100644--- a/CMakeModules/CopyYuzuQt5Deps.cmake+++ b/CMakeModules/CopyYuzuQt5Deps.cmake@@ -25,6 +25,7 @@ function(copy_yuzu_Qt5_deps target_dir)Qt5Gui$<$<CONFIG:Debug>:d>.*Qt5Widgets$<$<CONFIG:Debug>:d>.*Qt5Multimedia$<$<CONFIG:Debug>:d>.*+ Qt5Network$<$<CONFIG:Debug>:d>.*)if (YUZU_USE_QT_WEB_ENGINE)diff --git a/src/core/hid/irs_types.h b/src/core/hid/irs_types.hindex c73d008a07..88c5b016d4 100644--- a/src/core/hid/irs_types.h+++ b/src/core/hid/irs_types.h@@ -201,11 +201,11 @@ struct PackedClusteringProcessorConfig {PackedMcuVersion required_mcu_version;u32 pixel_count_min;u32 pixel_count_max;- u32 object_intensity_min;+ u8 object_intensity_min;bool is_external_light_filter_enabled;INSERT_PADDING_BYTES(2);};-static_assert(sizeof(PackedClusteringProcessorConfig) == 0x30,+static_assert(sizeof(PackedClusteringProcessorConfig) == 0x28,"PackedClusteringProcessorConfig is an invalid size");// This is nn::irsensor::PackedImageTransferProcessorConfig@@ -273,12 +273,9 @@ struct HandAnalysisConfig {};static_assert(sizeof(HandAnalysisConfig) == 0x4, "HandAnalysisConfig is an invalid size");-// This is nn::irsensor::detail::ProcessorState+// This is nn::irsensor::detail::ProcessorState contents are different for each processorstruct ProcessorState {- u64 start{};- u32 count{};- INSERT_PADDING_BYTES(4);- std::array<u8, 0xE10> processor_raw_data{};+ std::array<u8, 0xE20> processor_raw_data{};};static_assert(sizeof(ProcessorState) == 0xE20, "ProcessorState is an invalid size");diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.hindex 1bd62461cc..accc2b646c 100644--- a/src/core/hle/service/hid/errors.h+++ b/src/core/hle/service/hid/errors.h@@ -18,7 +18,11 @@ constexpr Result NpadIsSameType{ErrorModule::HID, 602};constexpr Result InvalidNpadId{ErrorModule::HID, 709};constexpr Result NpadNotConnected{ErrorModule::HID, 710};+} // namespace Service::HID++namespace Service::IRS {+constexpr ResultCode InvalidProcessorState{ErrorModule::Irsensor, 78};constexpr ResultCode InvalidIrCameraHandle{ErrorModule::Irsensor, 204};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cppindex 89bb124429..5ecbddf94d 100644--- a/src/core/hle/service/hid/hid.cpp+++ b/src/core/hle/service/hid/hid.cpp@@ -2345,8 +2345,8 @@ void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& systemstd::make_shared<HidSys>(system)->InstallAsService(service_manager);std::make_shared<HidTmp>(system)->InstallAsService(service_manager);- std::make_shared<IRS>(system)->InstallAsService(service_manager);- std::make_shared<IRS_SYS>(system)->InstallAsService(service_manager);+ std::make_shared<Service::IRS::IRS>(system)->InstallAsService(service_manager);+ std::make_shared<Service::IRS::IRS_SYS>(system)->InstallAsService(service_manager);std::make_shared<XCD_SYS>(system)->InstallAsService(service_manager);}diff --git a/src/core/hle/service/hid/irs.cpp b/src/core/hle/service/hid/irs.cppindex 53a31df79c..b6e7c07922 100644--- a/src/core/hle/service/hid/irs.cpp+++ b/src/core/hle/service/hid/irs.cpp@@ -22,7 +22,7 @@#include "core/hle/service/hid/irsensor/tera_plugin_processor.h"#include "core/memory.h"-namespace Service::HID {+namespace Service::IRS {IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {// clang-format off@@ -60,7 +60,7 @@ void IRS::ActivateIrsensor(Kernel::HLERequestContext& ctx) {IPC::RequestParser rp{ctx};const auto applet_resource_user_id{rp.Pop<u64>()};- LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",+ LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",applet_resource_user_id);IPC::ResponseBuilder rb{ctx, 2};@@ -71,7 +71,7 @@ void IRS::DeactivateIrsensor(Kernel::HLERequestContext& ctx) {IPC::RequestParser rp{ctx};const auto applet_resource_user_id{rp.Pop<u64>()};- LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",+ LOG_WARNING(Service_IRS, "(STUBBED) called, applet_resource_user_id={}",applet_resource_user_id);IPC::ResponseBuilder rb{ctx, 2};@@ -153,7 +153,7 @@ void IRS::RunClusteringProcessor(Kernel::HLERequestContext& ctx) {u64 applet_resource_user_id;Core::IrSensor::PackedClusteringProcessorConfig processor_config;};- static_assert(sizeof(Parameters) == 0x40, "Parameters has incorrect size.");+ static_assert(sizeof(Parameters) == 0x38, "Parameters has incorrect size.");const auto parameters{rp.PopRaw<Parameters>()};@@ -194,7 +194,7 @@ void IRS::RunImageTransferProcessor(Kernel::HLERequestContext& ctx) {system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle);if (t_mem.IsNull()) {- LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);+ LOG_ERROR(Service_IRS, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);IPC::ResponseBuilder rb{ctx, 2};rb.Push(ResultUnknown);return;@@ -268,24 +268,32 @@ void IRS::GetImageTransferProcessorState(Kernel::HLERequestContext& ctx) {void IRS::RunTeraPluginProcessor(Kernel::HLERequestContext& ctx) {IPC::RequestParser rp{ctx};- const auto camera_handle{rp.PopRaw<Core::IrSensor::IrCameraHandle>()};- const auto processor_config{rp.PopRaw<Core::IrSensor::PackedTeraPluginProcessorConfig>()};- const auto applet_resource_user_id{rp.Pop<u64>()};+ struct Parameters {+ Core::IrSensor::IrCameraHandle camera_handle;+ Core::IrSensor::PackedTeraPluginProcessorConfig processor_config;+ INSERT_PADDING_WORDS_NOINIT(1);+ u64 applet_resource_user_id;+ };+ static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");- LOG_WARNING(Service_IRS,- "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "- "applet_resource_user_id={}",- camera_handle.npad_type, camera_handle.npad_id, processor_config.mode,- processor_config.required_mcu_version.major,- processor_config.required_mcu_version.minor, applet_resource_user_id);+ const auto parameters{rp.PopRaw<Parameters>()};++ LOG_WARNING(+ Service_IRS,+ "(STUBBED) called, npad_type={}, npad_id={}, mode={}, mcu_version={}.{}, "+ "applet_resource_user_id={}",+ parameters.camera_handle.npad_type, parameters.camera_handle.npad_id,+ parameters.processor_config.mode, parameters.processor_config.required_mcu_version.major,+ parameters.processor_config.required_mcu_version.minor, parameters.applet_resource_user_id);- const auto result = IsIrCameraHandleValid(camera_handle);+ const auto result = IsIrCameraHandleValid(parameters.camera_handle);if (result.IsSuccess()) {- auto& device = GetIrCameraSharedMemoryDeviceEntry(camera_handle);- MakeProcessor<TeraPluginProcessor>(camera_handle, device);- auto& image_transfer_processor = GetProcessor<TeraPluginProcessor>(camera_handle);- image_transfer_processor.SetConfig(processor_config);+ auto& device = GetIrCameraSharedMemoryDeviceEntry(parameters.camera_handle);+ MakeProcessor<TeraPluginProcessor>(parameters.camera_handle, device);+ auto& image_transfer_processor =+ GetProcessor<TeraPluginProcessor>(parameters.camera_handle);+ image_transfer_processor.SetConfig(parameters.processor_config);}IPC::ResponseBuilder rb{ctx, 2};@@ -299,7 +307,7 @@ void IRS::GetNpadIrCameraHandle(Kernel::HLERequestContext& ctx) {if (npad_id > Core::HID::NpadIdType::Player8 && npad_id != Core::HID::NpadIdType::Invalid &&npad_id != Core::HID::NpadIdType::Handheld) {IPC::ResponseBuilder rb{ctx, 2};- rb.Push(InvalidNpadId);+ rb.Push(Service::HID::InvalidNpadId);return;}@@ -553,4 +561,4 @@ IRS_SYS::IRS_SYS(Core::System& system_) : ServiceFramework{system_, "irs:sys"} {IRS_SYS::~IRS_SYS() = default;-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irs.h b/src/core/hle/service/hid/irs.hindex ae7f7719b2..516620b4d7 100644--- a/src/core/hle/service/hid/irs.h+++ b/src/core/hle/service/hid/irs.h@@ -16,7 +16,7 @@ namespace Core::HID {class EmulatedController;} // namespace Core::HID-namespace Service::HID {+namespace Service::IRS {class IRS final : public ServiceFramework<IRS> {public:@@ -114,4 +114,4 @@ public:~IRS_SYS() override;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/clustering_processor.cpp b/src/core/hle/service/hid/irsensor/clustering_processor.cppindex aac3e4fec9..6479af2129 100644--- a/src/core/hle/service/hid/irsensor/clustering_processor.cpp+++ b/src/core/hle/service/hid/irsensor/clustering_processor.cpp@@ -3,14 +3,12 @@#include "core/hle/service/hid/irsensor/clustering_processor.h"-namespace Service::HID {+namespace Service::IRS {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;@@ -33,4 +31,4 @@ void ClusteringProcessor::SetConfig(Core::IrSensor::PackedClusteringProcessorConcurrent_config.object_intensity_min = config.object_intensity_min;}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/clustering_processor.h b/src/core/hle/service/hid/irsensor/clustering_processor.hindex 58b2acf1c2..6e2ba8846b 100644--- a/src/core/hle/service/hid/irsensor/clustering_processor.h+++ b/src/core/hle/service/hid/irsensor/clustering_processor.h@@ -7,7 +7,7 @@#include "core/hid/irs_types.h"#include "core/hle/service/hid/irsensor/processor_base.h"-namespace Service::HID {+namespace Service::IRS {class ClusteringProcessor final : public ProcessorBase {public:explicit ClusteringProcessor(Core::IrSensor::DeviceFormat& device_format);@@ -71,4 +71,4 @@ private:ClusteringProcessorConfig current_config{};Core::IrSensor::DeviceFormat& device;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp b/src/core/hle/service/hid/irsensor/image_transfer_processor.cppindex 703e825e64..98f0c579de 100644--- a/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp+++ b/src/core/hle/service/hid/irsensor/image_transfer_processor.cpp@@ -5,7 +5,7 @@#include "core/hid/hid_core.h"#include "core/hle/service/hid/irsensor/image_transfer_processor.h"-namespace Service::HID {+namespace Service::IRS {ImageTransferProcessor::ImageTransferProcessor(Core::HID::HIDCore& hid_core_,Core::IrSensor::DeviceFormat& device_format,std::size_t npad_index)@@ -21,8 +21,6 @@ ImageTransferProcessor::ImageTransferProcessor(Core::HID::HIDCore& hid_core_,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() {@@ -33,8 +31,6 @@ 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;}@@ -151,4 +147,4 @@ Core::IrSensor::ImageTransferProcessorState ImageTransferProcessor::GetState(return processor_state;}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/image_transfer_processor.h b/src/core/hle/service/hid/irsensor/image_transfer_processor.hindex b557eaf204..393df492d7 100644--- a/src/core/hle/service/hid/irsensor/image_transfer_processor.h+++ b/src/core/hle/service/hid/irsensor/image_transfer_processor.h@@ -11,7 +11,7 @@ namespace Core::HID {class EmulatedController;} // namespace Core::HID-namespace Service::HID {+namespace Service::IRS {class ImageTransferProcessor final : public ProcessorBase {public:explicit ImageTransferProcessor(Core::HID::HIDCore& hid_core_,@@ -70,4 +70,4 @@ private:u8* transfer_memory = nullptr;bool is_transfer_memory_set = false;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/ir_led_processor.cpp b/src/core/hle/service/hid/irsensor/ir_led_processor.cppindex 656e17c955..8e6dd99e49 100644--- a/src/core/hle/service/hid/irsensor/ir_led_processor.cpp+++ b/src/core/hle/service/hid/irsensor/ir_led_processor.cpp@@ -3,14 +3,12 @@#include "core/hle/service/hid/irsensor/ir_led_processor.h"-namespace Service::HID {+namespace Service::IRS {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;@@ -26,4 +24,4 @@ void IrLedProcessor::SetConfig(Core::IrSensor::PackedIrLedProcessorConfig configstatic_cast<Core::IrSensor::CameraLightTarget>(config.light_target);}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/ir_led_processor.h b/src/core/hle/service/hid/irsensor/ir_led_processor.hindex cb04d0b941..c3d8693c9e 100644--- a/src/core/hle/service/hid/irsensor/ir_led_processor.h+++ b/src/core/hle/service/hid/irsensor/ir_led_processor.h@@ -8,7 +8,7 @@#include "core/hid/irs_types.h"#include "core/hle/service/hid/irsensor/processor_base.h"-namespace Service::HID {+namespace Service::IRS {class IrLedProcessor final : public ProcessorBase {public:explicit IrLedProcessor(Core::IrSensor::DeviceFormat& device_format);@@ -44,4 +44,4 @@ private:Core::IrSensor::DeviceFormat& device;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/moment_processor.cpp b/src/core/hle/service/hid/irsensor/moment_processor.cppindex fb36be577c..dbaca420ad 100644--- a/src/core/hle/service/hid/irsensor/moment_processor.cpp+++ b/src/core/hle/service/hid/irsensor/moment_processor.cpp@@ -3,14 +3,12 @@#include "core/hle/service/hid/irsensor/moment_processor.h"-namespace Service::HID {+namespace Service::IRS {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;@@ -33,4 +31,4 @@ void MomentProcessor::SetConfig(Core::IrSensor::PackedMomentProcessorConfig confcurrent_config.preprocess_intensity_threshold = config.preprocess_intensity_threshold;}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/moment_processor.h b/src/core/hle/service/hid/irsensor/moment_processor.hindex 63cdadfda7..d4bd22e0f2 100644--- a/src/core/hle/service/hid/irsensor/moment_processor.h+++ b/src/core/hle/service/hid/irsensor/moment_processor.h@@ -8,7 +8,7 @@#include "core/hid/irs_types.h"#include "core/hle/service/hid/irsensor/processor_base.h"-namespace Service::HID {+namespace Service::IRS {class MomentProcessor final : public ProcessorBase {public:explicit MomentProcessor(Core::IrSensor::DeviceFormat& device_format);@@ -58,4 +58,4 @@ private:Core::IrSensor::DeviceFormat& device;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/pointing_processor.cpp b/src/core/hle/service/hid/irsensor/pointing_processor.cppindex 7eb1236363..929f177fc6 100644--- a/src/core/hle/service/hid/irsensor/pointing_processor.cpp+++ b/src/core/hle/service/hid/irsensor/pointing_processor.cpp@@ -3,14 +3,12 @@#include "core/hle/service/hid/irsensor/pointing_processor.h"-namespace Service::HID {+namespace Service::IRS {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;@@ -25,4 +23,4 @@ void PointingProcessor::SetConfig(Core::IrSensor::PackedPointingProcessorConfigcurrent_config.window_of_interest = config.window_of_interest;}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/pointing_processor.h b/src/core/hle/service/hid/irsensor/pointing_processor.hindex 2f67eff919..cf49307944 100644--- a/src/core/hle/service/hid/irsensor/pointing_processor.h+++ b/src/core/hle/service/hid/irsensor/pointing_processor.h@@ -3,12 +3,11 @@#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 {+namespace Service::IRS {class PointingProcessor final : public ProcessorBase {public:explicit PointingProcessor(Core::IrSensor::DeviceFormat& device_format);@@ -59,4 +58,4 @@ private:Core::IrSensor::DeviceFormat& device;};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/processor_base.cpp b/src/core/hle/service/hid/irsensor/processor_base.cppindex bc8025375c..4d43ca17ac 100644--- a/src/core/hle/service/hid/irsensor/processor_base.cpp+++ b/src/core/hle/service/hid/irsensor/processor_base.cpp@@ -3,7 +3,7 @@#include "core/hle/service/hid/irsensor/processor_base.h"-namespace Service::HID {+namespace Service::IRS {ProcessorBase::ProcessorBase() {}ProcessorBase::~ProcessorBase() = default;@@ -64,4 +64,4 @@ std::size_t ProcessorBase::GetDataHeight(}}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/processor_base.h b/src/core/hle/service/hid/irsensor/processor_base.hindex 49831aab6b..bc0d2977bc 100644--- a/src/core/hle/service/hid/irsensor/processor_base.h+++ b/src/core/hle/service/hid/irsensor/processor_base.h@@ -6,7 +6,7 @@#include "common/common_types.h"#include "core/hid/irs_types.h"-namespace Service::HID {+namespace Service::IRS {class ProcessorBase {public:explicit ProcessorBase();@@ -30,4 +30,4 @@ protected:bool is_active{false};};-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/tera_plugin_processor.cpp b/src/core/hle/service/hid/irsensor/tera_plugin_processor.cppindex deec22072e..e691c840a4 100644--- a/src/core/hle/service/hid/irsensor/tera_plugin_processor.cpp+++ b/src/core/hle/service/hid/irsensor/tera_plugin_processor.cpp@@ -3,14 +3,12 @@#include "core/hle/service/hid/irsensor/tera_plugin_processor.h"-namespace Service::HID {+namespace Service::IRS {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;@@ -28,4 +26,4 @@ void TeraPluginProcessor::SetConfig(Core::IrSensor::PackedTeraPluginProcessorConcurrent_config.unknown_3 = config.unknown_3;}-} // namespace Service::HID+} // namespace Service::IRSdiff --git a/src/core/hle/service/hid/irsensor/tera_plugin_processor.h b/src/core/hle/service/hid/irsensor/tera_plugin_processor.hindex 60f8057a5d..bbea7ed0b5 100644--- a/src/core/hle/service/hid/irsensor/tera_plugin_processor.h+++ b/src/core/hle/service/hid/irsensor/tera_plugin_processor.h@@ -8,7 +8,7 @@#include "core/hid/irs_types.h"#include "core/hle/service/hid/irsensor/processor_base.h"-namespace Service::HID {+namespace Service::IRS {class TeraPluginProcessor final : public ProcessorBase {public:explicit TeraPluginProcessor(Core::IrSensor::DeviceFormat& device_format);@@ -50,4 +50,4 @@ private:Core::IrSensor::DeviceFormat& device;};-} // namespace Service::HID+} // namespace Service::IRS