From d08f201e0c0e6d36176983f9673a89550705952b Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Thu, 22 Feb 2024 11:58:52 -0600 Subject: service: hid: Move and migrate AppletResource and ActiveVibrationDevice --- src/hid_core/resource_manager.cpp | 26 -------------------------- src/hid_core/resource_manager.h | 13 ------------- 2 files changed, 39 deletions(-) (limited to 'src/hid_core') diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp index 01261ba97..62fec03b1 100644 --- a/src/hid_core/resource_manager.cpp +++ b/src/hid_core/resource_manager.cpp @@ -4,7 +4,6 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/core_timing.h" -#include "core/hle/kernel/k_shared_memory.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/set/system_settings_server.h" #include "core/hle/service/sm/sm.h" @@ -501,29 +500,4 @@ void ResourceManager::UpdateMotion(std::chrono::nanoseconds ns_late) { console_six_axis->OnUpdate(core_timing); } -IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr resource, - u64 applet_resource_user_id) - : ServiceFramework{system_, "IAppletResource"}, aruid{applet_resource_user_id}, - resource_manager{resource} { - static const FunctionInfo functions[] = { - {0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"}, - }; - RegisterHandlers(functions); -} - -IAppletResource::~IAppletResource() { - resource_manager->FreeAppletResourceId(aruid); -} - -void IAppletResource::GetSharedMemoryHandle(HLERequestContext& ctx) { - Kernel::KSharedMemory* handle; - const auto result = resource_manager->GetSharedMemoryHandle(&handle, aruid); - - LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", aruid, result.raw); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(result); - rb.PushCopyObjects(handle); -} - } // namespace Service::HID diff --git a/src/hid_core/resource_manager.h b/src/hid_core/resource_manager.h index dc3ff01f8..5abd7e044 100644 --- a/src/hid_core/resource_manager.h +++ b/src/hid_core/resource_manager.h @@ -174,17 +174,4 @@ private: KernelHelpers::ServiceContext service_context; }; -class IAppletResource final : public ServiceFramework { -public: - explicit IAppletResource(Core::System& system_, std::shared_ptr resource, - u64 applet_resource_user_id); - ~IAppletResource() override; - -private: - void GetSharedMemoryHandle(HLERequestContext& ctx); - - u64 aruid{}; - std::shared_ptr resource_manager; -}; - } // namespace Service::HID -- cgit v1.2.3 From fc6a87bba1d7f1b358778c3b5535315c8401aced Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Thu, 22 Feb 2024 17:21:36 -0600 Subject: service: hid: Migrate HidServer to new IPC --- src/hid_core/hid_types.h | 34 +++++++++++++--------------------- src/hid_core/resources/palma/palma.cpp | 24 +++++++++++++----------- src/hid_core/resources/palma/palma.h | 34 ++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 38 deletions(-) (limited to 'src/hid_core') diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h index 1b2fc6295..165ecf9de 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h @@ -565,36 +565,28 @@ static_assert(sizeof(SixAxisSensorProperties) == 1, "SixAxisSensorProperties is // This is nn::hid::SixAxisSensorCalibrationParameter struct SixAxisSensorCalibrationParameter { - std::array unknown_data{}; + std::array unknown_data; }; static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, "SixAxisSensorCalibrationParameter is an invalid size"); +static_assert(std::is_trivial_v, + "SixAxisSensorCalibrationParameter must be trivial."); // This is nn::hid::SixAxisSensorIcInformation struct SixAxisSensorIcInformation { - f32 angular_rate{2000.0f}; // dps - std::array unknown_gyro_data1{ - -10.0f, -10.0f, -10.0f, 10.0f, 10.0f, 10.0f, - }; // dps - std::array unknown_gyro_data2{ - 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, - }; - std::array unknown_gyro_data3{ - 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, - }; - f32 acceleration_range{8.0f}; // g force - std::array unknown_accel_data1{ - -0.0612f, -0.0612f, -0.0612f, 0.0612f, 0.0612f, 0.0612f, - }; // g force - std::array unknown_accel_data2{ - 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, - }; - std::array unknown_accel_data3{ - 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, - }; + f32 angular_rate; // dps + std::array unknown_gyro_data1; // dps + std::array unknown_gyro_data2; + std::array unknown_gyro_data3; + f32 acceleration_range; // g force + std::array unknown_accel_data1; // g force + std::array unknown_accel_data2; + std::array unknown_accel_data3; }; static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, "SixAxisSensorIcInformation is an invalid size"); +static_assert(std::is_trivial_v, + "SixAxisSensorIcInformation must be trivial."); // This is nn::hid::SixAxisSensorAttribute struct SixAxisSensorAttribute { diff --git a/src/hid_core/resources/palma/palma.cpp b/src/hid_core/resources/palma/palma.cpp index ea4a291fd..be3d3c0ed 100644 --- a/src/hid_core/resources/palma/palma.cpp +++ b/src/hid_core/resources/palma/palma.cpp @@ -56,12 +56,14 @@ Kernel::KReadableEvent& Palma::AcquirePalmaOperationCompleteEvent( Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle, PalmaOperationType& operation_type, - PalmaOperationData& data) const { + std::span out_data) const { if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation_type = operation.operation; - data = operation.data; + operation_type = static_cast(operation.operation); + std::memcpy(out_data.data(), operation.data.data(), + std::min(out_data.size(), operation.data.size())); + return ResultSuccess; } @@ -69,7 +71,7 @@ Result Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_a if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::PlayActivity; + operation.operation = PackedPalmaOperationType::PlayActivity; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -88,7 +90,7 @@ Result Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) { if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::ReadStep; + operation.operation = PackedPalmaOperationType::ReadStep; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -117,7 +119,7 @@ Result Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) { if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::ReadUniqueCode; + operation.operation = PackedPalmaOperationType::ReadUniqueCode; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -128,7 +130,7 @@ Result Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) { if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::SetUniqueCodeInvalid; + operation.operation = PackedPalmaOperationType::SetUniqueCodeInvalid; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -141,7 +143,7 @@ Result Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::WriteRgbLedPatternEntry; + operation.operation = PackedPalmaOperationType::WriteRgbLedPatternEntry; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -153,7 +155,7 @@ Result Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWave if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::WriteWaveEntry; + operation.operation = PackedPalmaOperationType::WriteWaveEntry; operation.result = PalmaResultSuccess; operation.data = {}; operation_complete_event->Signal(); @@ -166,7 +168,7 @@ Result Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& return InvalidPalmaHandle; } database_id_version = database_id_version_; - operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; + operation.operation = PackedPalmaOperationType::ReadDataBaseIdentificationVersion; operation.result = PalmaResultSuccess; operation.data[0] = {}; operation_complete_event->Signal(); @@ -177,7 +179,7 @@ Result Palma::GetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; + operation.operation = PackedPalmaOperationType::ReadDataBaseIdentificationVersion; operation.result = PalmaResultSuccess; operation.data = {}; operation.data[0] = static_cast(database_id_version); diff --git a/src/hid_core/resources/palma/palma.h b/src/hid_core/resources/palma/palma.h index 60259c3d8..477cbf904 100644 --- a/src/hid_core/resources/palma/palma.h +++ b/src/hid_core/resources/palma/palma.h @@ -4,6 +4,8 @@ #pragma once #include +#include + #include "common/common_funcs.h" #include "common/typed_address.h" #include "hid_core/hid_result.h" @@ -27,9 +29,31 @@ namespace Service::HID { class Palma final : public ControllerBase { public: using PalmaOperationData = std::array; + using PalmaApplicationSection = std::array; + using Address = std::array; // This is nn::hid::PalmaOperationType - enum class PalmaOperationType { + enum class PalmaOperationType : u64 { + PlayActivity, + SetFrModeType, + ReadStep, + EnableStep, + ResetStep, + ReadApplicationSection, + WriteApplicationSection, + ReadUniqueCode, + SetUniqueCodeInvalid, + WriteActivityEntry, + WriteRgbLedPatternEntry, + WriteWaveEntry, + ReadDataBaseIdentificationVersion, + WriteDataBaseIdentificationVersion, + SuspendFeature, + ReadPlayLog, + ResetPlayLog, + }; + + enum class PackedPalmaOperationType : u32 { PlayActivity, SetFrModeType, ReadStep, @@ -75,7 +99,7 @@ public: // This is nn::hid::PalmaOperationInfo struct PalmaOperationInfo { - PalmaOperationType operation{}; + PackedPalmaOperationType operation{}; Result result{PalmaResultSuccess}; PalmaOperationData data{}; }; @@ -92,8 +116,7 @@ public: static_assert(sizeof(PalmaActivityEntry) == 0x20, "PalmaActivityEntry is an invalid size"); struct PalmaConnectionHandle { - Core::HID::NpadIdType npad_id; - INSERT_PADDING_BYTES(4); // Unknown + alignas(8) Core::HID::NpadIdType npad_id; }; static_assert(sizeof(PalmaConnectionHandle) == 0x8, "PalmaConnectionHandle has incorrect size."); @@ -115,8 +138,7 @@ public: Kernel::KReadableEvent& AcquirePalmaOperationCompleteEvent( const PalmaConnectionHandle& handle) const; Result GetPalmaOperationInfo(const PalmaConnectionHandle& handle, - PalmaOperationType& operation_type, - PalmaOperationData& data) const; + PalmaOperationType& operation_type, std::span out_data) const; Result PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity); Result SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_); Result ReadPalmaStep(const PalmaConnectionHandle& handle); -- cgit v1.2.3