summaryrefslogtreecommitdiff
path: root/src/hid_core/resources/palma
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_core/resources/palma')
-rw-r--r--src/hid_core/resources/palma/palma.cpp24
-rw-r--r--src/hid_core/resources/palma/palma.h34
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(
56 56
57Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle, 57Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
58 PalmaOperationType& operation_type, 58 PalmaOperationType& operation_type,
59 PalmaOperationData& data) const { 59 std::span<u8> out_data) const {
60 if (handle.npad_id != active_handle.npad_id) { 60 if (handle.npad_id != active_handle.npad_id) {
61 return InvalidPalmaHandle; 61 return InvalidPalmaHandle;
62 } 62 }
63 operation_type = operation.operation; 63 operation_type = static_cast<PalmaOperationType>(operation.operation);
64 data = operation.data; 64 std::memcpy(out_data.data(), operation.data.data(),
65 std::min(out_data.size(), operation.data.size()));
66
65 return ResultSuccess; 67 return ResultSuccess;
66} 68}
67 69
@@ -69,7 +71,7 @@ Result Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_a
69 if (handle.npad_id != active_handle.npad_id) { 71 if (handle.npad_id != active_handle.npad_id) {
70 return InvalidPalmaHandle; 72 return InvalidPalmaHandle;
71 } 73 }
72 operation.operation = PalmaOperationType::PlayActivity; 74 operation.operation = PackedPalmaOperationType::PlayActivity;
73 operation.result = PalmaResultSuccess; 75 operation.result = PalmaResultSuccess;
74 operation.data = {}; 76 operation.data = {};
75 operation_complete_event->Signal(); 77 operation_complete_event->Signal();
@@ -88,7 +90,7 @@ Result Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) {
88 if (handle.npad_id != active_handle.npad_id) { 90 if (handle.npad_id != active_handle.npad_id) {
89 return InvalidPalmaHandle; 91 return InvalidPalmaHandle;
90 } 92 }
91 operation.operation = PalmaOperationType::ReadStep; 93 operation.operation = PackedPalmaOperationType::ReadStep;
92 operation.result = PalmaResultSuccess; 94 operation.result = PalmaResultSuccess;
93 operation.data = {}; 95 operation.data = {};
94 operation_complete_event->Signal(); 96 operation_complete_event->Signal();
@@ -117,7 +119,7 @@ Result Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) {
117 if (handle.npad_id != active_handle.npad_id) { 119 if (handle.npad_id != active_handle.npad_id) {
118 return InvalidPalmaHandle; 120 return InvalidPalmaHandle;
119 } 121 }
120 operation.operation = PalmaOperationType::ReadUniqueCode; 122 operation.operation = PackedPalmaOperationType::ReadUniqueCode;
121 operation.result = PalmaResultSuccess; 123 operation.result = PalmaResultSuccess;
122 operation.data = {}; 124 operation.data = {};
123 operation_complete_event->Signal(); 125 operation_complete_event->Signal();
@@ -128,7 +130,7 @@ Result Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) {
128 if (handle.npad_id != active_handle.npad_id) { 130 if (handle.npad_id != active_handle.npad_id) {
129 return InvalidPalmaHandle; 131 return InvalidPalmaHandle;
130 } 132 }
131 operation.operation = PalmaOperationType::SetUniqueCodeInvalid; 133 operation.operation = PackedPalmaOperationType::SetUniqueCodeInvalid;
132 operation.result = PalmaResultSuccess; 134 operation.result = PalmaResultSuccess;
133 operation.data = {}; 135 operation.data = {};
134 operation_complete_event->Signal(); 136 operation_complete_event->Signal();
@@ -141,7 +143,7 @@ Result Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle,
141 if (handle.npad_id != active_handle.npad_id) { 143 if (handle.npad_id != active_handle.npad_id) {
142 return InvalidPalmaHandle; 144 return InvalidPalmaHandle;
143 } 145 }
144 operation.operation = PalmaOperationType::WriteRgbLedPatternEntry; 146 operation.operation = PackedPalmaOperationType::WriteRgbLedPatternEntry;
145 operation.result = PalmaResultSuccess; 147 operation.result = PalmaResultSuccess;
146 operation.data = {}; 148 operation.data = {};
147 operation_complete_event->Signal(); 149 operation_complete_event->Signal();
@@ -153,7 +155,7 @@ Result Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWave
153 if (handle.npad_id != active_handle.npad_id) { 155 if (handle.npad_id != active_handle.npad_id) {
154 return InvalidPalmaHandle; 156 return InvalidPalmaHandle;
155 } 157 }
156 operation.operation = PalmaOperationType::WriteWaveEntry; 158 operation.operation = PackedPalmaOperationType::WriteWaveEntry;
157 operation.result = PalmaResultSuccess; 159 operation.result = PalmaResultSuccess;
158 operation.data = {}; 160 operation.data = {};
159 operation_complete_event->Signal(); 161 operation_complete_event->Signal();
@@ -166,7 +168,7 @@ Result Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle&
166 return InvalidPalmaHandle; 168 return InvalidPalmaHandle;
167 } 169 }
168 database_id_version = database_id_version_; 170 database_id_version = database_id_version_;
169 operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; 171 operation.operation = PackedPalmaOperationType::ReadDataBaseIdentificationVersion;
170 operation.result = PalmaResultSuccess; 172 operation.result = PalmaResultSuccess;
171 operation.data[0] = {}; 173 operation.data[0] = {};
172 operation_complete_event->Signal(); 174 operation_complete_event->Signal();
@@ -177,7 +179,7 @@ Result Palma::GetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle&
177 if (handle.npad_id != active_handle.npad_id) { 179 if (handle.npad_id != active_handle.npad_id) {
178 return InvalidPalmaHandle; 180 return InvalidPalmaHandle;
179 } 181 }
180 operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; 182 operation.operation = PackedPalmaOperationType::ReadDataBaseIdentificationVersion;
181 operation.result = PalmaResultSuccess; 183 operation.result = PalmaResultSuccess;
182 operation.data = {}; 184 operation.data = {};
183 operation.data[0] = static_cast<u8>(database_id_version); 185 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 @@
4#pragma once 4#pragma once
5 5
6#include <array> 6#include <array>
7#include <span>
8
7#include "common/common_funcs.h" 9#include "common/common_funcs.h"
8#include "common/typed_address.h" 10#include "common/typed_address.h"
9#include "hid_core/hid_result.h" 11#include "hid_core/hid_result.h"
@@ -27,9 +29,31 @@ namespace Service::HID {
27class Palma final : public ControllerBase { 29class Palma final : public ControllerBase {
28public: 30public:
29 using PalmaOperationData = std::array<u8, 0x140>; 31 using PalmaOperationData = std::array<u8, 0x140>;
32 using PalmaApplicationSection = std::array<u8, 0x100>;
33 using Address = std::array<u8, 0x6>;
30 34
31 // This is nn::hid::PalmaOperationType 35 // This is nn::hid::PalmaOperationType
32 enum class PalmaOperationType { 36 enum class PalmaOperationType : u64 {
37 PlayActivity,
38 SetFrModeType,
39 ReadStep,
40 EnableStep,
41 ResetStep,
42 ReadApplicationSection,
43 WriteApplicationSection,
44 ReadUniqueCode,
45 SetUniqueCodeInvalid,
46 WriteActivityEntry,
47 WriteRgbLedPatternEntry,
48 WriteWaveEntry,
49 ReadDataBaseIdentificationVersion,
50 WriteDataBaseIdentificationVersion,
51 SuspendFeature,
52 ReadPlayLog,
53 ResetPlayLog,
54 };
55
56 enum class PackedPalmaOperationType : u32 {
33 PlayActivity, 57 PlayActivity,
34 SetFrModeType, 58 SetFrModeType,
35 ReadStep, 59 ReadStep,
@@ -75,7 +99,7 @@ public:
75 99
76 // This is nn::hid::PalmaOperationInfo 100 // This is nn::hid::PalmaOperationInfo
77 struct PalmaOperationInfo { 101 struct PalmaOperationInfo {
78 PalmaOperationType operation{}; 102 PackedPalmaOperationType operation{};
79 Result result{PalmaResultSuccess}; 103 Result result{PalmaResultSuccess};
80 PalmaOperationData data{}; 104 PalmaOperationData data{};
81 }; 105 };
@@ -92,8 +116,7 @@ public:
92 static_assert(sizeof(PalmaActivityEntry) == 0x20, "PalmaActivityEntry is an invalid size"); 116 static_assert(sizeof(PalmaActivityEntry) == 0x20, "PalmaActivityEntry is an invalid size");
93 117
94 struct PalmaConnectionHandle { 118 struct PalmaConnectionHandle {
95 Core::HID::NpadIdType npad_id; 119 alignas(8) Core::HID::NpadIdType npad_id;
96 INSERT_PADDING_BYTES(4); // Unknown
97 }; 120 };
98 static_assert(sizeof(PalmaConnectionHandle) == 0x8, 121 static_assert(sizeof(PalmaConnectionHandle) == 0x8,
99 "PalmaConnectionHandle has incorrect size."); 122 "PalmaConnectionHandle has incorrect size.");
@@ -115,8 +138,7 @@ public:
115 Kernel::KReadableEvent& AcquirePalmaOperationCompleteEvent( 138 Kernel::KReadableEvent& AcquirePalmaOperationCompleteEvent(
116 const PalmaConnectionHandle& handle) const; 139 const PalmaConnectionHandle& handle) const;
117 Result GetPalmaOperationInfo(const PalmaConnectionHandle& handle, 140 Result GetPalmaOperationInfo(const PalmaConnectionHandle& handle,
118 PalmaOperationType& operation_type, 141 PalmaOperationType& operation_type, std::span<u8> out_data) const;
119 PalmaOperationData& data) const;
120 Result PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity); 142 Result PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity);
121 Result SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_); 143 Result SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_);
122 Result ReadPalmaStep(const PalmaConnectionHandle& handle); 144 Result ReadPalmaStep(const PalmaConnectionHandle& handle);