diff options
| author | 2024-02-22 17:21:36 -0600 | |
|---|---|---|
| committer | 2024-02-23 17:49:02 -0600 | |
| commit | fc6a87bba1d7f1b358778c3b5535315c8401aced (patch) | |
| tree | 1a3972d281da3acddf0f9f34ca2afb262f41f0fa /src/hid_core | |
| parent | service: hid: Move and migrate AppletResource and ActiveVibrationDevice (diff) | |
| download | yuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.tar.gz yuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.tar.xz yuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.zip | |
service: hid: Migrate HidServer to new IPC
Diffstat (limited to 'src/hid_core')
| -rw-r--r-- | src/hid_core/hid_types.h | 34 | ||||
| -rw-r--r-- | src/hid_core/resources/palma/palma.cpp | 24 | ||||
| -rw-r--r-- | src/hid_core/resources/palma/palma.h | 34 |
3 files changed, 54 insertions, 38 deletions
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 | |||
| 565 | 565 | ||
| 566 | // This is nn::hid::SixAxisSensorCalibrationParameter | 566 | // This is nn::hid::SixAxisSensorCalibrationParameter |
| 567 | struct SixAxisSensorCalibrationParameter { | 567 | struct SixAxisSensorCalibrationParameter { |
| 568 | std::array<u8, 0x744> unknown_data{}; | 568 | std::array<u8, 0x744> unknown_data; |
| 569 | }; | 569 | }; |
| 570 | static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, | 570 | static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, |
| 571 | "SixAxisSensorCalibrationParameter is an invalid size"); | 571 | "SixAxisSensorCalibrationParameter is an invalid size"); |
| 572 | static_assert(std::is_trivial_v<SixAxisSensorCalibrationParameter>, | ||
| 573 | "SixAxisSensorCalibrationParameter must be trivial."); | ||
| 572 | 574 | ||
| 573 | // This is nn::hid::SixAxisSensorIcInformation | 575 | // This is nn::hid::SixAxisSensorIcInformation |
| 574 | struct SixAxisSensorIcInformation { | 576 | struct SixAxisSensorIcInformation { |
| 575 | f32 angular_rate{2000.0f}; // dps | 577 | f32 angular_rate; // dps |
| 576 | std::array<f32, 6> unknown_gyro_data1{ | 578 | std::array<f32, 6> unknown_gyro_data1; // dps |
| 577 | -10.0f, -10.0f, -10.0f, 10.0f, 10.0f, 10.0f, | 579 | std::array<f32, 9> unknown_gyro_data2; |
| 578 | }; // dps | 580 | std::array<f32, 9> unknown_gyro_data3; |
| 579 | std::array<f32, 9> unknown_gyro_data2{ | 581 | f32 acceleration_range; // g force |
| 580 | 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, | 582 | std::array<f32, 6> unknown_accel_data1; // g force |
| 581 | }; | 583 | std::array<f32, 9> unknown_accel_data2; |
| 582 | std::array<f32, 9> unknown_gyro_data3{ | 584 | std::array<f32, 9> unknown_accel_data3; |
| 583 | 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, | ||
| 584 | }; | ||
| 585 | f32 acceleration_range{8.0f}; // g force | ||
| 586 | std::array<f32, 6> unknown_accel_data1{ | ||
| 587 | -0.0612f, -0.0612f, -0.0612f, 0.0612f, 0.0612f, 0.0612f, | ||
| 588 | }; // g force | ||
| 589 | std::array<f32, 9> unknown_accel_data2{ | ||
| 590 | 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, -0.003f, -0.003f, -0.003f, 0.95f, | ||
| 591 | }; | ||
| 592 | std::array<f32, 9> unknown_accel_data3{ | ||
| 593 | 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, 0.003f, 0.003f, 0.003f, 1.05f, | ||
| 594 | }; | ||
| 595 | }; | 585 | }; |
| 596 | static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, | 586 | static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, |
| 597 | "SixAxisSensorIcInformation is an invalid size"); | 587 | "SixAxisSensorIcInformation is an invalid size"); |
| 588 | static_assert(std::is_trivial_v<SixAxisSensorIcInformation>, | ||
| 589 | "SixAxisSensorIcInformation must be trivial."); | ||
| 598 | 590 | ||
| 599 | // This is nn::hid::SixAxisSensorAttribute | 591 | // This is nn::hid::SixAxisSensorAttribute |
| 600 | struct SixAxisSensorAttribute { | 592 | 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( | |||
| 56 | 56 | ||
| 57 | Result Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle, | 57 | Result 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 { | |||
| 27 | class Palma final : public ControllerBase { | 29 | class Palma final : public ControllerBase { |
| 28 | public: | 30 | public: |
| 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); |