diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-02-27 18:26:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 18:26:26 +0100 |
commit | dc94882c9062ab88d3d5de35dcb8731111baaea2 (patch) | |
tree | b00be6f4a4b2c826f116e212e15f4498e4b50504 /src/hid_core/resources | |
parent | Merge pull request #13175 from liamwhite/asan (diff) | |
parent | service: hid: Migrate HidServer to new IPC (diff) | |
download | yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar.gz yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar.bz2 yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar.lz yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar.xz yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.tar.zst yuzu-dc94882c9062ab88d3d5de35dcb8731111baaea2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/hid_core/resources/palma/palma.cpp | 24 | ||||
-rw-r--r-- | src/hid_core/resources/palma/palma.h | 34 |
2 files changed, 41 insertions, 17 deletions
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<u8> out_data) const { if (handle.npad_id != active_handle.npad_id) { return InvalidPalmaHandle; } - operation_type = operation.operation; - data = operation.data; + operation_type = static_cast<PalmaOperationType>(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<u8>(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 <array> +#include <span> + #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<u8, 0x140>; + using PalmaApplicationSection = std::array<u8, 0x100>; + using Address = std::array<u8, 0x6>; // 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<u8> out_data) const; Result PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity); Result SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_); Result ReadPalmaStep(const PalmaConnectionHandle& handle); |