diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/palma.cpp | 229 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/palma.h | 163 | ||||
| -rw-r--r-- | src/core/hle/service/hid/errors.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 444 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 29 |
7 files changed, 842 insertions, 33 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 33cf470d5..c17662323 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -460,6 +460,8 @@ add_library(core STATIC | |||
| 460 | hle/service/hid/controllers/mouse.h | 460 | hle/service/hid/controllers/mouse.h |
| 461 | hle/service/hid/controllers/npad.cpp | 461 | hle/service/hid/controllers/npad.cpp |
| 462 | hle/service/hid/controllers/npad.h | 462 | hle/service/hid/controllers/npad.h |
| 463 | hle/service/hid/controllers/palma.cpp | ||
| 464 | hle/service/hid/controllers/palma.h | ||
| 463 | hle/service/hid/controllers/stubbed.cpp | 465 | hle/service/hid/controllers/stubbed.cpp |
| 464 | hle/service/hid/controllers/stubbed.h | 466 | hle/service/hid/controllers/stubbed.h |
| 465 | hle/service/hid/controllers/touchscreen.cpp | 467 | hle/service/hid/controllers/touchscreen.cpp |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index cb29004e8..f8972ec7a 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -660,7 +660,6 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
| 660 | ASSERT(false); | 660 | ASSERT(false); |
| 661 | break; | 661 | break; |
| 662 | case Core::HID::NpadStyleIndex::ProController: | 662 | case Core::HID::NpadStyleIndex::ProController: |
| 663 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 664 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | 663 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); |
| 665 | break; | 664 | break; |
| 666 | case Core::HID::NpadStyleIndex::Handheld: | 665 | case Core::HID::NpadStyleIndex::Handheld: |
| @@ -676,6 +675,11 @@ void Controller_NPad::OnMotionUpdate(const Core::Timing::CoreTiming& core_timing | |||
| 676 | case Core::HID::NpadStyleIndex::JoyconRight: | 675 | case Core::HID::NpadStyleIndex::JoyconRight: |
| 677 | set_motion_state(sixaxis_right_lifo_state, motion_state[1]); | 676 | set_motion_state(sixaxis_right_lifo_state, motion_state[1]); |
| 678 | break; | 677 | break; |
| 678 | case Core::HID::NpadStyleIndex::Pokeball: | ||
| 679 | using namespace std::literals::chrono_literals; | ||
| 680 | set_motion_state(sixaxis_fullkey_state, motion_state[0]); | ||
| 681 | sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count(); | ||
| 682 | break; | ||
| 679 | default: | 683 | default: |
| 680 | break; | 684 | break; |
| 681 | } | 685 | } |
diff --git a/src/core/hle/service/hid/controllers/palma.cpp b/src/core/hle/service/hid/controllers/palma.cpp new file mode 100644 index 000000000..575d4e626 --- /dev/null +++ b/src/core/hle/service/hid/controllers/palma.cpp | |||
| @@ -0,0 +1,229 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/core_timing.h" | ||
| 5 | #include "core/hid/emulated_controller.h" | ||
| 6 | #include "core/hid/hid_core.h" | ||
| 7 | #include "core/hid/hid_types.h" | ||
| 8 | #include "core/hle/kernel/k_event.h" | ||
| 9 | #include "core/hle/kernel/k_readable_event.h" | ||
| 10 | #include "core/hle/service/hid/controllers/palma.h" | ||
| 11 | #include "core/hle/service/kernel_helpers.h" | ||
| 12 | |||
| 13 | namespace Service::HID { | ||
| 14 | |||
| 15 | Controller_Palma::Controller_Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | ||
| 16 | KernelHelpers::ServiceContext& service_context_) | ||
| 17 | : ControllerBase{hid_core_}, service_context{service_context_} { | ||
| 18 | controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Other); | ||
| 19 | operation_complete_event = service_context.CreateEvent("hid:PalmaOperationCompleteEvent"); | ||
| 20 | } | ||
| 21 | |||
| 22 | Controller_Palma::~Controller_Palma() = default; | ||
| 23 | |||
| 24 | void Controller_Palma::OnInit() {} | ||
| 25 | |||
| 26 | void Controller_Palma::OnRelease() {} | ||
| 27 | |||
| 28 | void Controller_Palma::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | ||
| 29 | if (!IsControllerActivated()) { | ||
| 30 | return; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | Result Controller_Palma::GetPalmaConnectionHandle(Core::HID::NpadIdType npad_id, | ||
| 35 | PalmaConnectionHandle& handle) { | ||
| 36 | active_handle.npad_id = npad_id; | ||
| 37 | handle = active_handle; | ||
| 38 | return ResultSuccess; | ||
| 39 | } | ||
| 40 | |||
| 41 | Result Controller_Palma::InitializePalma(const PalmaConnectionHandle& handle) { | ||
| 42 | if (handle.npad_id != active_handle.npad_id) { | ||
| 43 | return InvalidPalmaHandle; | ||
| 44 | } | ||
| 45 | ActivateController(); | ||
| 46 | return ResultSuccess; | ||
| 47 | } | ||
| 48 | |||
| 49 | Kernel::KReadableEvent& Controller_Palma::AcquirePalmaOperationCompleteEvent( | ||
| 50 | const PalmaConnectionHandle& handle) const { | ||
| 51 | if (handle.npad_id != active_handle.npad_id) { | ||
| 52 | LOG_ERROR(Service_HID, "Invalid npad id {}", handle.npad_id); | ||
| 53 | } | ||
| 54 | return operation_complete_event->GetReadableEvent(); | ||
| 55 | } | ||
| 56 | |||
| 57 | Result Controller_Palma::GetPalmaOperationInfo(const PalmaConnectionHandle& handle, | ||
| 58 | PalmaOperationType& operation_type, | ||
| 59 | PalmaOperationData& data) const { | ||
| 60 | if (handle.npad_id != active_handle.npad_id) { | ||
| 61 | return InvalidPalmaHandle; | ||
| 62 | } | ||
| 63 | operation_type = operation.operation; | ||
| 64 | data = operation.data; | ||
| 65 | return ResultSuccess; | ||
| 66 | } | ||
| 67 | |||
| 68 | Result Controller_Palma::PlayPalmaActivity(const PalmaConnectionHandle& handle, | ||
| 69 | u64 palma_activity) { | ||
| 70 | if (handle.npad_id != active_handle.npad_id) { | ||
| 71 | return InvalidPalmaHandle; | ||
| 72 | } | ||
| 73 | operation.operation = PalmaOperationType::PlayActivity; | ||
| 74 | operation.result = PalmaResultSuccess; | ||
| 75 | operation.data = {}; | ||
| 76 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 77 | return ResultSuccess; | ||
| 78 | } | ||
| 79 | |||
| 80 | Result Controller_Palma::SetPalmaFrModeType(const PalmaConnectionHandle& handle, | ||
| 81 | PalmaFrModeType fr_mode_) { | ||
| 82 | if (handle.npad_id != active_handle.npad_id) { | ||
| 83 | return InvalidPalmaHandle; | ||
| 84 | } | ||
| 85 | fr_mode = fr_mode_; | ||
| 86 | return ResultSuccess; | ||
| 87 | } | ||
| 88 | |||
| 89 | Result Controller_Palma::ReadPalmaStep(const PalmaConnectionHandle& handle) { | ||
| 90 | if (handle.npad_id != active_handle.npad_id) { | ||
| 91 | return InvalidPalmaHandle; | ||
| 92 | } | ||
| 93 | operation.operation = PalmaOperationType::ReadStep; | ||
| 94 | operation.result = PalmaResultSuccess; | ||
| 95 | operation.data = {}; | ||
| 96 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 97 | return ResultSuccess; | ||
| 98 | } | ||
| 99 | |||
| 100 | Result Controller_Palma::EnablePalmaStep(const PalmaConnectionHandle& handle, bool is_enabled) { | ||
| 101 | if (handle.npad_id != active_handle.npad_id) { | ||
| 102 | return InvalidPalmaHandle; | ||
| 103 | } | ||
| 104 | return ResultSuccess; | ||
| 105 | } | ||
| 106 | |||
| 107 | Result Controller_Palma::ResetPalmaStep(const PalmaConnectionHandle& handle) { | ||
| 108 | if (handle.npad_id != active_handle.npad_id) { | ||
| 109 | return InvalidPalmaHandle; | ||
| 110 | } | ||
| 111 | return ResultSuccess; | ||
| 112 | } | ||
| 113 | |||
| 114 | void Controller_Palma::ReadPalmaApplicationSection() {} | ||
| 115 | |||
| 116 | void Controller_Palma::WritePalmaApplicationSection() {} | ||
| 117 | |||
| 118 | Result Controller_Palma::ReadPalmaUniqueCode(const PalmaConnectionHandle& handle) { | ||
| 119 | if (handle.npad_id != active_handle.npad_id) { | ||
| 120 | return InvalidPalmaHandle; | ||
| 121 | } | ||
| 122 | operation.operation = PalmaOperationType::ReadUniqueCode; | ||
| 123 | operation.result = PalmaResultSuccess; | ||
| 124 | operation.data = {}; | ||
| 125 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 126 | return ResultSuccess; | ||
| 127 | } | ||
| 128 | |||
| 129 | Result Controller_Palma::SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle) { | ||
| 130 | if (handle.npad_id != active_handle.npad_id) { | ||
| 131 | return InvalidPalmaHandle; | ||
| 132 | } | ||
| 133 | operation.operation = PalmaOperationType::SetUniqueCodeInvalid; | ||
| 134 | operation.result = PalmaResultSuccess; | ||
| 135 | operation.data = {}; | ||
| 136 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 137 | return ResultSuccess; | ||
| 138 | } | ||
| 139 | |||
| 140 | void Controller_Palma::WritePalmaActivityEntry() {} | ||
| 141 | |||
| 142 | Result Controller_Palma::WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, | ||
| 143 | u64 unknown) { | ||
| 144 | if (handle.npad_id != active_handle.npad_id) { | ||
| 145 | return InvalidPalmaHandle; | ||
| 146 | } | ||
| 147 | operation.operation = PalmaOperationType::WriteRgbLedPatternEntry; | ||
| 148 | operation.result = PalmaResultSuccess; | ||
| 149 | operation.data = {}; | ||
| 150 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 151 | return ResultSuccess; | ||
| 152 | } | ||
| 153 | |||
| 154 | Result Controller_Palma::WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave, | ||
| 155 | u8* t_mem, u64 size) { | ||
| 156 | if (handle.npad_id != active_handle.npad_id) { | ||
| 157 | return InvalidPalmaHandle; | ||
| 158 | } | ||
| 159 | operation.operation = PalmaOperationType::WriteWaveEntry; | ||
| 160 | operation.result = PalmaResultSuccess; | ||
| 161 | operation.data = {}; | ||
| 162 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 163 | return ResultSuccess; | ||
| 164 | } | ||
| 165 | |||
| 166 | Result Controller_Palma::SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle, | ||
| 167 | s32 database_id_version_) { | ||
| 168 | if (handle.npad_id != active_handle.npad_id) { | ||
| 169 | return InvalidPalmaHandle; | ||
| 170 | } | ||
| 171 | database_id_version = database_id_version_; | ||
| 172 | operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; | ||
| 173 | operation.result = PalmaResultSuccess; | ||
| 174 | operation.data[0] = {}; | ||
| 175 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 176 | return ResultSuccess; | ||
| 177 | } | ||
| 178 | |||
| 179 | Result Controller_Palma::GetPalmaDataBaseIdentificationVersion( | ||
| 180 | const PalmaConnectionHandle& handle) { | ||
| 181 | if (handle.npad_id != active_handle.npad_id) { | ||
| 182 | return InvalidPalmaHandle; | ||
| 183 | } | ||
| 184 | operation.operation = PalmaOperationType::ReadDataBaseIdentificationVersion; | ||
| 185 | operation.result = PalmaResultSuccess; | ||
| 186 | operation.data = {}; | ||
| 187 | operation.data[0] = static_cast<u8>(database_id_version); | ||
| 188 | operation_complete_event->GetWritableEvent().Signal(); | ||
| 189 | return ResultSuccess; | ||
| 190 | } | ||
| 191 | |||
| 192 | void Controller_Palma::SuspendPalmaFeature() {} | ||
| 193 | |||
| 194 | Result Controller_Palma::GetPalmaOperationResult(const PalmaConnectionHandle& handle) const { | ||
| 195 | if (handle.npad_id != active_handle.npad_id) { | ||
| 196 | return InvalidPalmaHandle; | ||
| 197 | } | ||
| 198 | return operation.result; | ||
| 199 | } | ||
| 200 | void Controller_Palma::ReadPalmaPlayLog() {} | ||
| 201 | |||
| 202 | void Controller_Palma::ResetPalmaPlayLog() {} | ||
| 203 | |||
| 204 | void Controller_Palma::SetIsPalmaAllConnectable(bool is_all_connectable) { | ||
| 205 | // If true controllers are able to be paired | ||
| 206 | is_connectable = is_all_connectable; | ||
| 207 | } | ||
| 208 | |||
| 209 | void Controller_Palma::SetIsPalmaPairedConnectable() {} | ||
| 210 | |||
| 211 | Result Controller_Palma::PairPalma(const PalmaConnectionHandle& handle) { | ||
| 212 | if (handle.npad_id != active_handle.npad_id) { | ||
| 213 | return InvalidPalmaHandle; | ||
| 214 | } | ||
| 215 | // TODO: Do something | ||
| 216 | return ResultSuccess; | ||
| 217 | } | ||
| 218 | |||
| 219 | void Controller_Palma::SetPalmaBoostMode(bool boost_mode) {} | ||
| 220 | |||
| 221 | void Controller_Palma::CancelWritePalmaWaveEntry() {} | ||
| 222 | |||
| 223 | void Controller_Palma::EnablePalmaBoostMode() {} | ||
| 224 | |||
| 225 | void Controller_Palma::GetPalmaBluetoothAddress() {} | ||
| 226 | |||
| 227 | void Controller_Palma::SetDisallowedPalmaConnection() {} | ||
| 228 | |||
| 229 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/controllers/palma.h b/src/core/hle/service/hid/controllers/palma.h new file mode 100644 index 000000000..1d7fc94e1 --- /dev/null +++ b/src/core/hle/service/hid/controllers/palma.h | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | #include "common/common_funcs.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | #include "core/hle/service/hid/controllers/controller_base.h" | ||
| 10 | #include "core/hle/service/hid/errors.h" | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | class KEvent; | ||
| 14 | class KReadableEvent; | ||
| 15 | } // namespace Kernel | ||
| 16 | |||
| 17 | namespace Service::KernelHelpers { | ||
| 18 | class ServiceContext; | ||
| 19 | } | ||
| 20 | |||
| 21 | namespace Core::HID { | ||
| 22 | class EmulatedController; | ||
| 23 | } // namespace Core::HID | ||
| 24 | |||
| 25 | namespace Service::HID { | ||
| 26 | class Controller_Palma final : public ControllerBase { | ||
| 27 | public: | ||
| 28 | using PalmaOperationData = std::array<u8, 0x140>; | ||
| 29 | |||
| 30 | // This is nn::hid::PalmaOperationType | ||
| 31 | enum class PalmaOperationType { | ||
| 32 | PlayActivity, | ||
| 33 | SetFrModeType, | ||
| 34 | ReadStep, | ||
| 35 | EnableStep, | ||
| 36 | ResetStep, | ||
| 37 | ReadApplicationSection, | ||
| 38 | WriteApplicationSection, | ||
| 39 | ReadUniqueCode, | ||
| 40 | SetUniqueCodeInvalid, | ||
| 41 | WriteActivityEntry, | ||
| 42 | WriteRgbLedPatternEntry, | ||
| 43 | WriteWaveEntry, | ||
| 44 | ReadDataBaseIdentificationVersion, | ||
| 45 | WriteDataBaseIdentificationVersion, | ||
| 46 | SuspendFeature, | ||
| 47 | ReadPlayLog, | ||
| 48 | ResetPlayLog, | ||
| 49 | }; | ||
| 50 | |||
| 51 | // This is nn::hid::PalmaWaveSet | ||
| 52 | enum class PalmaWaveSet : u64 { | ||
| 53 | Small, | ||
| 54 | Medium, | ||
| 55 | Large, | ||
| 56 | }; | ||
| 57 | |||
| 58 | // This is nn::hid::PalmaFrModeType | ||
| 59 | enum class PalmaFrModeType : u64 { | ||
| 60 | Off, | ||
| 61 | B01, | ||
| 62 | B02, | ||
| 63 | B03, | ||
| 64 | Downloaded, | ||
| 65 | }; | ||
| 66 | |||
| 67 | // This is nn::hid::PalmaFeature | ||
| 68 | enum class PalmaFeature : u64 { | ||
| 69 | FrMode, | ||
| 70 | RumbleFeedback, | ||
| 71 | Step, | ||
| 72 | MuteSwitch, | ||
| 73 | }; | ||
| 74 | |||
| 75 | // This is nn::hid::PalmaOperationInfo | ||
| 76 | struct PalmaOperationInfo { | ||
| 77 | PalmaOperationType operation{}; | ||
| 78 | Result result{PalmaResultSuccess}; | ||
| 79 | PalmaOperationData data{}; | ||
| 80 | }; | ||
| 81 | static_assert(sizeof(PalmaOperationInfo) == 0x148, "PalmaOperationInfo is an invalid size"); | ||
| 82 | |||
| 83 | // This is nn::hid::PalmaActivityEntry | ||
| 84 | struct PalmaActivityEntry { | ||
| 85 | u32 rgb_led_pattern_index; | ||
| 86 | INSERT_PADDING_BYTES(2); | ||
| 87 | PalmaWaveSet wave_set; | ||
| 88 | u32 wave_index; | ||
| 89 | INSERT_PADDING_BYTES(12); | ||
| 90 | }; | ||
| 91 | static_assert(sizeof(PalmaActivityEntry) == 0x20, "PalmaActivityEntry is an invalid size"); | ||
| 92 | |||
| 93 | struct PalmaConnectionHandle { | ||
| 94 | Core::HID::NpadIdType npad_id; | ||
| 95 | INSERT_PADDING_BYTES(4); // Unknown | ||
| 96 | }; | ||
| 97 | static_assert(sizeof(PalmaConnectionHandle) == 0x8, | ||
| 98 | "PalmaConnectionHandle has incorrect size."); | ||
| 99 | |||
| 100 | explicit Controller_Palma(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_, | ||
| 101 | KernelHelpers::ServiceContext& service_context_); | ||
| 102 | ~Controller_Palma() override; | ||
| 103 | |||
| 104 | // Called when the controller is initialized | ||
| 105 | void OnInit() override; | ||
| 106 | |||
| 107 | // When the controller is released | ||
| 108 | void OnRelease() override; | ||
| 109 | |||
| 110 | // When the controller is requesting an update for the shared memory | ||
| 111 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | ||
| 112 | |||
| 113 | Result GetPalmaConnectionHandle(Core::HID::NpadIdType npad_id, PalmaConnectionHandle& handle); | ||
| 114 | Result InitializePalma(const PalmaConnectionHandle& handle); | ||
| 115 | Kernel::KReadableEvent& AcquirePalmaOperationCompleteEvent( | ||
| 116 | const PalmaConnectionHandle& handle) const; | ||
| 117 | Result GetPalmaOperationInfo(const PalmaConnectionHandle& handle, | ||
| 118 | PalmaOperationType& operation_type, | ||
| 119 | PalmaOperationData& data) const; | ||
| 120 | Result PlayPalmaActivity(const PalmaConnectionHandle& handle, u64 palma_activity); | ||
| 121 | Result SetPalmaFrModeType(const PalmaConnectionHandle& handle, PalmaFrModeType fr_mode_); | ||
| 122 | Result ReadPalmaStep(const PalmaConnectionHandle& handle); | ||
| 123 | Result EnablePalmaStep(const PalmaConnectionHandle& handle, bool is_enabled); | ||
| 124 | Result ResetPalmaStep(const PalmaConnectionHandle& handle); | ||
| 125 | Result ReadPalmaUniqueCode(const PalmaConnectionHandle& handle); | ||
| 126 | Result SetPalmaUniqueCodeInvalid(const PalmaConnectionHandle& handle); | ||
| 127 | Result WritePalmaRgbLedPatternEntry(const PalmaConnectionHandle& handle, u64 unknown); | ||
| 128 | Result WritePalmaWaveEntry(const PalmaConnectionHandle& handle, PalmaWaveSet wave, u8* t_mem, | ||
| 129 | u64 size); | ||
| 130 | Result SetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle, | ||
| 131 | s32 database_id_version_); | ||
| 132 | Result GetPalmaDataBaseIdentificationVersion(const PalmaConnectionHandle& handle); | ||
| 133 | Result GetPalmaOperationResult(const PalmaConnectionHandle& handle) const; | ||
| 134 | void SetIsPalmaAllConnectable(bool is_all_connectable); | ||
| 135 | Result PairPalma(const PalmaConnectionHandle& handle); | ||
| 136 | void SetPalmaBoostMode(bool boost_mode); | ||
| 137 | |||
| 138 | private: | ||
| 139 | void ReadPalmaApplicationSection(); | ||
| 140 | void WritePalmaApplicationSection(); | ||
| 141 | void WritePalmaActivityEntry(); | ||
| 142 | void SuspendPalmaFeature(); | ||
| 143 | void ReadPalmaPlayLog(); | ||
| 144 | void ResetPalmaPlayLog(); | ||
| 145 | void SetIsPalmaPairedConnectable(); | ||
| 146 | void CancelWritePalmaWaveEntry(); | ||
| 147 | void EnablePalmaBoostMode(); | ||
| 148 | void GetPalmaBluetoothAddress(); | ||
| 149 | void SetDisallowedPalmaConnection(); | ||
| 150 | |||
| 151 | bool is_connectable{}; | ||
| 152 | s32 database_id_version{}; | ||
| 153 | PalmaOperationInfo operation{}; | ||
| 154 | PalmaFrModeType fr_mode{}; | ||
| 155 | PalmaConnectionHandle active_handle{}; | ||
| 156 | |||
| 157 | Core::HID::EmulatedController* controller; | ||
| 158 | |||
| 159 | Kernel::KEvent* operation_complete_event; | ||
| 160 | KernelHelpers::ServiceContext& service_context; | ||
| 161 | }; | ||
| 162 | |||
| 163 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.h index 4613a4e60..76208e9a4 100644 --- a/src/core/hle/service/hid/errors.h +++ b/src/core/hle/service/hid/errors.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | namespace Service::HID { | 8 | namespace Service::HID { |
| 9 | 9 | ||
| 10 | constexpr Result PalmaResultSuccess{ErrorModule::HID, 0}; | ||
| 10 | constexpr Result NpadInvalidHandle{ErrorModule::HID, 100}; | 11 | constexpr Result NpadInvalidHandle{ErrorModule::HID, 100}; |
| 11 | constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; | 12 | constexpr Result NpadDeviceIndexOutOfRange{ErrorModule::HID, 107}; |
| 12 | constexpr Result VibrationInvalidStyleIndex{ErrorModule::HID, 122}; | 13 | constexpr Result VibrationInvalidStyleIndex{ErrorModule::HID, 122}; |
| @@ -17,6 +18,7 @@ constexpr Result NpadIsDualJoycon{ErrorModule::HID, 601}; | |||
| 17 | constexpr Result NpadIsSameType{ErrorModule::HID, 602}; | 18 | constexpr Result NpadIsSameType{ErrorModule::HID, 602}; |
| 18 | constexpr Result InvalidNpadId{ErrorModule::HID, 709}; | 19 | constexpr Result InvalidNpadId{ErrorModule::HID, 709}; |
| 19 | constexpr Result NpadNotConnected{ErrorModule::HID, 710}; | 20 | constexpr Result NpadNotConnected{ErrorModule::HID, 710}; |
| 21 | constexpr Result InvalidPalmaHandle{ErrorModule::HID, 3302}; | ||
| 20 | 22 | ||
| 21 | } // namespace Service::HID | 23 | } // namespace Service::HID |
| 22 | 24 | ||
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 3d3457160..de3fae2cb 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include "core/hle/service/hid/controllers/keyboard.h" | 27 | #include "core/hle/service/hid/controllers/keyboard.h" |
| 28 | #include "core/hle/service/hid/controllers/mouse.h" | 28 | #include "core/hle/service/hid/controllers/mouse.h" |
| 29 | #include "core/hle/service/hid/controllers/npad.h" | 29 | #include "core/hle/service/hid/controllers/npad.h" |
| 30 | #include "core/hle/service/hid/controllers/palma.h" | ||
| 30 | #include "core/hle/service/hid/controllers/stubbed.h" | 31 | #include "core/hle/service/hid/controllers/stubbed.h" |
| 31 | #include "core/hle/service/hid/controllers/touchscreen.h" | 32 | #include "core/hle/service/hid/controllers/touchscreen.h" |
| 32 | #include "core/hle/service/hid/controllers/xpad.h" | 33 | #include "core/hle/service/hid/controllers/xpad.h" |
| @@ -60,6 +61,7 @@ IAppletResource::IAppletResource(Core::System& system_, | |||
| 60 | MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory); | 61 | MakeControllerWithServiceContext<Controller_NPad>(HidController::NPad, shared_memory); |
| 61 | MakeController<Controller_Gesture>(HidController::Gesture, shared_memory); | 62 | MakeController<Controller_Gesture>(HidController::Gesture, shared_memory); |
| 62 | MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory); | 63 | MakeController<Controller_ConsoleSixAxis>(HidController::ConsoleSixAxisSensor, shared_memory); |
| 64 | MakeControllerWithServiceContext<Controller_Palma>(HidController::Palma, shared_memory); | ||
| 63 | 65 | ||
| 64 | // Homebrew doesn't try to activate some controllers, so we activate them by default | 66 | // Homebrew doesn't try to activate some controllers, so we activate them by default |
| 65 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); | 67 | GetController<Controller_NPad>(HidController::NPad).ActivateController(); |
| @@ -310,36 +312,36 @@ Hid::Hid(Core::System& system_) | |||
| 310 | {406, nullptr, "GetNpadLeftRightInterfaceType"}, | 312 | {406, nullptr, "GetNpadLeftRightInterfaceType"}, |
| 311 | {407, nullptr, "GetNpadOfHighestBatteryLevel"}, | 313 | {407, nullptr, "GetNpadOfHighestBatteryLevel"}, |
| 312 | {408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"}, | 314 | {408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"}, |
| 313 | {500, nullptr, "GetPalmaConnectionHandle"}, | 315 | {500, &Hid::GetPalmaConnectionHandle, "GetPalmaConnectionHandle"}, |
| 314 | {501, nullptr, "InitializePalma"}, | 316 | {501, &Hid::InitializePalma, "InitializePalma"}, |
| 315 | {502, nullptr, "AcquirePalmaOperationCompleteEvent"}, | 317 | {502, &Hid::AcquirePalmaOperationCompleteEvent, "AcquirePalmaOperationCompleteEvent"}, |
| 316 | {503, nullptr, "GetPalmaOperationInfo"}, | 318 | {503, &Hid::GetPalmaOperationInfo, "GetPalmaOperationInfo"}, |
| 317 | {504, nullptr, "PlayPalmaActivity"}, | 319 | {504, &Hid::PlayPalmaActivity, "PlayPalmaActivity"}, |
| 318 | {505, nullptr, "SetPalmaFrModeType"}, | 320 | {505, &Hid::SetPalmaFrModeType, "SetPalmaFrModeType"}, |
| 319 | {506, nullptr, "ReadPalmaStep"}, | 321 | {506, &Hid::ReadPalmaStep, "ReadPalmaStep"}, |
| 320 | {507, nullptr, "EnablePalmaStep"}, | 322 | {507, &Hid::EnablePalmaStep, "EnablePalmaStep"}, |
| 321 | {508, nullptr, "ResetPalmaStep"}, | 323 | {508, &Hid::ResetPalmaStep, "ResetPalmaStep"}, |
| 322 | {509, nullptr, "ReadPalmaApplicationSection"}, | 324 | {509, &Hid::ReadPalmaApplicationSection, "ReadPalmaApplicationSection"}, |
| 323 | {510, nullptr, "WritePalmaApplicationSection"}, | 325 | {510, &Hid::WritePalmaApplicationSection, "WritePalmaApplicationSection"}, |
| 324 | {511, nullptr, "ReadPalmaUniqueCode"}, | 326 | {511, &Hid::ReadPalmaUniqueCode, "ReadPalmaUniqueCode"}, |
| 325 | {512, nullptr, "SetPalmaUniqueCodeInvalid"}, | 327 | {512, &Hid::SetPalmaUniqueCodeInvalid, "SetPalmaUniqueCodeInvalid"}, |
| 326 | {513, nullptr, "WritePalmaActivityEntry"}, | 328 | {513, &Hid::WritePalmaActivityEntry, "WritePalmaActivityEntry"}, |
| 327 | {514, nullptr, "WritePalmaRgbLedPatternEntry"}, | 329 | {514, &Hid::WritePalmaRgbLedPatternEntry, "WritePalmaRgbLedPatternEntry"}, |
| 328 | {515, nullptr, "WritePalmaWaveEntry"}, | 330 | {515, &Hid::WritePalmaWaveEntry, "WritePalmaWaveEntry"}, |
| 329 | {516, nullptr, "SetPalmaDataBaseIdentificationVersion"}, | 331 | {516, &Hid::SetPalmaDataBaseIdentificationVersion, "SetPalmaDataBaseIdentificationVersion"}, |
| 330 | {517, nullptr, "GetPalmaDataBaseIdentificationVersion"}, | 332 | {517, &Hid::GetPalmaDataBaseIdentificationVersion, "GetPalmaDataBaseIdentificationVersion"}, |
| 331 | {518, nullptr, "SuspendPalmaFeature"}, | 333 | {518, &Hid::SuspendPalmaFeature, "SuspendPalmaFeature"}, |
| 332 | {519, nullptr, "GetPalmaOperationResult"}, | 334 | {519, &Hid::GetPalmaOperationResult, "GetPalmaOperationResult"}, |
| 333 | {520, nullptr, "ReadPalmaPlayLog"}, | 335 | {520, &Hid::ReadPalmaPlayLog, "ReadPalmaPlayLog"}, |
| 334 | {521, nullptr, "ResetPalmaPlayLog"}, | 336 | {521, &Hid::ResetPalmaPlayLog, "ResetPalmaPlayLog"}, |
| 335 | {522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, | 337 | {522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, |
| 336 | {523, nullptr, "SetIsPalmaPairedConnectable"}, | 338 | {523, &Hid::SetIsPalmaPairedConnectable, "SetIsPalmaPairedConnectable"}, |
| 337 | {524, nullptr, "PairPalma"}, | 339 | {524, &Hid::PairPalma, "PairPalma"}, |
| 338 | {525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"}, | 340 | {525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"}, |
| 339 | {526, nullptr, "CancelWritePalmaWaveEntry"}, | 341 | {526, &Hid::CancelWritePalmaWaveEntry, "CancelWritePalmaWaveEntry"}, |
| 340 | {527, nullptr, "EnablePalmaBoostMode"}, | 342 | {527, &Hid::EnablePalmaBoostMode, "EnablePalmaBoostMode"}, |
| 341 | {528, nullptr, "GetPalmaBluetoothAddress"}, | 343 | {528, &Hid::GetPalmaBluetoothAddress, "GetPalmaBluetoothAddress"}, |
| 342 | {529, nullptr, "SetDisallowedPalmaConnection"}, | 344 | {529, &Hid::SetDisallowedPalmaConnection, "SetDisallowedPalmaConnection"}, |
| 343 | {1000, &Hid::SetNpadCommunicationMode, "SetNpadCommunicationMode"}, | 345 | {1000, &Hid::SetNpadCommunicationMode, "SetNpadCommunicationMode"}, |
| 344 | {1001, &Hid::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, | 346 | {1001, &Hid::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, |
| 345 | {1002, &Hid::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, | 347 | {1002, &Hid::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, |
| @@ -1878,14 +1880,361 @@ void Hid::IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx) { | |||
| 1878 | rb.Push(false); | 1880 | rb.Push(false); |
| 1879 | } | 1881 | } |
| 1880 | 1882 | ||
| 1883 | void Hid::GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx) { | ||
| 1884 | IPC::RequestParser rp{ctx}; | ||
| 1885 | struct Parameters { | ||
| 1886 | Core::HID::NpadIdType npad_id; | ||
| 1887 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 1888 | u64 applet_resource_user_id; | ||
| 1889 | }; | ||
| 1890 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 1891 | |||
| 1892 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 1893 | |||
| 1894 | LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", | ||
| 1895 | parameters.npad_id, parameters.applet_resource_user_id); | ||
| 1896 | |||
| 1897 | Controller_Palma::PalmaConnectionHandle handle; | ||
| 1898 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1899 | const auto result = controller.GetPalmaConnectionHandle(parameters.npad_id, handle); | ||
| 1900 | |||
| 1901 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 1902 | rb.Push(result); | ||
| 1903 | rb.PushRaw(handle); | ||
| 1904 | } | ||
| 1905 | |||
| 1906 | void Hid::InitializePalma(Kernel::HLERequestContext& ctx) { | ||
| 1907 | IPC::RequestParser rp{ctx}; | ||
| 1908 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1909 | |||
| 1910 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 1911 | |||
| 1912 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1913 | const auto result = controller.InitializePalma(connection_handle); | ||
| 1914 | |||
| 1915 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1916 | rb.Push(result); | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | void Hid::AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx) { | ||
| 1920 | IPC::RequestParser rp{ctx}; | ||
| 1921 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1922 | |||
| 1923 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 1924 | |||
| 1925 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1926 | |||
| 1927 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 1928 | rb.Push(ResultSuccess); | ||
| 1929 | rb.PushCopyObjects(controller.AcquirePalmaOperationCompleteEvent(connection_handle)); | ||
| 1930 | } | ||
| 1931 | |||
| 1932 | void Hid::GetPalmaOperationInfo(Kernel::HLERequestContext& ctx) { | ||
| 1933 | IPC::RequestParser rp{ctx}; | ||
| 1934 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1935 | |||
| 1936 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 1937 | |||
| 1938 | Controller_Palma::PalmaOperationType operation_type; | ||
| 1939 | Controller_Palma::PalmaOperationData data; | ||
| 1940 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1941 | const auto result = controller.GetPalmaOperationInfo(connection_handle, operation_type, data); | ||
| 1942 | |||
| 1943 | if (result.IsError()) { | ||
| 1944 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1945 | rb.Push(result); | ||
| 1946 | } | ||
| 1947 | |||
| 1948 | ctx.WriteBuffer(data); | ||
| 1949 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 1950 | rb.Push(result); | ||
| 1951 | rb.Push(static_cast<u64>(operation_type)); | ||
| 1952 | } | ||
| 1953 | |||
| 1954 | void Hid::PlayPalmaActivity(Kernel::HLERequestContext& ctx) { | ||
| 1955 | IPC::RequestParser rp{ctx}; | ||
| 1956 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1957 | const auto palma_activity{rp.Pop<u64>()}; | ||
| 1958 | |||
| 1959 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, palma_activity={}", | ||
| 1960 | connection_handle.npad_id, palma_activity); | ||
| 1961 | |||
| 1962 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1963 | const auto result = controller.PlayPalmaActivity(connection_handle, palma_activity); | ||
| 1964 | |||
| 1965 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1966 | rb.Push(result); | ||
| 1967 | } | ||
| 1968 | |||
| 1969 | void Hid::SetPalmaFrModeType(Kernel::HLERequestContext& ctx) { | ||
| 1970 | IPC::RequestParser rp{ctx}; | ||
| 1971 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1972 | const auto fr_mode{rp.PopEnum<Controller_Palma::PalmaFrModeType>()}; | ||
| 1973 | |||
| 1974 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, fr_mode={}", | ||
| 1975 | connection_handle.npad_id, fr_mode); | ||
| 1976 | |||
| 1977 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1978 | const auto result = controller.SetPalmaFrModeType(connection_handle, fr_mode); | ||
| 1979 | |||
| 1980 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1981 | rb.Push(result); | ||
| 1982 | } | ||
| 1983 | |||
| 1984 | void Hid::ReadPalmaStep(Kernel::HLERequestContext& ctx) { | ||
| 1985 | IPC::RequestParser rp{ctx}; | ||
| 1986 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 1987 | |||
| 1988 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 1989 | |||
| 1990 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 1991 | const auto result = controller.ReadPalmaStep(connection_handle); | ||
| 1992 | |||
| 1993 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 1994 | rb.Push(result); | ||
| 1995 | } | ||
| 1996 | |||
| 1997 | void Hid::EnablePalmaStep(Kernel::HLERequestContext& ctx) { | ||
| 1998 | IPC::RequestParser rp{ctx}; | ||
| 1999 | struct Parameters { | ||
| 2000 | bool is_enabled; | ||
| 2001 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 2002 | Controller_Palma::PalmaConnectionHandle connection_handle; | ||
| 2003 | }; | ||
| 2004 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 2005 | |||
| 2006 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 2007 | |||
| 2008 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, is_enabled={}", | ||
| 2009 | parameters.connection_handle.npad_id, parameters.is_enabled); | ||
| 2010 | |||
| 2011 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 2012 | const auto result = | ||
| 2013 | controller.EnablePalmaStep(parameters.connection_handle, parameters.is_enabled); | ||
| 2014 | |||
| 2015 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2016 | rb.Push(result); | ||
| 2017 | } | ||
| 2018 | |||
| 2019 | void Hid::ResetPalmaStep(Kernel::HLERequestContext& ctx) { | ||
| 2020 | IPC::RequestParser rp{ctx}; | ||
| 2021 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2022 | |||
| 2023 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2024 | |||
| 2025 | auto& controller = GetAppletResource()->GetController<Controller_Palma>(HidController::Palma); | ||
| 2026 | const auto result = controller.ResetPalmaStep(connection_handle); | ||
| 2027 | |||
| 2028 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2029 | rb.Push(result); | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | void Hid::ReadPalmaApplicationSection(Kernel::HLERequestContext& ctx) { | ||
| 2033 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2034 | |||
| 2035 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2036 | rb.Push(ResultSuccess); | ||
| 2037 | } | ||
| 2038 | |||
| 2039 | void Hid::WritePalmaApplicationSection(Kernel::HLERequestContext& ctx) { | ||
| 2040 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2041 | |||
| 2042 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2043 | rb.Push(ResultSuccess); | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | void Hid::ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx) { | ||
| 2047 | IPC::RequestParser rp{ctx}; | ||
| 2048 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2049 | |||
| 2050 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2051 | |||
| 2052 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2053 | .ReadPalmaUniqueCode(connection_handle); | ||
| 2054 | |||
| 2055 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2056 | rb.Push(ResultSuccess); | ||
| 2057 | } | ||
| 2058 | |||
| 2059 | void Hid::SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx) { | ||
| 2060 | IPC::RequestParser rp{ctx}; | ||
| 2061 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2062 | |||
| 2063 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2064 | |||
| 2065 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2066 | .SetPalmaUniqueCodeInvalid(connection_handle); | ||
| 2067 | |||
| 2068 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2069 | rb.Push(ResultSuccess); | ||
| 2070 | } | ||
| 2071 | |||
| 2072 | void Hid::WritePalmaActivityEntry(Kernel::HLERequestContext& ctx) { | ||
| 2073 | LOG_CRITICAL(Service_HID, "(STUBBED) called"); | ||
| 2074 | |||
| 2075 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2076 | rb.Push(ResultSuccess); | ||
| 2077 | } | ||
| 2078 | |||
| 2079 | void Hid::WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx) { | ||
| 2080 | IPC::RequestParser rp{ctx}; | ||
| 2081 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2082 | const auto unknown{rp.Pop<u64>()}; | ||
| 2083 | |||
| 2084 | const auto buffer = ctx.ReadBuffer(); | ||
| 2085 | |||
| 2086 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}", | ||
| 2087 | connection_handle.npad_id, unknown); | ||
| 2088 | |||
| 2089 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2090 | .WritePalmaRgbLedPatternEntry(connection_handle, unknown); | ||
| 2091 | |||
| 2092 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2093 | rb.Push(ResultSuccess); | ||
| 2094 | } | ||
| 2095 | |||
| 2096 | void Hid::WritePalmaWaveEntry(Kernel::HLERequestContext& ctx) { | ||
| 2097 | IPC::RequestParser rp{ctx}; | ||
| 2098 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2099 | const auto wave_set{rp.PopEnum<Controller_Palma::PalmaWaveSet>()}; | ||
| 2100 | const auto unknown{rp.Pop<u64>()}; | ||
| 2101 | const auto t_mem_size{rp.Pop<u64>()}; | ||
| 2102 | const auto t_mem_handle{ctx.GetCopyHandle(0)}; | ||
| 2103 | const auto size{rp.Pop<u64>()}; | ||
| 2104 | |||
| 2105 | ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes"); | ||
| 2106 | |||
| 2107 | auto t_mem = | ||
| 2108 | system.CurrentProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(t_mem_handle); | ||
| 2109 | |||
| 2110 | if (t_mem.IsNull()) { | ||
| 2111 | LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle); | ||
| 2112 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2113 | rb.Push(ResultUnknown); | ||
| 2114 | return; | ||
| 2115 | } | ||
| 2116 | |||
| 2117 | ASSERT_MSG(t_mem->GetSize() == 0x3000, "t_mem has incorrect size"); | ||
| 2118 | |||
| 2119 | LOG_WARNING(Service_HID, | ||
| 2120 | "(STUBBED) called, connection_handle={}, wave_set={}, unkown={}, " | ||
| 2121 | "t_mem_handle=0x{:08X}, t_mem_size={}, size={}", | ||
| 2122 | connection_handle.npad_id, wave_set, unknown, t_mem_handle, t_mem_size, size); | ||
| 2123 | |||
| 2124 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2125 | .WritePalmaWaveEntry(connection_handle, wave_set, | ||
| 2126 | system.Memory().GetPointer(t_mem->GetSourceAddress()), t_mem_size); | ||
| 2127 | |||
| 2128 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2129 | rb.Push(ResultSuccess); | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | void Hid::SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) { | ||
| 2133 | IPC::RequestParser rp{ctx}; | ||
| 2134 | struct Parameters { | ||
| 2135 | s32 database_id_version; | ||
| 2136 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 2137 | Controller_Palma::PalmaConnectionHandle connection_handle; | ||
| 2138 | }; | ||
| 2139 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 2140 | |||
| 2141 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 2142 | |||
| 2143 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, database_id_version={}", | ||
| 2144 | parameters.connection_handle.npad_id, parameters.database_id_version); | ||
| 2145 | |||
| 2146 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2147 | .SetPalmaDataBaseIdentificationVersion(parameters.connection_handle, | ||
| 2148 | parameters.database_id_version); | ||
| 2149 | |||
| 2150 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2151 | rb.Push(ResultSuccess); | ||
| 2152 | } | ||
| 2153 | |||
| 2154 | void Hid::GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx) { | ||
| 2155 | IPC::RequestParser rp{ctx}; | ||
| 2156 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2157 | |||
| 2158 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2159 | |||
| 2160 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2161 | .GetPalmaDataBaseIdentificationVersion(connection_handle); | ||
| 2162 | |||
| 2163 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2164 | rb.Push(ResultSuccess); | ||
| 2165 | } | ||
| 2166 | |||
| 2167 | void Hid::SuspendPalmaFeature(Kernel::HLERequestContext& ctx) { | ||
| 2168 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2169 | |||
| 2170 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2171 | rb.Push(ResultSuccess); | ||
| 2172 | } | ||
| 2173 | |||
| 2174 | void Hid::GetPalmaOperationResult(Kernel::HLERequestContext& ctx) { | ||
| 2175 | IPC::RequestParser rp{ctx}; | ||
| 2176 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2177 | |||
| 2178 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2179 | |||
| 2180 | const auto result = applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2181 | .GetPalmaOperationResult(connection_handle); | ||
| 2182 | |||
| 2183 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2184 | rb.Push(result); | ||
| 2185 | } | ||
| 2186 | |||
| 2187 | void Hid::ReadPalmaPlayLog(Kernel::HLERequestContext& ctx) { | ||
| 2188 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2189 | |||
| 2190 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2191 | rb.Push(ResultSuccess); | ||
| 2192 | } | ||
| 2193 | |||
| 2194 | void Hid::ResetPalmaPlayLog(Kernel::HLERequestContext& ctx) { | ||
| 2195 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2196 | |||
| 2197 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2198 | rb.Push(ResultSuccess); | ||
| 2199 | } | ||
| 2200 | |||
| 1881 | void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { | 2201 | void Hid::SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { |
| 1882 | IPC::RequestParser rp{ctx}; | 2202 | IPC::RequestParser rp{ctx}; |
| 1883 | const auto applet_resource_user_id{rp.Pop<u64>()}; | 2203 | struct Parameters { |
| 1884 | const auto is_palma_all_connectable{rp.Pop<bool>()}; | 2204 | bool is_palma_all_connectable; |
| 2205 | INSERT_PADDING_BYTES_NOINIT(7); | ||
| 2206 | u64 applet_resource_user_id; | ||
| 2207 | }; | ||
| 2208 | static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size."); | ||
| 2209 | |||
| 2210 | const auto parameters{rp.PopRaw<Parameters>()}; | ||
| 1885 | 2211 | ||
| 1886 | LOG_WARNING(Service_HID, | 2212 | LOG_WARNING(Service_HID, |
| 1887 | "(STUBBED) called, applet_resource_user_id={}, is_palma_all_connectable={}", | 2213 | "(STUBBED) called, is_palma_all_connectable={},applet_resource_user_id={}", |
| 1888 | applet_resource_user_id, is_palma_all_connectable); | 2214 | parameters.is_palma_all_connectable, parameters.applet_resource_user_id); |
| 2215 | |||
| 2216 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2217 | .SetIsPalmaAllConnectable(parameters.is_palma_all_connectable); | ||
| 2218 | |||
| 2219 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2220 | rb.Push(ResultSuccess); | ||
| 2221 | } | ||
| 2222 | |||
| 2223 | void Hid::SetIsPalmaPairedConnectable(Kernel::HLERequestContext& ctx) { | ||
| 2224 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2225 | |||
| 2226 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2227 | rb.Push(ResultSuccess); | ||
| 2228 | } | ||
| 2229 | |||
| 2230 | void Hid::PairPalma(Kernel::HLERequestContext& ctx) { | ||
| 2231 | IPC::RequestParser rp{ctx}; | ||
| 2232 | const auto connection_handle{rp.PopRaw<Controller_Palma::PalmaConnectionHandle>()}; | ||
| 2233 | |||
| 2234 | LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); | ||
| 2235 | |||
| 2236 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2237 | .PairPalma(connection_handle); | ||
| 1889 | 2238 | ||
| 1890 | IPC::ResponseBuilder rb{ctx, 2}; | 2239 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1891 | rb.Push(ResultSuccess); | 2240 | rb.Push(ResultSuccess); |
| @@ -1897,6 +2246,37 @@ void Hid::SetPalmaBoostMode(Kernel::HLERequestContext& ctx) { | |||
| 1897 | 2246 | ||
| 1898 | LOG_WARNING(Service_HID, "(STUBBED) called, palma_boost_mode={}", palma_boost_mode); | 2247 | LOG_WARNING(Service_HID, "(STUBBED) called, palma_boost_mode={}", palma_boost_mode); |
| 1899 | 2248 | ||
| 2249 | applet_resource->GetController<Controller_Palma>(HidController::Palma) | ||
| 2250 | .SetPalmaBoostMode(palma_boost_mode); | ||
| 2251 | |||
| 2252 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2253 | rb.Push(ResultSuccess); | ||
| 2254 | } | ||
| 2255 | |||
| 2256 | void Hid::CancelWritePalmaWaveEntry(Kernel::HLERequestContext& ctx) { | ||
| 2257 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2258 | |||
| 2259 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2260 | rb.Push(ResultSuccess); | ||
| 2261 | } | ||
| 2262 | |||
| 2263 | void Hid::EnablePalmaBoostMode(Kernel::HLERequestContext& ctx) { | ||
| 2264 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2265 | |||
| 2266 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2267 | rb.Push(ResultSuccess); | ||
| 2268 | } | ||
| 2269 | |||
| 2270 | void Hid::GetPalmaBluetoothAddress(Kernel::HLERequestContext& ctx) { | ||
| 2271 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2272 | |||
| 2273 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2274 | rb.Push(ResultSuccess); | ||
| 2275 | } | ||
| 2276 | |||
| 2277 | void Hid::SetDisallowedPalmaConnection(Kernel::HLERequestContext& ctx) { | ||
| 2278 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 2279 | |||
| 1900 | IPC::ResponseBuilder rb{ctx, 2}; | 2280 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1901 | rb.Push(ResultSuccess); | 2281 | rb.Push(ResultSuccess); |
| 1902 | } | 2282 | } |
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index ac4333022..340d26fdc 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -33,6 +33,7 @@ enum class HidController : std::size_t { | |||
| 33 | NPad, | 33 | NPad, |
| 34 | Gesture, | 34 | Gesture, |
| 35 | ConsoleSixAxisSensor, | 35 | ConsoleSixAxisSensor, |
| 36 | Palma, | ||
| 36 | 37 | ||
| 37 | MaxControllers, | 38 | MaxControllers, |
| 38 | }; | 39 | }; |
| @@ -166,8 +167,36 @@ private: | |||
| 166 | void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); | 167 | void FinalizeSevenSixAxisSensor(Kernel::HLERequestContext& ctx); |
| 167 | void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx); | 168 | void ResetSevenSixAxisSensorTimestamp(Kernel::HLERequestContext& ctx); |
| 168 | void IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx); | 169 | void IsUsbFullKeyControllerEnabled(Kernel::HLERequestContext& ctx); |
| 170 | void GetPalmaConnectionHandle(Kernel::HLERequestContext& ctx); | ||
| 171 | void InitializePalma(Kernel::HLERequestContext& ctx); | ||
| 172 | void AcquirePalmaOperationCompleteEvent(Kernel::HLERequestContext& ctx); | ||
| 173 | void GetPalmaOperationInfo(Kernel::HLERequestContext& ctx); | ||
| 174 | void PlayPalmaActivity(Kernel::HLERequestContext& ctx); | ||
| 175 | void SetPalmaFrModeType(Kernel::HLERequestContext& ctx); | ||
| 176 | void ReadPalmaStep(Kernel::HLERequestContext& ctx); | ||
| 177 | void EnablePalmaStep(Kernel::HLERequestContext& ctx); | ||
| 178 | void ResetPalmaStep(Kernel::HLERequestContext& ctx); | ||
| 179 | void ReadPalmaApplicationSection(Kernel::HLERequestContext& ctx); | ||
| 180 | void WritePalmaApplicationSection(Kernel::HLERequestContext& ctx); | ||
| 181 | void ReadPalmaUniqueCode(Kernel::HLERequestContext& ctx); | ||
| 182 | void SetPalmaUniqueCodeInvalid(Kernel::HLERequestContext& ctx); | ||
| 183 | void WritePalmaActivityEntry(Kernel::HLERequestContext& ctx); | ||
| 184 | void WritePalmaRgbLedPatternEntry(Kernel::HLERequestContext& ctx); | ||
| 185 | void WritePalmaWaveEntry(Kernel::HLERequestContext& ctx); | ||
| 186 | void SetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx); | ||
| 187 | void GetPalmaDataBaseIdentificationVersion(Kernel::HLERequestContext& ctx); | ||
| 188 | void SuspendPalmaFeature(Kernel::HLERequestContext& ctx); | ||
| 189 | void GetPalmaOperationResult(Kernel::HLERequestContext& ctx); | ||
| 190 | void ReadPalmaPlayLog(Kernel::HLERequestContext& ctx); | ||
| 191 | void ResetPalmaPlayLog(Kernel::HLERequestContext& ctx); | ||
| 169 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); | 192 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); |
| 193 | void SetIsPalmaPairedConnectable(Kernel::HLERequestContext& ctx); | ||
| 194 | void PairPalma(Kernel::HLERequestContext& ctx); | ||
| 170 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); | 195 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); |
| 196 | void CancelWritePalmaWaveEntry(Kernel::HLERequestContext& ctx); | ||
| 197 | void EnablePalmaBoostMode(Kernel::HLERequestContext& ctx); | ||
| 198 | void GetPalmaBluetoothAddress(Kernel::HLERequestContext& ctx); | ||
| 199 | void SetDisallowedPalmaConnection(Kernel::HLERequestContext& ctx); | ||
| 171 | void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx); | 200 | void SetNpadCommunicationMode(Kernel::HLERequestContext& ctx); |
| 172 | void GetNpadCommunicationMode(Kernel::HLERequestContext& ctx); | 201 | void GetNpadCommunicationMode(Kernel::HLERequestContext& ctx); |
| 173 | void SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx); | 202 | void SetTouchScreenConfiguration(Kernel::HLERequestContext& ctx); |