summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-02-22 17:21:36 -0600
committerGravatar Narr the Reg2024-02-23 17:49:02 -0600
commitfc6a87bba1d7f1b358778c3b5535315c8401aced (patch)
tree1a3972d281da3acddf0f9f34ca2afb262f41f0fa
parentservice: hid: Move and migrate AppletResource and ActiveVibrationDevice (diff)
downloadyuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.tar.gz
yuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.tar.xz
yuzu-fc6a87bba1d7f1b358778c3b5535315c8401aced.zip
service: hid: Migrate HidServer to new IPC
-rw-r--r--src/core/hle/service/hid/hid_server.cpp2547
-rw-r--r--src/core/hle/service/hid/hid_server.h352
-rw-r--r--src/hid_core/hid_types.h34
-rw-r--r--src/hid_core/resources/palma/palma.cpp24
-rw-r--r--src/hid_core/resources/palma/palma.h34
5 files changed, 1043 insertions, 1948 deletions
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 6942f6e82..926a3bfe9 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -10,9 +10,9 @@
10#include "core/hle/kernel/k_transfer_memory.h" 10#include "core/hle/kernel/k_transfer_memory.h"
11#include "core/hle/kernel/kernel.h" 11#include "core/hle/kernel/kernel.h"
12#include "core/hle/service/cmif_serialization.h" 12#include "core/hle/service/cmif_serialization.h"
13#include "core/hle/service/hid/hid_server.h"
14#include "core/hle/service/hid/active_vibration_device_list.h" 13#include "core/hle/service/hid/active_vibration_device_list.h"
15#include "core/hle/service/hid/applet_resource.h" 14#include "core/hle/service/hid/applet_resource.h"
15#include "core/hle/service/hid/hid_server.h"
16#include "core/hle/service/ipc_helpers.h" 16#include "core/hle/service/ipc_helpers.h"
17#include "core/memory.h" 17#include "core/memory.h"
18#include "hid_core/hid_result.h" 18#include "hid_core/hid_result.h"
@@ -44,102 +44,102 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
44 : ServiceFramework{system_, "hid"}, resource_manager{resource}, firmware_settings{settings} { 44 : ServiceFramework{system_, "hid"}, resource_manager{resource}, firmware_settings{settings} {
45 // clang-format off 45 // clang-format off
46 static const FunctionInfo functions[] = { 46 static const FunctionInfo functions[] = {
47 {0, &IHidServer::CreateAppletResource, "CreateAppletResource"}, 47 {0, C<&IHidServer::CreateAppletResource>, "CreateAppletResource"},
48 {1, &IHidServer::ActivateDebugPad, "ActivateDebugPad"}, 48 {1, C<&IHidServer::ActivateDebugPad>, "ActivateDebugPad"},
49 {11, &IHidServer::ActivateTouchScreen, "ActivateTouchScreen"}, 49 {11, C<&IHidServer::ActivateTouchScreen>, "ActivateTouchScreen"},
50 {21, &IHidServer::ActivateMouse, "ActivateMouse"}, 50 {21, C<&IHidServer::ActivateMouse>, "ActivateMouse"},
51 {26, nullptr, "ActivateDebugMouse"}, 51 {26, nullptr, "ActivateDebugMouse"},
52 {31, &IHidServer::ActivateKeyboard, "ActivateKeyboard"}, 52 {31, C<&IHidServer::ActivateKeyboard>, "ActivateKeyboard"},
53 {32, &IHidServer::SendKeyboardLockKeyEvent, "SendKeyboardLockKeyEvent"}, 53 {32, C<&IHidServer::SendKeyboardLockKeyEvent>, "SendKeyboardLockKeyEvent"},
54 {40, &IHidServer::AcquireXpadIdEventHandle, "AcquireXpadIdEventHandle"}, 54 {40, C<&IHidServer::AcquireXpadIdEventHandle>, "AcquireXpadIdEventHandle"},
55 {41, &IHidServer::ReleaseXpadIdEventHandle, "ReleaseXpadIdEventHandle"}, 55 {41, C<&IHidServer::ReleaseXpadIdEventHandle>, "ReleaseXpadIdEventHandle"},
56 {51, &IHidServer::ActivateXpad, "ActivateXpad"}, 56 {51, C<&IHidServer::ActivateXpad>, "ActivateXpad"},
57 {55, &IHidServer::GetXpadIds, "GetXpadIds"}, 57 {55, C<&IHidServer::GetXpadIds>, "GetXpadIds"},
58 {56, &IHidServer::ActivateJoyXpad, "ActivateJoyXpad"}, 58 {56, C<&IHidServer::ActivateJoyXpad>, "ActivateJoyXpad"},
59 {58, &IHidServer::GetJoyXpadLifoHandle, "GetJoyXpadLifoHandle"}, 59 {58, C<&IHidServer::GetJoyXpadLifoHandle>, "GetJoyXpadLifoHandle"},
60 {59, &IHidServer::GetJoyXpadIds, "GetJoyXpadIds"}, 60 {59, C<&IHidServer::GetJoyXpadIds>, "GetJoyXpadIds"},
61 {60, &IHidServer::ActivateSixAxisSensor, "ActivateSixAxisSensor"}, 61 {60, C<&IHidServer::ActivateSixAxisSensor>, "ActivateSixAxisSensor"},
62 {61, &IHidServer::DeactivateSixAxisSensor, "DeactivateSixAxisSensor"}, 62 {61, C<&IHidServer::DeactivateSixAxisSensor>, "DeactivateSixAxisSensor"},
63 {62, &IHidServer::GetSixAxisSensorLifoHandle, "GetSixAxisSensorLifoHandle"}, 63 {62, C<&IHidServer::GetSixAxisSensorLifoHandle>, "GetSixAxisSensorLifoHandle"},
64 {63, &IHidServer::ActivateJoySixAxisSensor, "ActivateJoySixAxisSensor"}, 64 {63, C<&IHidServer::ActivateJoySixAxisSensor>, "ActivateJoySixAxisSensor"},
65 {64, &IHidServer::DeactivateJoySixAxisSensor, "DeactivateJoySixAxisSensor"}, 65 {64, C<&IHidServer::DeactivateJoySixAxisSensor>, "DeactivateJoySixAxisSensor"},
66 {65, &IHidServer::GetJoySixAxisSensorLifoHandle, "GetJoySixAxisSensorLifoHandle"}, 66 {65, C<&IHidServer::GetJoySixAxisSensorLifoHandle>, "GetJoySixAxisSensorLifoHandle"},
67 {66, &IHidServer::StartSixAxisSensor, "StartSixAxisSensor"}, 67 {66, C<&IHidServer::StartSixAxisSensor>, "StartSixAxisSensor"},
68 {67, &IHidServer::StopSixAxisSensor, "StopSixAxisSensor"}, 68 {67, C<&IHidServer::StopSixAxisSensor>, "StopSixAxisSensor"},
69 {68, &IHidServer::IsSixAxisSensorFusionEnabled, "IsSixAxisSensorFusionEnabled"}, 69 {68, C<&IHidServer::IsSixAxisSensorFusionEnabled>, "IsSixAxisSensorFusionEnabled"},
70 {69, &IHidServer::EnableSixAxisSensorFusion, "EnableSixAxisSensorFusion"}, 70 {69, C<&IHidServer::EnableSixAxisSensorFusion>, "EnableSixAxisSensorFusion"},
71 {70, &IHidServer::SetSixAxisSensorFusionParameters, "SetSixAxisSensorFusionParameters"}, 71 {70, C<&IHidServer::SetSixAxisSensorFusionParameters>, "SetSixAxisSensorFusionParameters"},
72 {71, &IHidServer::GetSixAxisSensorFusionParameters, "GetSixAxisSensorFusionParameters"}, 72 {71, C<&IHidServer::GetSixAxisSensorFusionParameters>, "GetSixAxisSensorFusionParameters"},
73 {72, &IHidServer::ResetSixAxisSensorFusionParameters, "ResetSixAxisSensorFusionParameters"}, 73 {72, C<&IHidServer::ResetSixAxisSensorFusionParameters>, "ResetSixAxisSensorFusionParameters"},
74 {73, nullptr, "SetAccelerometerParameters"}, 74 {73, nullptr, "SetAccelerometerParameters"},
75 {74, nullptr, "GetAccelerometerParameters"}, 75 {74, nullptr, "GetAccelerometerParameters"},
76 {75, nullptr, "ResetAccelerometerParameters"}, 76 {75, nullptr, "ResetAccelerometerParameters"},
77 {76, nullptr, "SetAccelerometerPlayMode"}, 77 {76, nullptr, "SetAccelerometerPlayMode"},
78 {77, nullptr, "GetAccelerometerPlayMode"}, 78 {77, nullptr, "GetAccelerometerPlayMode"},
79 {78, nullptr, "ResetAccelerometerPlayMode"}, 79 {78, nullptr, "ResetAccelerometerPlayMode"},
80 {79, &IHidServer::SetGyroscopeZeroDriftMode, "SetGyroscopeZeroDriftMode"}, 80 {79, C<&IHidServer::SetGyroscopeZeroDriftMode>, "SetGyroscopeZeroDriftMode"},
81 {80, &IHidServer::GetGyroscopeZeroDriftMode, "GetGyroscopeZeroDriftMode"}, 81 {80, C<&IHidServer::GetGyroscopeZeroDriftMode>, "GetGyroscopeZeroDriftMode"},
82 {81, &IHidServer::ResetGyroscopeZeroDriftMode, "ResetGyroscopeZeroDriftMode"}, 82 {81, C<&IHidServer::ResetGyroscopeZeroDriftMode>, "ResetGyroscopeZeroDriftMode"},
83 {82, &IHidServer::IsSixAxisSensorAtRest, "IsSixAxisSensorAtRest"}, 83 {82, C<&IHidServer::IsSixAxisSensorAtRest>, "IsSixAxisSensorAtRest"},
84 {83, &IHidServer::IsFirmwareUpdateAvailableForSixAxisSensor, "IsFirmwareUpdateAvailableForSixAxisSensor"}, 84 {83, C<&IHidServer::IsFirmwareUpdateAvailableForSixAxisSensor>, "IsFirmwareUpdateAvailableForSixAxisSensor"},
85 {84, &IHidServer::EnableSixAxisSensorUnalteredPassthrough, "EnableSixAxisSensorUnalteredPassthrough"}, 85 {84, C<&IHidServer::EnableSixAxisSensorUnalteredPassthrough>, "EnableSixAxisSensorUnalteredPassthrough"},
86 {85, &IHidServer::IsSixAxisSensorUnalteredPassthroughEnabled, "IsSixAxisSensorUnalteredPassthroughEnabled"}, 86 {85, C<&IHidServer::IsSixAxisSensorUnalteredPassthroughEnabled>, "IsSixAxisSensorUnalteredPassthroughEnabled"},
87 {86, nullptr, "StoreSixAxisSensorCalibrationParameter"}, 87 {86, nullptr, "StoreSixAxisSensorCalibrationParameter"},
88 {87, &IHidServer::LoadSixAxisSensorCalibrationParameter, "LoadSixAxisSensorCalibrationParameter"}, 88 {87, C<&IHidServer::LoadSixAxisSensorCalibrationParameter>, "LoadSixAxisSensorCalibrationParameter"},
89 {88, &IHidServer::GetSixAxisSensorIcInformation, "GetSixAxisSensorIcInformation"}, 89 {88, C<&IHidServer::GetSixAxisSensorIcInformation>, "GetSixAxisSensorIcInformation"},
90 {89, &IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned, "ResetIsSixAxisSensorDeviceNewlyAssigned"}, 90 {89, C<&IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned>, "ResetIsSixAxisSensorDeviceNewlyAssigned"},
91 {91, &IHidServer::ActivateGesture, "ActivateGesture"}, 91 {91, C<&IHidServer::ActivateGesture>, "ActivateGesture"},
92 {100, &IHidServer::SetSupportedNpadStyleSet, "SetSupportedNpadStyleSet"}, 92 {100, C<&IHidServer::SetSupportedNpadStyleSet>, "SetSupportedNpadStyleSet"},
93 {101, &IHidServer::GetSupportedNpadStyleSet, "GetSupportedNpadStyleSet"}, 93 {101, C<&IHidServer::GetSupportedNpadStyleSet>, "GetSupportedNpadStyleSet"},
94 {102, &IHidServer::SetSupportedNpadIdType, "SetSupportedNpadIdType"}, 94 {102, C<&IHidServer::SetSupportedNpadIdType>, "SetSupportedNpadIdType"},
95 {103, &IHidServer::ActivateNpad, "ActivateNpad"}, 95 {103, C<&IHidServer::ActivateNpad>, "ActivateNpad"},
96 {104, &IHidServer::DeactivateNpad, "DeactivateNpad"}, 96 {104, C<&IHidServer::DeactivateNpad>, "DeactivateNpad"},
97 {106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, 97 {106, C<&IHidServer::AcquireNpadStyleSetUpdateEventHandle>, "AcquireNpadStyleSetUpdateEventHandle"},
98 {107, &IHidServer::DisconnectNpad, "DisconnectNpad"}, 98 {107, C<&IHidServer::DisconnectNpad>, "DisconnectNpad"},
99 {108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"}, 99 {108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"},
100 {109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, 100 {109, C<&IHidServer::ActivateNpadWithRevision>, "ActivateNpadWithRevision"},
101 {120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, 101 {120, C<&IHidServer::SetNpadJoyHoldType>, "SetNpadJoyHoldType"},
102 {121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, 102 {121, C<&IHidServer::GetNpadJoyHoldType>, "GetNpadJoyHoldType"},
103 {122, &IHidServer::SetNpadJoyAssignmentModeSingleByDefault, "SetNpadJoyAssignmentModeSingleByDefault"}, 103 {122, C<&IHidServer::SetNpadJoyAssignmentModeSingleByDefault>, "SetNpadJoyAssignmentModeSingleByDefault"},
104 {123, &IHidServer::SetNpadJoyAssignmentModeSingle, "SetNpadJoyAssignmentModeSingle"}, 104 {123, C<&IHidServer::SetNpadJoyAssignmentModeSingle>, "SetNpadJoyAssignmentModeSingle"},
105 {124, &IHidServer::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"}, 105 {124, C<&IHidServer::SetNpadJoyAssignmentModeDual>, "SetNpadJoyAssignmentModeDual"},
106 {125, &IHidServer::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"}, 106 {125, C<&IHidServer::MergeSingleJoyAsDualJoy>, "MergeSingleJoyAsDualJoy"},
107 {126, &IHidServer::StartLrAssignmentMode, "StartLrAssignmentMode"}, 107 {126, C<&IHidServer::StartLrAssignmentMode>, "StartLrAssignmentMode"},
108 {127, &IHidServer::StopLrAssignmentMode, "StopLrAssignmentMode"}, 108 {127, C<&IHidServer::StopLrAssignmentMode>, "StopLrAssignmentMode"},
109 {128, &IHidServer::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, 109 {128, C<&IHidServer::SetNpadHandheldActivationMode>, "SetNpadHandheldActivationMode"},
110 {129, &IHidServer::GetNpadHandheldActivationMode, "GetNpadHandheldActivationMode"}, 110 {129, C<&IHidServer::GetNpadHandheldActivationMode>, "GetNpadHandheldActivationMode"},
111 {130, &IHidServer::SwapNpadAssignment, "SwapNpadAssignment"}, 111 {130, C<&IHidServer::SwapNpadAssignment>, "SwapNpadAssignment"},
112 {131, &IHidServer::IsUnintendedHomeButtonInputProtectionEnabled, "IsUnintendedHomeButtonInputProtectionEnabled"}, 112 {131, C<&IHidServer::IsUnintendedHomeButtonInputProtectionEnabled>, "IsUnintendedHomeButtonInputProtectionEnabled"},
113 {132, &IHidServer::EnableUnintendedHomeButtonInputProtection, "EnableUnintendedHomeButtonInputProtection"}, 113 {132, C<&IHidServer::EnableUnintendedHomeButtonInputProtection>, "EnableUnintendedHomeButtonInputProtection"},
114 {133, &IHidServer::SetNpadJoyAssignmentModeSingleWithDestination, "SetNpadJoyAssignmentModeSingleWithDestination"}, 114 {133, C<&IHidServer::SetNpadJoyAssignmentModeSingleWithDestination>, "SetNpadJoyAssignmentModeSingleWithDestination"},
115 {134, &IHidServer::SetNpadAnalogStickUseCenterClamp, "SetNpadAnalogStickUseCenterClamp"}, 115 {134, C<&IHidServer::SetNpadAnalogStickUseCenterClamp>, "SetNpadAnalogStickUseCenterClamp"},
116 {135, &IHidServer::SetNpadCaptureButtonAssignment, "SetNpadCaptureButtonAssignment"}, 116 {135, C<&IHidServer::SetNpadCaptureButtonAssignment>, "SetNpadCaptureButtonAssignment"},
117 {136, &IHidServer::ClearNpadCaptureButtonAssignment, "ClearNpadCaptureButtonAssignment"}, 117 {136, C<&IHidServer::ClearNpadCaptureButtonAssignment>, "ClearNpadCaptureButtonAssignment"},
118 {200, &IHidServer::GetVibrationDeviceInfo, "GetVibrationDeviceInfo"}, 118 {200, C<&IHidServer::GetVibrationDeviceInfo>, "GetVibrationDeviceInfo"},
119 {201, &IHidServer::SendVibrationValue, "SendVibrationValue"}, 119 {201, C<&IHidServer::SendVibrationValue>, "SendVibrationValue"},
120 {202, &IHidServer::GetActualVibrationValue, "GetActualVibrationValue"}, 120 {202, C<&IHidServer::GetActualVibrationValue>, "GetActualVibrationValue"},
121 {203, &IHidServer::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, 121 {203, C<&IHidServer::CreateActiveVibrationDeviceList>, "CreateActiveVibrationDeviceList"},
122 {204, &IHidServer::PermitVibration, "PermitVibration"}, 122 {204, C<&IHidServer::PermitVibration>, "PermitVibration"},
123 {205, &IHidServer::IsVibrationPermitted, "IsVibrationPermitted"}, 123 {205, C<&IHidServer::IsVibrationPermitted>, "IsVibrationPermitted"},
124 {206, &IHidServer::SendVibrationValues, "SendVibrationValues"}, 124 {206, C<&IHidServer::SendVibrationValues>, "SendVibrationValues"},
125 {207, &IHidServer::SendVibrationGcErmCommand, "SendVibrationGcErmCommand"}, 125 {207, C<&IHidServer::SendVibrationGcErmCommand>, "SendVibrationGcErmCommand"},
126 {208, &IHidServer::GetActualVibrationGcErmCommand, "GetActualVibrationGcErmCommand"}, 126 {208, C<&IHidServer::GetActualVibrationGcErmCommand>, "GetActualVibrationGcErmCommand"},
127 {209, &IHidServer::BeginPermitVibrationSession, "BeginPermitVibrationSession"}, 127 {209, C<&IHidServer::BeginPermitVibrationSession>, "BeginPermitVibrationSession"},
128 {210, &IHidServer::EndPermitVibrationSession, "EndPermitVibrationSession"}, 128 {210, C<&IHidServer::EndPermitVibrationSession>, "EndPermitVibrationSession"},
129 {211, &IHidServer::IsVibrationDeviceMounted, "IsVibrationDeviceMounted"}, 129 {211, C<&IHidServer::IsVibrationDeviceMounted>, "IsVibrationDeviceMounted"},
130 {212, &IHidServer::SendVibrationValueInBool, "SendVibrationValueInBool"}, 130 {212, C<&IHidServer::SendVibrationValueInBool>, "SendVibrationValueInBool"},
131 {300, &IHidServer::ActivateConsoleSixAxisSensor, "ActivateConsoleSixAxisSensor"}, 131 {300, C<&IHidServer::ActivateConsoleSixAxisSensor>, "ActivateConsoleSixAxisSensor"},
132 {301, &IHidServer::StartConsoleSixAxisSensor, "StartConsoleSixAxisSensor"}, 132 {301, C<&IHidServer::StartConsoleSixAxisSensor>, "StartConsoleSixAxisSensor"},
133 {302, &IHidServer::StopConsoleSixAxisSensor, "StopConsoleSixAxisSensor"}, 133 {302, C<&IHidServer::StopConsoleSixAxisSensor>, "StopConsoleSixAxisSensor"},
134 {303, &IHidServer::ActivateSevenSixAxisSensor, "ActivateSevenSixAxisSensor"}, 134 {303, C<&IHidServer::ActivateSevenSixAxisSensor>, "ActivateSevenSixAxisSensor"},
135 {304, &IHidServer::StartSevenSixAxisSensor, "StartSevenSixAxisSensor"}, 135 {304, C<&IHidServer::StartSevenSixAxisSensor>, "StartSevenSixAxisSensor"},
136 {305, &IHidServer::StopSevenSixAxisSensor, "StopSevenSixAxisSensor"}, 136 {305, C<&IHidServer::StopSevenSixAxisSensor>, "StopSevenSixAxisSensor"},
137 {306, &IHidServer::InitializeSevenSixAxisSensor, "InitializeSevenSixAxisSensor"}, 137 {306, C<&IHidServer::InitializeSevenSixAxisSensor>, "InitializeSevenSixAxisSensor"},
138 {307, &IHidServer::FinalizeSevenSixAxisSensor, "FinalizeSevenSixAxisSensor"}, 138 {307, C<&IHidServer::FinalizeSevenSixAxisSensor>, "FinalizeSevenSixAxisSensor"},
139 {308, nullptr, "SetSevenSixAxisSensorFusionStrength"}, 139 {308, nullptr, "SetSevenSixAxisSensorFusionStrength"},
140 {309, nullptr, "GetSevenSixAxisSensorFusionStrength"}, 140 {309, nullptr, "GetSevenSixAxisSensorFusionStrength"},
141 {310, &IHidServer::ResetSevenSixAxisSensorTimestamp, "ResetSevenSixAxisSensorTimestamp"}, 141 {310, C<&IHidServer::ResetSevenSixAxisSensorTimestamp>, "ResetSevenSixAxisSensorTimestamp"},
142 {400, &IHidServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, 142 {400, C<&IHidServer::IsUsbFullKeyControllerEnabled>, "IsUsbFullKeyControllerEnabled"},
143 {401, nullptr, "EnableUsbFullKeyController"}, 143 {401, nullptr, "EnableUsbFullKeyController"},
144 {402, nullptr, "IsUsbFullKeyControllerConnected"}, 144 {402, nullptr, "IsUsbFullKeyControllerConnected"},
145 {403, nullptr, "HasBattery"}, 145 {403, nullptr, "HasBattery"},
@@ -148,41 +148,41 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
148 {406, nullptr, "GetNpadLeftRightInterfaceType"}, 148 {406, nullptr, "GetNpadLeftRightInterfaceType"},
149 {407, nullptr, "GetNpadOfHighestBatteryLevel"}, 149 {407, nullptr, "GetNpadOfHighestBatteryLevel"},
150 {408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"}, 150 {408, nullptr, "GetNpadOfHighestBatteryLevelForJoyRight"},
151 {500, &IHidServer::GetPalmaConnectionHandle, "GetPalmaConnectionHandle"}, 151 {500, C<&IHidServer::GetPalmaConnectionHandle>, "GetPalmaConnectionHandle"},
152 {501, &IHidServer::InitializePalma, "InitializePalma"}, 152 {501, C<&IHidServer::InitializePalma>, "InitializePalma"},
153 {502, &IHidServer::AcquirePalmaOperationCompleteEvent, "AcquirePalmaOperationCompleteEvent"}, 153 {502, C<&IHidServer::AcquirePalmaOperationCompleteEvent>, "AcquirePalmaOperationCompleteEvent"},
154 {503, &IHidServer::GetPalmaOperationInfo, "GetPalmaOperationInfo"}, 154 {503, C<&IHidServer::GetPalmaOperationInfo>, "GetPalmaOperationInfo"},
155 {504, &IHidServer::PlayPalmaActivity, "PlayPalmaActivity"}, 155 {504, C<&IHidServer::PlayPalmaActivity>, "PlayPalmaActivity"},
156 {505, &IHidServer::SetPalmaFrModeType, "SetPalmaFrModeType"}, 156 {505, C<&IHidServer::SetPalmaFrModeType>, "SetPalmaFrModeType"},
157 {506, &IHidServer::ReadPalmaStep, "ReadPalmaStep"}, 157 {506, C<&IHidServer::ReadPalmaStep>, "ReadPalmaStep"},
158 {507, &IHidServer::EnablePalmaStep, "EnablePalmaStep"}, 158 {507, C<&IHidServer::EnablePalmaStep>, "EnablePalmaStep"},
159 {508, &IHidServer::ResetPalmaStep, "ResetPalmaStep"}, 159 {508, C<&IHidServer::ResetPalmaStep>, "ResetPalmaStep"},
160 {509, &IHidServer::ReadPalmaApplicationSection, "ReadPalmaApplicationSection"}, 160 {509, C<&IHidServer::ReadPalmaApplicationSection>, "ReadPalmaApplicationSection"},
161 {510, &IHidServer::WritePalmaApplicationSection, "WritePalmaApplicationSection"}, 161 {510, C<&IHidServer::WritePalmaApplicationSection>, "WritePalmaApplicationSection"},
162 {511, &IHidServer::ReadPalmaUniqueCode, "ReadPalmaUniqueCode"}, 162 {511, C<&IHidServer::ReadPalmaUniqueCode>, "ReadPalmaUniqueCode"},
163 {512, &IHidServer::SetPalmaUniqueCodeInvalid, "SetPalmaUniqueCodeInvalid"}, 163 {512, C<&IHidServer::SetPalmaUniqueCodeInvalid>, "SetPalmaUniqueCodeInvalid"},
164 {513, &IHidServer::WritePalmaActivityEntry, "WritePalmaActivityEntry"}, 164 {513, C<&IHidServer::WritePalmaActivityEntry>, "WritePalmaActivityEntry"},
165 {514, &IHidServer::WritePalmaRgbLedPatternEntry, "WritePalmaRgbLedPatternEntry"}, 165 {514, C<&IHidServer::WritePalmaRgbLedPatternEntry>, "WritePalmaRgbLedPatternEntry"},
166 {515, &IHidServer::WritePalmaWaveEntry, "WritePalmaWaveEntry"}, 166 {515, C<&IHidServer::WritePalmaWaveEntry>, "WritePalmaWaveEntry"},
167 {516, &IHidServer::SetPalmaDataBaseIdentificationVersion, "SetPalmaDataBaseIdentificationVersion"}, 167 {516, C<&IHidServer::SetPalmaDataBaseIdentificationVersion>, "SetPalmaDataBaseIdentificationVersion"},
168 {517, &IHidServer::GetPalmaDataBaseIdentificationVersion, "GetPalmaDataBaseIdentificationVersion"}, 168 {517, C<&IHidServer::GetPalmaDataBaseIdentificationVersion>, "GetPalmaDataBaseIdentificationVersion"},
169 {518, &IHidServer::SuspendPalmaFeature, "SuspendPalmaFeature"}, 169 {518, C<&IHidServer::SuspendPalmaFeature>, "SuspendPalmaFeature"},
170 {519, &IHidServer::GetPalmaOperationResult, "GetPalmaOperationResult"}, 170 {519, C<&IHidServer::GetPalmaOperationResult>, "GetPalmaOperationResult"},
171 {520, &IHidServer::ReadPalmaPlayLog, "ReadPalmaPlayLog"}, 171 {520, C<&IHidServer::ReadPalmaPlayLog>, "ReadPalmaPlayLog"},
172 {521, &IHidServer::ResetPalmaPlayLog, "ResetPalmaPlayLog"}, 172 {521, C<&IHidServer::ResetPalmaPlayLog>, "ResetPalmaPlayLog"},
173 {522, &IHidServer::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, 173 {522, C<&IHidServer::SetIsPalmaAllConnectable>, "SetIsPalmaAllConnectable"},
174 {523, &IHidServer::SetIsPalmaPairedConnectable, "SetIsPalmaPairedConnectable"}, 174 {523, C<&IHidServer::SetIsPalmaPairedConnectable>, "SetIsPalmaPairedConnectable"},
175 {524, &IHidServer::PairPalma, "PairPalma"}, 175 {524, C<&IHidServer::PairPalma>, "PairPalma"},
176 {525, &IHidServer::SetPalmaBoostMode, "SetPalmaBoostMode"}, 176 {525, C<&IHidServer::SetPalmaBoostMode>, "SetPalmaBoostMode"},
177 {526, &IHidServer::CancelWritePalmaWaveEntry, "CancelWritePalmaWaveEntry"}, 177 {526, C<&IHidServer::CancelWritePalmaWaveEntry>, "CancelWritePalmaWaveEntry"},
178 {527, &IHidServer::EnablePalmaBoostMode, "EnablePalmaBoostMode"}, 178 {527, C<&IHidServer::EnablePalmaBoostMode>, "EnablePalmaBoostMode"},
179 {528, &IHidServer::GetPalmaBluetoothAddress, "GetPalmaBluetoothAddress"}, 179 {528, C<&IHidServer::GetPalmaBluetoothAddress>, "GetPalmaBluetoothAddress"},
180 {529, &IHidServer::SetDisallowedPalmaConnection, "SetDisallowedPalmaConnection"}, 180 {529, C<&IHidServer::SetDisallowedPalmaConnection>, "SetDisallowedPalmaConnection"},
181 {1000, &IHidServer::SetNpadCommunicationMode, "SetNpadCommunicationMode"}, 181 {1000, C<&IHidServer::SetNpadCommunicationMode>, "SetNpadCommunicationMode"},
182 {1001, &IHidServer::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, 182 {1001, C<&IHidServer::GetNpadCommunicationMode>, "GetNpadCommunicationMode"},
183 {1002, &IHidServer::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, 183 {1002, C<&IHidServer::SetTouchScreenConfiguration>, "SetTouchScreenConfiguration"},
184 {1003, &IHidServer::IsFirmwareUpdateNeededForNotification, "IsFirmwareUpdateNeededForNotification"}, 184 {1003, C<&IHidServer::IsFirmwareUpdateNeededForNotification>, "IsFirmwareUpdateNeededForNotification"},
185 {1004, &IHidServer::SetTouchScreenResolution, "SetTouchScreenResolution"}, 185 {1004, C<&IHidServer::SetTouchScreenResolution>, "SetTouchScreenResolution"},
186 {2000, nullptr, "ActivateDigitizer"}, 186 {2000, nullptr, "ActivateDigitizer"},
187 }; 187 };
188 // clang-format on 188 // clang-format on
@@ -192,890 +192,455 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r
192 192
193IHidServer::~IHidServer() = default; 193IHidServer::~IHidServer() = default;
194 194
195void IHidServer::CreateAppletResource(HLERequestContext& ctx) { 195Result IHidServer::CreateAppletResource(OutInterface<IAppletResource> out_applet_resource,
196 IPC::RequestParser rp{ctx}; 196 ClientAppletResourceUserId aruid) {
197 const auto applet_resource_user_id{rp.Pop<u64>()}; 197 const auto result = GetResourceManager()->CreateAppletResource(aruid.pid);
198 198
199 Result result = GetResourceManager()->CreateAppletResource(applet_resource_user_id); 199 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", aruid.pid,
200 result.raw);
200 201
201 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, result=0x{:X}", 202 *out_applet_resource = std::make_shared<IAppletResource>(system, resource_manager, aruid.pid);
202 applet_resource_user_id, result.raw); 203 R_SUCCEED();
203
204 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
205 rb.Push(result);
206 rb.PushIpcInterface<IAppletResource>(system, resource_manager, applet_resource_user_id);
207} 204}
208 205
209void IHidServer::ActivateDebugPad(HLERequestContext& ctx) { 206Result IHidServer::ActivateDebugPad(ClientAppletResourceUserId aruid) {
210 IPC::RequestParser rp{ctx}; 207 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
211 const auto applet_resource_user_id{rp.Pop<u64>()};
212
213 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
214
215 Result result = ResultSuccess;
216 auto debug_pad = GetResourceManager()->GetDebugPad();
217 208
218 if (!firmware_settings->IsDeviceManaged()) { 209 if (!firmware_settings->IsDeviceManaged()) {
219 result = debug_pad->Activate(); 210 R_TRY(GetResourceManager()->GetDebugPad()->Activate());
220 }
221
222 if (result.IsSuccess()) {
223 result = debug_pad->Activate(applet_resource_user_id);
224 } 211 }
225 212
226 IPC::ResponseBuilder rb{ctx, 2}; 213 R_RETURN(GetResourceManager()->GetDebugPad()->Activate(aruid.pid));
227 rb.Push(result);
228} 214}
229 215
230void IHidServer::ActivateTouchScreen(HLERequestContext& ctx) { 216Result IHidServer::ActivateTouchScreen(ClientAppletResourceUserId aruid) {
231 IPC::RequestParser rp{ctx}; 217 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
232 const auto applet_resource_user_id{rp.Pop<u64>()};
233
234 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
235
236 Result result = ResultSuccess;
237 auto touch_screen = GetResourceManager()->GetTouchScreen();
238 218
239 if (!firmware_settings->IsDeviceManaged()) { 219 if (!firmware_settings->IsDeviceManaged()) {
240 result = touch_screen->Activate(); 220 R_TRY(GetResourceManager()->GetTouchScreen()->Activate());
241 }
242
243 if (result.IsSuccess()) {
244 result = touch_screen->Activate(applet_resource_user_id);
245 } 221 }
246 222
247 IPC::ResponseBuilder rb{ctx, 2}; 223 R_RETURN(GetResourceManager()->GetTouchScreen()->Activate(aruid.pid));
248 rb.Push(result);
249} 224}
250 225
251void IHidServer::ActivateMouse(HLERequestContext& ctx) { 226Result IHidServer::ActivateMouse(ClientAppletResourceUserId aruid) {
252 IPC::RequestParser rp{ctx}; 227 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
253 const auto applet_resource_user_id{rp.Pop<u64>()};
254
255 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
256
257 Result result = ResultSuccess;
258 auto mouse = GetResourceManager()->GetMouse();
259 228
260 if (!firmware_settings->IsDeviceManaged()) { 229 if (!firmware_settings->IsDeviceManaged()) {
261 result = mouse->Activate(); 230 R_TRY(GetResourceManager()->GetMouse()->Activate());
262 } 231 }
263 232
264 if (result.IsSuccess()) { 233 R_RETURN(GetResourceManager()->GetMouse()->Activate(aruid.pid));
265 result = mouse->Activate(applet_resource_user_id);
266 }
267
268 IPC::ResponseBuilder rb{ctx, 2};
269 rb.Push(result);
270} 234}
271 235
272void IHidServer::ActivateKeyboard(HLERequestContext& ctx) { 236Result IHidServer::ActivateKeyboard(ClientAppletResourceUserId aruid) {
273 IPC::RequestParser rp{ctx}; 237 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
274 const auto applet_resource_user_id{rp.Pop<u64>()};
275
276 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
277
278 Result result = ResultSuccess;
279 auto keyboard = GetResourceManager()->GetKeyboard();
280 238
281 if (!firmware_settings->IsDeviceManaged()) { 239 if (!firmware_settings->IsDeviceManaged()) {
282 result = keyboard->Activate(); 240 R_TRY(GetResourceManager()->GetKeyboard()->Activate());
283 }
284
285 if (result.IsSuccess()) {
286 result = keyboard->Activate(applet_resource_user_id);
287 } 241 }
288 242
289 IPC::ResponseBuilder rb{ctx, 2}; 243 R_RETURN(GetResourceManager()->GetKeyboard()->Activate(aruid.pid));
290 rb.Push(result);
291} 244}
292 245
293void IHidServer::SendKeyboardLockKeyEvent(HLERequestContext& ctx) { 246Result IHidServer::SendKeyboardLockKeyEvent(u32 flags) {
294 IPC::RequestParser rp{ctx};
295 const auto flags{rp.Pop<u32>()};
296
297 LOG_WARNING(Service_HID, "(STUBBED) called. flags={}", flags); 247 LOG_WARNING(Service_HID, "(STUBBED) called. flags={}", flags);
298 248 R_SUCCEED();
299 IPC::ResponseBuilder rb{ctx, 2};
300 rb.Push(ResultSuccess);
301} 249}
302 250
303void IHidServer::AcquireXpadIdEventHandle(HLERequestContext& ctx) { 251Result IHidServer::AcquireXpadIdEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event,
304 IPC::RequestParser rp{ctx}; 252 ClientAppletResourceUserId aruid) {
305 const auto applet_resource_user_id{rp.Pop<u64>()}; 253 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
306
307 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
308 254
309 // This function has been stubbed since 10.0.0+ 255 // This function has been stubbed since 10.0.0+
310 256 *out_event = nullptr;
311 IPC::ResponseBuilder rb{ctx, 2, 1}; 257 R_SUCCEED();
312 rb.Push(ResultSuccess);
313 // Handle returned is null here
314} 258}
315 259
316void IHidServer::ReleaseXpadIdEventHandle(HLERequestContext& ctx) { 260Result IHidServer::ReleaseXpadIdEventHandle(ClientAppletResourceUserId aruid) {
317 IPC::RequestParser rp{ctx}; 261 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
318 const auto applet_resource_user_id{rp.Pop<u64>()};
319
320 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
321 262
322 // This function has been stubbed since 10.0.0+ 263 // This function has been stubbed since 10.0.0+
323 264 R_SUCCEED();
324 IPC::ResponseBuilder rb{ctx, 2};
325 rb.Push(ResultSuccess);
326} 265}
327 266
328void IHidServer::ActivateXpad(HLERequestContext& ctx) { 267Result IHidServer::ActivateXpad(u32 basic_xpad_id, ClientAppletResourceUserId aruid) {
329 IPC::RequestParser rp{ctx}; 268 LOG_DEBUG(Service_HID, "called, basic_xpad_id={}, applet_resource_user_id={}", basic_xpad_id,
330 struct Parameters { 269 aruid.pid);
331 u32 basic_xpad_id;
332 INSERT_PADDING_WORDS_NOINIT(1);
333 u64 applet_resource_user_id;
334 };
335 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
336
337 const auto parameters{rp.PopRaw<Parameters>()};
338
339 LOG_DEBUG(Service_HID, "called, basic_xpad_id={}, applet_resource_user_id={}",
340 parameters.basic_xpad_id, parameters.applet_resource_user_id);
341 270
342 // This function has been stubbed since 10.0.0+ 271 // This function has been stubbed since 10.0.0+
343 272 R_SUCCEED();
344 IPC::ResponseBuilder rb{ctx, 2};
345 rb.Push(ResultSuccess);
346} 273}
347 274
348void IHidServer::GetXpadIds(HLERequestContext& ctx) { 275Result IHidServer::GetXpadIds(Out<u64> out_count,
276 OutArray<u32, BufferAttr_HipcPointer> out_basic_pad_ids) {
349 LOG_DEBUG(Service_HID, "called"); 277 LOG_DEBUG(Service_HID, "called");
350 278
351 // This function has been hardcoded since 10.0.0+ 279 // This function has been hardcoded since 10.0.0+
352 const std::array<u32, 4> basic_xpad_id{0, 1, 2, 3}; 280 out_basic_pad_ids[0] = 0;
353 ctx.WriteBuffer(basic_xpad_id); 281 out_basic_pad_ids[1] = 1;
354 282 out_basic_pad_ids[2] = 2;
355 IPC::ResponseBuilder rb{ctx, 4}; 283 out_basic_pad_ids[3] = 3;
356 rb.Push(ResultSuccess); 284 *out_count = 4;
357 rb.Push<s64>(basic_xpad_id.size()); 285 R_SUCCEED();
358} 286}
359 287
360void IHidServer::ActivateJoyXpad(HLERequestContext& ctx) { 288Result IHidServer::ActivateJoyXpad(u32 joy_xpad_id) {
361 IPC::RequestParser rp{ctx};
362 const auto joy_xpad_id{rp.Pop<u32>()};
363
364 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 289 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
365 290
366 // This function has been stubbed since 10.0.0+ 291 // This function has been stubbed since 10.0.0+
367 292 R_SUCCEED();
368 IPC::ResponseBuilder rb{ctx, 2};
369 rb.Push(ResultSuccess);
370} 293}
371 294
372void IHidServer::GetJoyXpadLifoHandle(HLERequestContext& ctx) { 295Result IHidServer::GetJoyXpadLifoHandle(
373 IPC::RequestParser rp{ctx}; 296 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle, u32 joy_xpad_id) {
374 const auto joy_xpad_id{rp.Pop<u32>()};
375
376 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 297 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
377 298
378 // This function has been stubbed since 10.0.0+ 299 // This function has been stubbed since 10.0.0+
379 300 *out_shared_memory_handle = nullptr;
380 IPC::ResponseBuilder rb{ctx, 2, 1}; 301 R_SUCCEED();
381 rb.Push(ResultSuccess);
382 // Handle returned is null here
383} 302}
384 303
385void IHidServer::GetJoyXpadIds(HLERequestContext& ctx) { 304Result IHidServer::GetJoyXpadIds(Out<s64> out_basic_xpad_id_count) {
386 LOG_DEBUG(Service_HID, "called"); 305 LOG_DEBUG(Service_HID, "called");
387 306
388 // This function has been hardcoded since 10.0.0+ 307 // This function has been hardcoded since 10.0.0+
389 const s64 basic_xpad_id_count{}; 308 *out_basic_xpad_id_count = 0;
390 309 R_SUCCEED();
391 IPC::ResponseBuilder rb{ctx, 4};
392 rb.Push(ResultSuccess);
393 rb.Push(basic_xpad_id_count);
394} 310}
395 311
396void IHidServer::ActivateSixAxisSensor(HLERequestContext& ctx) { 312Result IHidServer::ActivateSixAxisSensor(u32 joy_xpad_id) {
397 IPC::RequestParser rp{ctx};
398 const auto joy_xpad_id{rp.Pop<u32>()};
399
400 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 313 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
401 314
402 // This function has been stubbed since 10.0.0+ 315 // This function has been stubbed since 10.0.0+
403 316 R_SUCCEED();
404 IPC::ResponseBuilder rb{ctx, 2};
405 rb.Push(ResultSuccess);
406} 317}
407 318
408void IHidServer::DeactivateSixAxisSensor(HLERequestContext& ctx) { 319Result IHidServer::DeactivateSixAxisSensor(u32 joy_xpad_id) {
409 IPC::RequestParser rp{ctx};
410 const auto joy_xpad_id{rp.Pop<u32>()};
411
412 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 320 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
413 321
414 // This function has been stubbed since 10.0.0+ 322 // This function has been stubbed since 10.0.0+
415 323 R_SUCCEED();
416 IPC::ResponseBuilder rb{ctx, 2, 1};
417 rb.Push(ResultSuccess);
418} 324}
419 325
420void IHidServer::GetSixAxisSensorLifoHandle(HLERequestContext& ctx) { 326Result IHidServer::GetSixAxisSensorLifoHandle(
421 IPC::RequestParser rp{ctx}; 327 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle, u32 joy_xpad_id) {
422 const auto joy_xpad_id{rp.Pop<u32>()};
423
424 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 328 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
425 329
426 // This function has been stubbed since 10.0.0+ 330 // This function has been stubbed since 10.0.0+
427 331 *out_shared_memory_handle = nullptr;
428 IPC::ResponseBuilder rb{ctx, 2}; 332 R_SUCCEED();
429 rb.Push(ResultSuccess);
430} 333}
431 334
432void IHidServer::ActivateJoySixAxisSensor(HLERequestContext& ctx) { 335Result IHidServer::ActivateJoySixAxisSensor(u32 joy_xpad_id) {
433 IPC::RequestParser rp{ctx};
434 const auto joy_xpad_id{rp.Pop<u32>()};
435
436 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 336 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
437 337
438 // This function has been stubbed since 10.0.0+ 338 // This function has been stubbed since 10.0.0+
439 339 R_SUCCEED();
440 IPC::ResponseBuilder rb{ctx, 2};
441 rb.Push(ResultSuccess);
442} 340}
443 341
444void IHidServer::DeactivateJoySixAxisSensor(HLERequestContext& ctx) { 342Result IHidServer::DeactivateJoySixAxisSensor(u32 joy_xpad_id) {
445 IPC::RequestParser rp{ctx};
446 const auto joy_xpad_id{rp.Pop<u32>()};
447
448 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 343 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
449 344
450 // This function has been stubbed since 10.0.0+ 345 // This function has been stubbed since 10.0.0+
451 346 R_SUCCEED();
452 IPC::ResponseBuilder rb{ctx, 2};
453 rb.Push(ResultSuccess);
454} 347}
455 348
456void IHidServer::GetJoySixAxisSensorLifoHandle(HLERequestContext& ctx) { 349Result IHidServer::GetJoySixAxisSensorLifoHandle(
457 IPC::RequestParser rp{ctx}; 350 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle, u32 joy_xpad_id) {
458 const auto joy_xpad_id{rp.Pop<u32>()};
459
460 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id); 351 LOG_DEBUG(Service_HID, "called, joy_xpad_id={}", joy_xpad_id);
461 352
462 // This function has been stubbed since 10.0.0+ 353 // This function has been stubbed since 10.0.0+
463 354 *out_shared_memory_handle = nullptr;
464 IPC::ResponseBuilder rb{ctx, 2, 1}; 355 R_SUCCEED();
465 rb.Push(ResultSuccess);
466 // Handle returned is null here
467} 356}
468 357
469void IHidServer::StartSixAxisSensor(HLERequestContext& ctx) { 358Result IHidServer::StartSixAxisSensor(Core::HID::SixAxisSensorHandle sixaxis_handle,
470 IPC::RequestParser rp{ctx}; 359 ClientAppletResourceUserId aruid) {
471 struct Parameters {
472 Core::HID::SixAxisSensorHandle sixaxis_handle;
473 INSERT_PADDING_WORDS_NOINIT(1);
474 u64 applet_resource_user_id;
475 };
476 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
477
478 const auto parameters{rp.PopRaw<Parameters>()};
479
480 auto six_axis = GetResourceManager()->GetSixAxis();
481 const auto result = six_axis->SetSixAxisEnabled(parameters.sixaxis_handle, true);
482
483 LOG_DEBUG(Service_HID, 360 LOG_DEBUG(Service_HID,
484 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 361 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
485 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 362 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
486 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 363 aruid.pid);
487 364
488 IPC::ResponseBuilder rb{ctx, 2}; 365 R_RETURN(GetResourceManager()->GetSixAxis()->SetSixAxisEnabled(sixaxis_handle, true));
489 rb.Push(result);
490} 366}
491 367
492void IHidServer::StopSixAxisSensor(HLERequestContext& ctx) { 368Result IHidServer::StopSixAxisSensor(Core::HID::SixAxisSensorHandle sixaxis_handle,
493 IPC::RequestParser rp{ctx}; 369 ClientAppletResourceUserId aruid) {
494 struct Parameters {
495 Core::HID::SixAxisSensorHandle sixaxis_handle;
496 INSERT_PADDING_WORDS_NOINIT(1);
497 u64 applet_resource_user_id;
498 };
499 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
500
501 const auto parameters{rp.PopRaw<Parameters>()};
502
503 auto six_axis = GetResourceManager()->GetSixAxis();
504 const auto result = six_axis->SetSixAxisEnabled(parameters.sixaxis_handle, false);
505
506 LOG_DEBUG(Service_HID, 370 LOG_DEBUG(Service_HID,
507 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 371 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
508 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 372 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
509 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 373 aruid.pid);
510 374
511 IPC::ResponseBuilder rb{ctx, 2}; 375 R_RETURN(GetResourceManager()->GetSixAxis()->SetSixAxisEnabled(sixaxis_handle, false));
512 rb.Push(result);
513} 376}
514 377
515void IHidServer::IsSixAxisSensorFusionEnabled(HLERequestContext& ctx) { 378Result IHidServer::IsSixAxisSensorFusionEnabled(Out<bool> out_is_enabled,
516 IPC::RequestParser rp{ctx}; 379 Core::HID::SixAxisSensorHandle sixaxis_handle,
517 struct Parameters { 380 ClientAppletResourceUserId aruid) {
518 Core::HID::SixAxisSensorHandle sixaxis_handle;
519 INSERT_PADDING_WORDS_NOINIT(1);
520 u64 applet_resource_user_id;
521 };
522 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
523
524 const auto parameters{rp.PopRaw<Parameters>()};
525
526 bool is_enabled{};
527 auto six_axis = GetResourceManager()->GetSixAxis();
528 const auto result =
529 six_axis->IsSixAxisSensorFusionEnabled(parameters.sixaxis_handle, is_enabled);
530
531 LOG_DEBUG(Service_HID, 381 LOG_DEBUG(Service_HID,
532 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 382 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
533 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 383 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
534 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 384 aruid.pid);
535 385
536 IPC::ResponseBuilder rb{ctx, 3}; 386 R_RETURN(GetResourceManager()->GetSixAxis()->IsSixAxisSensorFusionEnabled(sixaxis_handle,
537 rb.Push(result); 387 *out_is_enabled));
538 rb.Push(is_enabled);
539} 388}
540 389
541void IHidServer::EnableSixAxisSensorFusion(HLERequestContext& ctx) { 390Result IHidServer::EnableSixAxisSensorFusion(bool is_enabled,
542 IPC::RequestParser rp{ctx}; 391 Core::HID::SixAxisSensorHandle sixaxis_handle,
543 struct Parameters { 392 ClientAppletResourceUserId aruid) {
544 bool enable_sixaxis_sensor_fusion;
545 INSERT_PADDING_BYTES_NOINIT(3);
546 Core::HID::SixAxisSensorHandle sixaxis_handle;
547 u64 applet_resource_user_id;
548 };
549 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
550
551 const auto parameters{rp.PopRaw<Parameters>()};
552
553 auto six_axis = GetResourceManager()->GetSixAxis();
554 const auto result = six_axis->SetSixAxisFusionEnabled(parameters.sixaxis_handle,
555 parameters.enable_sixaxis_sensor_fusion);
556
557 LOG_DEBUG(Service_HID, 393 LOG_DEBUG(Service_HID,
558 "called, enable_sixaxis_sensor_fusion={}, npad_type={}, npad_id={}, " 394 "called, is_enabled={}, npad_type={}, npad_id={}, "
559 "device_index={}, applet_resource_user_id={}", 395 "device_index={}, applet_resource_user_id={}",
560 parameters.enable_sixaxis_sensor_fusion, parameters.sixaxis_handle.npad_type, 396 is_enabled, sixaxis_handle.npad_type, sixaxis_handle.npad_id,
561 parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, 397 sixaxis_handle.device_index, aruid.pid);
562 parameters.applet_resource_user_id);
563 398
564 IPC::ResponseBuilder rb{ctx, 2}; 399 R_RETURN(
565 rb.Push(result); 400 GetResourceManager()->GetSixAxis()->SetSixAxisFusionEnabled(sixaxis_handle, is_enabled));
566} 401}
567 402
568void IHidServer::SetSixAxisSensorFusionParameters(HLERequestContext& ctx) { 403Result IHidServer::SetSixAxisSensorFusionParameters(
569 IPC::RequestParser rp{ctx}; 404 Core::HID::SixAxisSensorHandle sixaxis_handle,
570 struct Parameters { 405 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion, ClientAppletResourceUserId aruid) {
571 Core::HID::SixAxisSensorHandle sixaxis_handle;
572 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion;
573 INSERT_PADDING_WORDS_NOINIT(1);
574 u64 applet_resource_user_id;
575 };
576 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
577
578 const auto parameters{rp.PopRaw<Parameters>()};
579
580 auto six_axis = GetResourceManager()->GetSixAxis();
581 const auto result =
582 six_axis->SetSixAxisFusionParameters(parameters.sixaxis_handle, parameters.sixaxis_fusion);
583
584 LOG_DEBUG(Service_HID, 406 LOG_DEBUG(Service_HID,
585 "called, npad_type={}, npad_id={}, device_index={}, parameter1={}, " 407 "called, npad_type={}, npad_id={}, device_index={}, parameter1={}, "
586 "parameter2={}, applet_resource_user_id={}", 408 "parameter2={}, applet_resource_user_id={}",
587 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 409 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
588 parameters.sixaxis_handle.device_index, parameters.sixaxis_fusion.parameter1, 410 sixaxis_fusion.parameter1, sixaxis_fusion.parameter2, aruid.pid);
589 parameters.sixaxis_fusion.parameter2, parameters.applet_resource_user_id);
590 411
591 IPC::ResponseBuilder rb{ctx, 2}; 412 R_RETURN(GetResourceManager()->GetSixAxis()->SetSixAxisFusionParameters(sixaxis_handle,
592 rb.Push(result); 413 sixaxis_fusion));
593} 414}
594 415
595void IHidServer::GetSixAxisSensorFusionParameters(HLERequestContext& ctx) { 416Result IHidServer::GetSixAxisSensorFusionParameters(
596 IPC::RequestParser rp{ctx}; 417 Out<Core::HID::SixAxisSensorFusionParameters> out_fusion_parameters,
597 struct Parameters { 418 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid) {
598 Core::HID::SixAxisSensorHandle sixaxis_handle;
599 INSERT_PADDING_WORDS_NOINIT(1);
600 u64 applet_resource_user_id;
601 };
602 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
603
604 const auto parameters{rp.PopRaw<Parameters>()};
605
606 Core::HID::SixAxisSensorFusionParameters fusion_parameters{};
607 auto six_axis = GetResourceManager()->GetSixAxis();
608 const auto result =
609 six_axis->GetSixAxisFusionParameters(parameters.sixaxis_handle, fusion_parameters);
610
611 LOG_DEBUG(Service_HID, 419 LOG_DEBUG(Service_HID,
612 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 420 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
613 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 421 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
614 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 422 aruid.pid);
615 423
616 IPC::ResponseBuilder rb{ctx, 4}; 424 R_RETURN(GetResourceManager()->GetSixAxis()->GetSixAxisFusionParameters(
617 rb.Push(result); 425 sixaxis_handle, *out_fusion_parameters));
618 rb.PushRaw(fusion_parameters);
619} 426}
620 427
621void IHidServer::ResetSixAxisSensorFusionParameters(HLERequestContext& ctx) { 428Result IHidServer::ResetSixAxisSensorFusionParameters(Core::HID::SixAxisSensorHandle sixaxis_handle,
622 IPC::RequestParser rp{ctx}; 429 ClientAppletResourceUserId aruid) {
623 struct Parameters { 430 LOG_DEBUG(Service_HID,
624 Core::HID::SixAxisSensorHandle sixaxis_handle; 431 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
625 INSERT_PADDING_WORDS_NOINIT(1); 432 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
626 u64 applet_resource_user_id; 433 aruid.pid);
627 };
628 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
629
630 const auto parameters{rp.PopRaw<Parameters>()};
631 434
632 // Since these parameters are unknown just use what HW outputs 435 // Since these parameters are unknown just use what HW outputs
633 const Core::HID::SixAxisSensorFusionParameters fusion_parameters{ 436 const Core::HID::SixAxisSensorFusionParameters fusion_parameters{
634 .parameter1 = 0.03f, 437 .parameter1 = 0.03f,
635 .parameter2 = 0.4f, 438 .parameter2 = 0.4f,
636 }; 439 };
637 auto six_axis = GetResourceManager()->GetSixAxis();
638 const auto result1 =
639 six_axis->SetSixAxisFusionParameters(parameters.sixaxis_handle, fusion_parameters);
640 const auto result2 = six_axis->SetSixAxisFusionEnabled(parameters.sixaxis_handle, true);
641 440
642 LOG_DEBUG(Service_HID, 441 R_TRY(GetResourceManager()->GetSixAxis()->SetSixAxisFusionParameters(sixaxis_handle,
643 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 442 fusion_parameters));
644 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 443 R_RETURN(GetResourceManager()->GetSixAxis()->SetSixAxisFusionEnabled(sixaxis_handle, true));
645 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
646
647 IPC::ResponseBuilder rb{ctx, 2};
648 if (result1.IsError()) {
649 rb.Push(result1);
650 return;
651 }
652 rb.Push(result2);
653} 444}
654 445
655void IHidServer::SetGyroscopeZeroDriftMode(HLERequestContext& ctx) { 446Result IHidServer::SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
656 IPC::RequestParser rp{ctx}; 447 Core::HID::GyroscopeZeroDriftMode drift_mode,
657 const auto sixaxis_handle{rp.PopRaw<Core::HID::SixAxisSensorHandle>()}; 448 ClientAppletResourceUserId aruid) {
658 const auto drift_mode{rp.PopEnum<Core::HID::GyroscopeZeroDriftMode>()};
659 const auto applet_resource_user_id{rp.Pop<u64>()};
660
661 auto six_axis = GetResourceManager()->GetSixAxis();
662 const auto result = six_axis->SetGyroscopeZeroDriftMode(sixaxis_handle, drift_mode);
663
664 LOG_DEBUG(Service_HID, 449 LOG_DEBUG(Service_HID,
665 "called, npad_type={}, npad_id={}, device_index={}, drift_mode={}, " 450 "called, npad_type={}, npad_id={}, device_index={}, drift_mode={}, "
666 "applet_resource_user_id={}", 451 "applet_resource_user_id={}",
667 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, 452 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
668 drift_mode, applet_resource_user_id); 453 drift_mode, aruid.pid);
669 454
670 IPC::ResponseBuilder rb{ctx, 2}; 455 R_RETURN(
671 rb.Push(result); 456 GetResourceManager()->GetSixAxis()->SetGyroscopeZeroDriftMode(sixaxis_handle, drift_mode));
672} 457}
673 458
674void IHidServer::GetGyroscopeZeroDriftMode(HLERequestContext& ctx) { 459Result IHidServer::GetGyroscopeZeroDriftMode(Out<Core::HID::GyroscopeZeroDriftMode> out_drift_mode,
675 IPC::RequestParser rp{ctx}; 460 Core::HID::SixAxisSensorHandle sixaxis_handle,
676 struct Parameters { 461 ClientAppletResourceUserId aruid) {
677 Core::HID::SixAxisSensorHandle sixaxis_handle;
678 INSERT_PADDING_WORDS_NOINIT(1);
679 u64 applet_resource_user_id;
680 };
681 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
682
683 const auto parameters{rp.PopRaw<Parameters>()};
684
685 auto drift_mode{Core::HID::GyroscopeZeroDriftMode::Standard};
686 auto six_axis = GetResourceManager()->GetSixAxis();
687 const auto result = six_axis->GetGyroscopeZeroDriftMode(parameters.sixaxis_handle, drift_mode);
688
689 LOG_DEBUG(Service_HID, 462 LOG_DEBUG(Service_HID,
690 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 463 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
691 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 464 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
692 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 465 aruid.pid);
693 466
694 IPC::ResponseBuilder rb{ctx, 3}; 467 R_RETURN(GetResourceManager()->GetSixAxis()->GetGyroscopeZeroDriftMode(sixaxis_handle,
695 rb.Push(result); 468 *out_drift_mode));
696 rb.PushEnum(drift_mode);
697} 469}
698 470
699void IHidServer::ResetGyroscopeZeroDriftMode(HLERequestContext& ctx) { 471Result IHidServer::ResetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
700 IPC::RequestParser rp{ctx}; 472 ClientAppletResourceUserId aruid) {
701 struct Parameters {
702 Core::HID::SixAxisSensorHandle sixaxis_handle;
703 INSERT_PADDING_WORDS_NOINIT(1);
704 u64 applet_resource_user_id;
705 };
706 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
707
708 const auto parameters{rp.PopRaw<Parameters>()};
709
710 const auto drift_mode{Core::HID::GyroscopeZeroDriftMode::Standard};
711 auto six_axis = GetResourceManager()->GetSixAxis();
712 const auto result = six_axis->SetGyroscopeZeroDriftMode(parameters.sixaxis_handle, drift_mode);
713
714 LOG_DEBUG(Service_HID, 473 LOG_DEBUG(Service_HID,
715 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 474 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
716 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 475 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
717 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 476 aruid.pid);
718 477
719 IPC::ResponseBuilder rb{ctx, 2}; 478 const auto drift_mode{Core::HID::GyroscopeZeroDriftMode::Standard};
720 rb.Push(result); 479 R_RETURN(
480 GetResourceManager()->GetSixAxis()->SetGyroscopeZeroDriftMode(sixaxis_handle, drift_mode));
721} 481}
722 482
723void IHidServer::IsSixAxisSensorAtRest(HLERequestContext& ctx) { 483Result IHidServer::IsSixAxisSensorAtRest(Out<bool> out_is_at_rest,
724 IPC::RequestParser rp{ctx}; 484 Core::HID::SixAxisSensorHandle sixaxis_handle,
725 struct Parameters { 485 ClientAppletResourceUserId aruid) {
726 Core::HID::SixAxisSensorHandle sixaxis_handle;
727 INSERT_PADDING_WORDS_NOINIT(1);
728 u64 applet_resource_user_id;
729 };
730 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
731
732 const auto parameters{rp.PopRaw<Parameters>()};
733
734 bool is_at_rest{};
735 auto six_axis = GetResourceManager()->GetSixAxis();
736 six_axis->IsSixAxisSensorAtRest(parameters.sixaxis_handle, is_at_rest);
737
738 LOG_DEBUG(Service_HID, 486 LOG_DEBUG(Service_HID,
739 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 487 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
740 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 488 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index,
741 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id); 489 aruid.pid);
742 490
743 IPC::ResponseBuilder rb{ctx, 3}; 491 R_RETURN(
744 rb.Push(ResultSuccess); 492 GetResourceManager()->GetSixAxis()->IsSixAxisSensorAtRest(sixaxis_handle, *out_is_at_rest));
745 rb.Push(is_at_rest);
746} 493}
747 494
748void IHidServer::IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx) { 495Result IHidServer::IsFirmwareUpdateAvailableForSixAxisSensor(
749 IPC::RequestParser rp{ctx}; 496 Out<bool> out_is_firmware_available, Core::HID::SixAxisSensorHandle sixaxis_handle,
750 struct Parameters { 497 ClientAppletResourceUserId aruid) {
751 Core::HID::SixAxisSensorHandle sixaxis_handle;
752 INSERT_PADDING_WORDS_NOINIT(1);
753 u64 applet_resource_user_id;
754 };
755 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
756
757 const auto parameters{rp.PopRaw<Parameters>()};
758
759 bool is_firmware_available{};
760 auto controller = GetResourceManager()->GetNpad();
761 controller->IsFirmwareUpdateAvailableForSixAxisSensor(
762 parameters.applet_resource_user_id, parameters.sixaxis_handle, is_firmware_available);
763
764 LOG_WARNING( 498 LOG_WARNING(
765 Service_HID, 499 Service_HID,
766 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 500 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
767 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 501 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, aruid.pid);
768 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
769 502
770 IPC::ResponseBuilder rb{ctx, 3}; 503 R_RETURN(GetResourceManager()->GetNpad()->IsFirmwareUpdateAvailableForSixAxisSensor(
771 rb.Push(ResultSuccess); 504 aruid.pid, sixaxis_handle, *out_is_firmware_available));
772 rb.Push(is_firmware_available);
773} 505}
774 506
775void IHidServer::EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx) { 507Result IHidServer::EnableSixAxisSensorUnalteredPassthrough(
776 IPC::RequestParser rp{ctx}; 508 bool is_enabled, Core::HID::SixAxisSensorHandle sixaxis_handle,
777 struct Parameters { 509 ClientAppletResourceUserId aruid) {
778 bool enabled;
779 Core::HID::SixAxisSensorHandle sixaxis_handle;
780 u64 applet_resource_user_id;
781 };
782 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
783
784 const auto parameters{rp.PopRaw<Parameters>()};
785
786 auto six_axis = GetResourceManager()->GetSixAxis();
787 const auto result = six_axis->EnableSixAxisSensorUnalteredPassthrough(parameters.sixaxis_handle,
788 parameters.enabled);
789
790 LOG_DEBUG(Service_HID, 510 LOG_DEBUG(Service_HID,
791 "(STUBBED) called, enabled={}, npad_type={}, npad_id={}, device_index={}, " 511 "(STUBBED) called, enabled={}, npad_type={}, npad_id={}, device_index={}, "
792 "applet_resource_user_id={}", 512 "applet_resource_user_id={}",
793 parameters.enabled, parameters.sixaxis_handle.npad_type, 513 is_enabled, sixaxis_handle.npad_type, sixaxis_handle.npad_id,
794 parameters.sixaxis_handle.npad_id, parameters.sixaxis_handle.device_index, 514 sixaxis_handle.device_index, aruid.pid);
795 parameters.applet_resource_user_id);
796 515
797 IPC::ResponseBuilder rb{ctx, 2}; 516 R_RETURN(GetResourceManager()->GetSixAxis()->EnableSixAxisSensorUnalteredPassthrough(
798 rb.Push(result); 517 sixaxis_handle, is_enabled));
799} 518}
800 519
801void IHidServer::IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx) { 520Result IHidServer::IsSixAxisSensorUnalteredPassthroughEnabled(
802 IPC::RequestParser rp{ctx}; 521 Out<bool> out_is_enabled, Core::HID::SixAxisSensorHandle sixaxis_handle,
803 struct Parameters { 522 ClientAppletResourceUserId aruid) {
804 Core::HID::SixAxisSensorHandle sixaxis_handle;
805 INSERT_PADDING_WORDS_NOINIT(1);
806 u64 applet_resource_user_id;
807 };
808 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
809
810 const auto parameters{rp.PopRaw<Parameters>()};
811
812 bool is_unaltered_sisxaxis_enabled{};
813 auto six_axis = GetResourceManager()->GetSixAxis();
814 const auto result = six_axis->IsSixAxisSensorUnalteredPassthroughEnabled(
815 parameters.sixaxis_handle, is_unaltered_sisxaxis_enabled);
816
817 LOG_DEBUG( 523 LOG_DEBUG(
818 Service_HID, 524 Service_HID,
819 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 525 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
820 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 526 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, aruid.pid);
821 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
822 527
823 IPC::ResponseBuilder rb{ctx, 3}; 528 R_RETURN(GetResourceManager()->GetSixAxis()->IsSixAxisSensorUnalteredPassthroughEnabled(
824 rb.Push(result); 529 sixaxis_handle, *out_is_enabled));
825 rb.Push(is_unaltered_sisxaxis_enabled);
826} 530}
827 531
828void IHidServer::LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx) { 532Result IHidServer::LoadSixAxisSensorCalibrationParameter(
829 IPC::RequestParser rp{ctx}; 533 OutLargeData<Core::HID::SixAxisSensorCalibrationParameter, BufferAttr_HipcMapAlias>
830 struct Parameters { 534 out_calibration,
831 Core::HID::SixAxisSensorHandle sixaxis_handle; 535 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid) {
832 INSERT_PADDING_WORDS_NOINIT(1);
833 u64 applet_resource_user_id;
834 };
835 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
836
837 const auto parameters{rp.PopRaw<Parameters>()};
838
839 Core::HID::SixAxisSensorCalibrationParameter calibration{};
840 auto six_axis = GetResourceManager()->GetSixAxis();
841 const auto result =
842 six_axis->LoadSixAxisSensorCalibrationParameter(parameters.sixaxis_handle, calibration);
843
844 LOG_WARNING( 536 LOG_WARNING(
845 Service_HID, 537 Service_HID,
846 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 538 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
847 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 539 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, aruid.pid);
848 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
849
850 if (result.IsSuccess()) {
851 ctx.WriteBuffer(calibration);
852 }
853 540
854 IPC::ResponseBuilder rb{ctx, 2}; 541 R_RETURN(GetResourceManager()->GetSixAxis()->LoadSixAxisSensorCalibrationParameter(
855 rb.Push(result); 542 sixaxis_handle, *out_calibration));
856} 543}
857 544
858void IHidServer::GetSixAxisSensorIcInformation(HLERequestContext& ctx) { 545Result IHidServer::GetSixAxisSensorIcInformation(
859 IPC::RequestParser rp{ctx}; 546 OutLargeData<Core::HID::SixAxisSensorIcInformation, BufferAttr_HipcPointer> out_ic_information,
860 struct Parameters { 547 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid) {
861 Core::HID::SixAxisSensorHandle sixaxis_handle;
862 INSERT_PADDING_WORDS_NOINIT(1);
863 u64 applet_resource_user_id;
864 };
865 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
866
867 const auto parameters{rp.PopRaw<Parameters>()};
868
869 Core::HID::SixAxisSensorIcInformation ic_information{};
870 auto six_axis = GetResourceManager()->GetSixAxis();
871 const auto result =
872 six_axis->GetSixAxisSensorIcInformation(parameters.sixaxis_handle, ic_information);
873
874 LOG_WARNING( 548 LOG_WARNING(
875 Service_HID, 549 Service_HID,
876 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 550 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
877 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 551 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, aruid.pid);
878 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
879
880 if (result.IsSuccess()) {
881 ctx.WriteBuffer(ic_information);
882 }
883 552
884 IPC::ResponseBuilder rb{ctx, 2}; 553 R_RETURN(GetResourceManager()->GetSixAxis()->GetSixAxisSensorIcInformation(
885 rb.Push(result); 554 sixaxis_handle, *out_ic_information));
886} 555}
887 556
888void IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx) { 557Result IHidServer::ResetIsSixAxisSensorDeviceNewlyAssigned(
889 IPC::RequestParser rp{ctx}; 558 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid) {
890 struct Parameters {
891 Core::HID::SixAxisSensorHandle sixaxis_handle;
892 INSERT_PADDING_WORDS_NOINIT(1);
893 u64 applet_resource_user_id;
894 };
895 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
896
897 const auto parameters{rp.PopRaw<Parameters>()};
898
899 auto controller = GetResourceManager()->GetNpad();
900 const auto result = controller->ResetIsSixAxisSensorDeviceNewlyAssigned(
901 parameters.applet_resource_user_id, parameters.sixaxis_handle);
902
903 LOG_WARNING( 559 LOG_WARNING(
904 Service_HID, 560 Service_HID,
905 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 561 "(STUBBED) called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
906 parameters.sixaxis_handle.npad_type, parameters.sixaxis_handle.npad_id, 562 sixaxis_handle.npad_type, sixaxis_handle.npad_id, sixaxis_handle.device_index, aruid.pid);
907 parameters.sixaxis_handle.device_index, parameters.applet_resource_user_id);
908 563
909 IPC::ResponseBuilder rb{ctx, 2}; 564 R_RETURN(GetResourceManager()->GetNpad()->ResetIsSixAxisSensorDeviceNewlyAssigned(
910 rb.Push(result); 565 aruid.pid, sixaxis_handle));
911} 566}
912 567
913void IHidServer::ActivateGesture(HLERequestContext& ctx) { 568Result IHidServer::ActivateGesture(u32 basic_gesture_id, ClientAppletResourceUserId aruid) {
914 IPC::RequestParser rp{ctx};
915 struct Parameters {
916 u32 basic_gesture_id;
917 INSERT_PADDING_WORDS_NOINIT(1);
918 u64 applet_resource_user_id;
919 };
920 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
921
922 const auto parameters{rp.PopRaw<Parameters>()};
923
924 LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}", 569 LOG_INFO(Service_HID, "called, basic_gesture_id={}, applet_resource_user_id={}",
925 parameters.basic_gesture_id, parameters.applet_resource_user_id); 570 basic_gesture_id, aruid.pid);
926
927 Result result = ResultSuccess;
928 auto gesture = GetResourceManager()->GetGesture();
929 571
930 if (!firmware_settings->IsDeviceManaged()) { 572 if (!firmware_settings->IsDeviceManaged()) {
931 result = gesture->Activate(); 573 R_TRY(GetResourceManager()->GetGesture()->Activate());
932 }
933
934 if (result.IsSuccess()) {
935 result = gesture->Activate(parameters.applet_resource_user_id, parameters.basic_gesture_id);
936 } 574 }
937 575
938 IPC::ResponseBuilder rb{ctx, 2}; 576 R_RETURN(GetResourceManager()->GetGesture()->Activate(aruid.pid, basic_gesture_id));
939 rb.Push(result);
940} 577}
941 578
942void IHidServer::SetSupportedNpadStyleSet(HLERequestContext& ctx) { 579Result IHidServer::SetSupportedNpadStyleSet(Core::HID::NpadStyleSet supported_style_set,
943 IPC::RequestParser rp{ctx}; 580 ClientAppletResourceUserId aruid) {
944 struct Parameters {
945 Core::HID::NpadStyleSet supported_style_set;
946 INSERT_PADDING_WORDS_NOINIT(1);
947 u64 applet_resource_user_id;
948 };
949 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
950
951 const auto parameters{rp.PopRaw<Parameters>()};
952
953 LOG_DEBUG(Service_HID, "called, supported_style_set={}, applet_resource_user_id={}", 581 LOG_DEBUG(Service_HID, "called, supported_style_set={}, applet_resource_user_id={}",
954 parameters.supported_style_set, parameters.applet_resource_user_id); 582 supported_style_set, aruid.pid);
955 583
956 const auto npad = GetResourceManager()->GetNpad(); 584 R_TRY(
957 const Result result = npad->SetSupportedNpadStyleSet(parameters.applet_resource_user_id, 585 GetResourceManager()->GetNpad()->SetSupportedNpadStyleSet(aruid.pid, supported_style_set));
958 parameters.supported_style_set);
959 586
960 if (result.IsSuccess()) { 587 Core::HID::NpadStyleTag style_tag{supported_style_set};
961 Core::HID::NpadStyleTag style_tag{parameters.supported_style_set}; 588 const auto revision = GetResourceManager()->GetNpad()->GetRevision(aruid.pid);
962 const auto revision = npad->GetRevision(parameters.applet_resource_user_id);
963 589
964 if (style_tag.palma != 0 && revision < NpadRevision::Revision3) { 590 if (style_tag.palma != 0 && revision < NpadRevision::Revision3) {
965 // GetResourceManager()->GetPalma()->EnableBoostMode(parameters.applet_resource_user_id, 591 // GetResourceManager()->GetPalma()->EnableBoostMode(aruid.pid, true);
966 // true);
967 }
968 } 592 }
969 593
970 IPC::ResponseBuilder rb{ctx, 2}; 594 R_SUCCEED()
971 rb.Push(result);
972} 595}
973 596
974void IHidServer::GetSupportedNpadStyleSet(HLERequestContext& ctx) { 597Result IHidServer::GetSupportedNpadStyleSet(Out<Core::HID::NpadStyleSet> out_supported_style_set,
975 IPC::RequestParser rp{ctx}; 598 ClientAppletResourceUserId aruid) {
976 const auto applet_resource_user_id{rp.Pop<u64>()}; 599 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
977 600
978 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 601 R_RETURN(GetResourceManager()->GetNpad()->GetSupportedNpadStyleSet(aruid.pid,
979 602 *out_supported_style_set));
980 Core::HID::NpadStyleSet supported_style_set{};
981 const auto npad = GetResourceManager()->GetNpad();
982 const auto result =
983 npad->GetSupportedNpadStyleSet(applet_resource_user_id, supported_style_set);
984
985 IPC::ResponseBuilder rb{ctx, 3};
986 rb.Push(result);
987 rb.PushEnum(supported_style_set);
988} 603}
989 604
990void IHidServer::SetSupportedNpadIdType(HLERequestContext& ctx) { 605Result IHidServer::SetSupportedNpadIdType(
991 IPC::RequestParser rp{ctx}; 606 ClientAppletResourceUserId aruid,
992 const auto applet_resource_user_id{rp.Pop<u64>()}; 607 InArray<Core::HID::NpadIdType, BufferAttr_HipcPointer> supported_npad_list) {
993 const auto buffer = ctx.ReadBuffer(); 608 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
994 const std::size_t elements = ctx.GetReadBufferNumElements<Core::HID::NpadIdType>();
995
996 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
997 609
998 std::vector<Core::HID::NpadIdType> supported_npad_list(elements); 610 R_RETURN(
999 memcpy(supported_npad_list.data(), buffer.data(), buffer.size()); 611 GetResourceManager()->GetNpad()->SetSupportedNpadIdType(aruid.pid, supported_npad_list));
1000
1001 const auto npad = GetResourceManager()->GetNpad();
1002 const Result result =
1003 npad->SetSupportedNpadIdType(applet_resource_user_id, supported_npad_list);
1004
1005 IPC::ResponseBuilder rb{ctx, 2};
1006 rb.Push(result);
1007} 612}
1008 613
1009void IHidServer::ActivateNpad(HLERequestContext& ctx) { 614Result IHidServer::ActivateNpad(ClientAppletResourceUserId aruid) {
1010 IPC::RequestParser rp{ctx}; 615 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1011 const auto applet_resource_user_id{rp.Pop<u64>()};
1012
1013 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1014 616
1015 auto npad = GetResourceManager()->GetNpad(); 617 auto npad = GetResourceManager()->GetNpad();
1016 618
1017 npad->SetRevision(applet_resource_user_id, NpadRevision::Revision0); 619 GetResourceManager()->GetNpad()->SetRevision(aruid.pid, NpadRevision::Revision0);
1018 const Result result = npad->Activate(applet_resource_user_id); 620 R_RETURN(GetResourceManager()->GetNpad()->Activate(aruid.pid));
1019
1020 IPC::ResponseBuilder rb{ctx, 2};
1021 rb.Push(result);
1022} 621}
1023 622
1024void IHidServer::DeactivateNpad(HLERequestContext& ctx) { 623Result IHidServer::DeactivateNpad(ClientAppletResourceUserId aruid) {
1025 IPC::RequestParser rp{ctx}; 624 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1026 const auto applet_resource_user_id{rp.Pop<u64>()};
1027
1028 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1029 625
1030 // This function does nothing since 10.0.0+ 626 // This function does nothing since 10.0.0+
1031 627 R_SUCCEED();
1032 IPC::ResponseBuilder rb{ctx, 2};
1033 rb.Push(ResultSuccess);
1034} 628}
1035 629
1036void IHidServer::AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx) { 630Result IHidServer::AcquireNpadStyleSetUpdateEventHandle(
1037 IPC::RequestParser rp{ctx}; 631 OutCopyHandle<Kernel::KReadableEvent> out_event, Core::HID::NpadIdType npad_id,
1038 struct Parameters { 632 ClientAppletResourceUserId aruid, u64 unknown) {
1039 Core::HID::NpadIdType npad_id; 633 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}, unknown={}", npad_id,
1040 INSERT_PADDING_WORDS_NOINIT(1); 634 aruid.pid, unknown);
1041 u64 applet_resource_user_id;
1042 u64 unknown;
1043 };
1044 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1045
1046 const auto parameters{rp.PopRaw<Parameters>()};
1047
1048 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}, unknown={}",
1049 parameters.npad_id, parameters.applet_resource_user_id, parameters.unknown);
1050
1051 Kernel::KReadableEvent* style_set_update_event;
1052 const auto result = GetResourceManager()->GetNpad()->AcquireNpadStyleSetUpdateEventHandle(
1053 parameters.applet_resource_user_id, &style_set_update_event, parameters.npad_id);
1054 635
1055 IPC::ResponseBuilder rb{ctx, 2, 1}; 636 R_RETURN(GetResourceManager()->GetNpad()->AcquireNpadStyleSetUpdateEventHandle(
1056 rb.Push(result); 637 aruid.pid, out_event, npad_id));
1057 rb.PushCopyObjects(style_set_update_event);
1058} 638}
1059 639
1060void IHidServer::DisconnectNpad(HLERequestContext& ctx) { 640Result IHidServer::DisconnectNpad(Core::HID::NpadIdType npad_id, ClientAppletResourceUserId aruid) {
1061 IPC::RequestParser rp{ctx}; 641 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", npad_id, aruid.pid);
1062 struct Parameters {
1063 Core::HID::NpadIdType npad_id;
1064 INSERT_PADDING_WORDS_NOINIT(1);
1065 u64 applet_resource_user_id;
1066 };
1067 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1068
1069 const auto parameters{rp.PopRaw<Parameters>()};
1070
1071 auto controller = GetResourceManager()->GetNpad();
1072 controller->DisconnectNpad(parameters.applet_resource_user_id, parameters.npad_id);
1073 642
1074 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, 643 R_RETURN(GetResourceManager()->GetNpad()->DisconnectNpad(aruid.pid, npad_id));
1075 parameters.applet_resource_user_id);
1076
1077 IPC::ResponseBuilder rb{ctx, 2};
1078 rb.Push(ResultSuccess);
1079} 644}
1080 645
1081Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, 646Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
@@ -1113,833 +678,445 @@ Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_patter
1113 } 678 }
1114} 679}
1115 680
1116void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { 681Result IHidServer::ActivateNpadWithRevision(NpadRevision revision,
1117 IPC::RequestParser rp{ctx}; 682 ClientAppletResourceUserId aruid) {
1118 struct Parameters { 683 LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", revision, aruid.pid);
1119 NpadRevision revision;
1120 INSERT_PADDING_WORDS_NOINIT(1);
1121 u64 applet_resource_user_id;
1122 };
1123 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1124
1125 const auto parameters{rp.PopRaw<Parameters>()};
1126
1127 LOG_DEBUG(Service_HID, "called, revision={}, applet_resource_user_id={}", parameters.revision,
1128 parameters.applet_resource_user_id);
1129
1130 auto npad = GetResourceManager()->GetNpad();
1131 684
1132 npad->SetRevision(parameters.applet_resource_user_id, parameters.revision); 685 GetResourceManager()->GetNpad()->SetRevision(aruid.pid, revision);
1133 const auto result = npad->Activate(parameters.applet_resource_user_id); 686 R_RETURN(GetResourceManager()->GetNpad()->Activate(aruid.pid));
1134
1135 IPC::ResponseBuilder rb{ctx, 2};
1136 rb.Push(result);
1137} 687}
1138 688
1139void IHidServer::SetNpadJoyHoldType(HLERequestContext& ctx) { 689Result IHidServer::SetNpadJoyHoldType(ClientAppletResourceUserId aruid, NpadJoyHoldType hold_type) {
1140 IPC::RequestParser rp{ctx}; 690 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, hold_type={}", aruid.pid,
1141 const auto applet_resource_user_id{rp.Pop<u64>()}; 691 hold_type);
1142 const auto hold_type{rp.PopEnum<NpadJoyHoldType>()};
1143
1144 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, hold_type={}",
1145 applet_resource_user_id, hold_type);
1146 692
1147 if (hold_type != NpadJoyHoldType::Horizontal && hold_type != NpadJoyHoldType::Vertical) { 693 if (hold_type != NpadJoyHoldType::Horizontal && hold_type != NpadJoyHoldType::Vertical) {
1148 // This should crash console 694 // This should crash console
1149 ASSERT_MSG(false, "Invalid npad joy hold type"); 695 ASSERT_MSG(false, "Invalid npad joy hold type");
1150 } 696 }
1151 697
1152 const auto npad = GetResourceManager()->GetNpad(); 698 R_RETURN(GetResourceManager()->GetNpad()->SetNpadJoyHoldType(aruid.pid, hold_type));
1153 const auto result = npad->SetNpadJoyHoldType(applet_resource_user_id, hold_type);
1154
1155 IPC::ResponseBuilder rb{ctx, 2};
1156 rb.Push(result);
1157} 699}
1158 700
1159void IHidServer::GetNpadJoyHoldType(HLERequestContext& ctx) { 701Result IHidServer::GetNpadJoyHoldType(Out<NpadJoyHoldType> out_hold_type,
1160 IPC::RequestParser rp{ctx}; 702 ClientAppletResourceUserId aruid) {
1161 const auto applet_resource_user_id{rp.Pop<u64>()}; 703 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1162 704
1163 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 705 R_RETURN(GetResourceManager()->GetNpad()->GetNpadJoyHoldType(aruid.pid, *out_hold_type));
1164
1165 NpadJoyHoldType hold_type{};
1166 const auto npad = GetResourceManager()->GetNpad();
1167 const auto result = npad->GetNpadJoyHoldType(applet_resource_user_id, hold_type);
1168
1169 IPC::ResponseBuilder rb{ctx, 4};
1170 rb.Push(result);
1171 rb.PushEnum(hold_type);
1172} 706}
1173 707
1174void IHidServer::SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx) { 708Result IHidServer::SetNpadJoyAssignmentModeSingleByDefault(Core::HID::NpadIdType npad_id,
1175 IPC::RequestParser rp{ctx}; 709 ClientAppletResourceUserId aruid) {
1176 struct Parameters { 710 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", npad_id, aruid.pid);
1177 Core::HID::NpadIdType npad_id;
1178 INSERT_PADDING_WORDS_NOINIT(1);
1179 u64 applet_resource_user_id;
1180 };
1181 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1182
1183 const auto parameters{rp.PopRaw<Parameters>()};
1184 711
1185 Core::HID::NpadIdType new_npad_id{}; 712 Core::HID::NpadIdType new_npad_id{};
1186 auto controller = GetResourceManager()->GetNpad(); 713 GetResourceManager()->GetNpad()->SetNpadMode(
1187 controller->SetNpadMode(parameters.applet_resource_user_id, new_npad_id, parameters.npad_id, 714 aruid.pid, new_npad_id, npad_id, NpadJoyDeviceType::Left, NpadJoyAssignmentMode::Single);
1188 NpadJoyDeviceType::Left, NpadJoyAssignmentMode::Single); 715 R_SUCCEED();
1189
1190 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
1191 parameters.applet_resource_user_id);
1192
1193 IPC::ResponseBuilder rb{ctx, 2};
1194 rb.Push(ResultSuccess);
1195} 716}
1196 717
1197void IHidServer::SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx) { 718Result IHidServer::SetNpadJoyAssignmentModeSingle(Core::HID::NpadIdType npad_id,
1198 IPC::RequestParser rp{ctx}; 719 ClientAppletResourceUserId aruid,
1199 struct Parameters { 720 NpadJoyDeviceType npad_joy_device_type) {
1200 Core::HID::NpadIdType npad_id;
1201 INSERT_PADDING_WORDS_NOINIT(1);
1202 u64 applet_resource_user_id;
1203 NpadJoyDeviceType npad_joy_device_type;
1204 };
1205 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1206
1207 const auto parameters{rp.PopRaw<Parameters>()};
1208
1209 Core::HID::NpadIdType new_npad_id{};
1210 auto controller = GetResourceManager()->GetNpad();
1211 controller->SetNpadMode(parameters.applet_resource_user_id, new_npad_id, parameters.npad_id,
1212 parameters.npad_joy_device_type, NpadJoyAssignmentMode::Single);
1213
1214 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", 721 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}",
1215 parameters.npad_id, parameters.applet_resource_user_id, 722 npad_id, aruid.pid, npad_joy_device_type);
1216 parameters.npad_joy_device_type);
1217 723
1218 IPC::ResponseBuilder rb{ctx, 2}; 724 Core::HID::NpadIdType new_npad_id{};
1219 rb.Push(ResultSuccess); 725 GetResourceManager()->GetNpad()->SetNpadMode(
726 aruid.pid, new_npad_id, npad_id, npad_joy_device_type, NpadJoyAssignmentMode::Single);
727 R_SUCCEED();
1220} 728}
1221 729
1222void IHidServer::SetNpadJoyAssignmentModeDual(HLERequestContext& ctx) { 730Result IHidServer::SetNpadJoyAssignmentModeDual(Core::HID::NpadIdType npad_id,
1223 IPC::RequestParser rp{ctx}; 731 ClientAppletResourceUserId aruid) {
1224 struct Parameters { 732 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", npad_id, aruid.pid);
1225 Core::HID::NpadIdType npad_id;
1226 INSERT_PADDING_WORDS_NOINIT(1);
1227 u64 applet_resource_user_id;
1228 };
1229 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1230
1231 const auto parameters{rp.PopRaw<Parameters>()};
1232 733
1233 Core::HID::NpadIdType new_npad_id{}; 734 Core::HID::NpadIdType new_npad_id{};
1234 auto controller = GetResourceManager()->GetNpad(); 735 GetResourceManager()->GetNpad()->SetNpadMode(aruid.pid, new_npad_id, npad_id, {},
1235 controller->SetNpadMode(parameters.applet_resource_user_id, new_npad_id, parameters.npad_id, {}, 736 NpadJoyAssignmentMode::Dual);
1236 NpadJoyAssignmentMode::Dual); 737 R_SUCCEED();
1237
1238 LOG_DEBUG(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
1239 parameters.applet_resource_user_id); // Spams a lot when controller applet is open
1240
1241 IPC::ResponseBuilder rb{ctx, 2};
1242 rb.Push(ResultSuccess);
1243} 738}
1244 739
1245void IHidServer::MergeSingleJoyAsDualJoy(HLERequestContext& ctx) { 740Result IHidServer::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
1246 IPC::RequestParser rp{ctx}; 741 Core::HID::NpadIdType npad_id_2,
1247 const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; 742 ClientAppletResourceUserId aruid) {
1248 const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()};
1249 const auto applet_resource_user_id{rp.Pop<u64>()};
1250
1251 auto controller = GetResourceManager()->GetNpad();
1252 const auto result =
1253 controller->MergeSingleJoyAsDualJoy(applet_resource_user_id, npad_id_1, npad_id_2);
1254
1255 LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}", 743 LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}",
1256 npad_id_1, npad_id_2, applet_resource_user_id); 744 npad_id_1, npad_id_2, aruid.pid);
1257 745
1258 IPC::ResponseBuilder rb{ctx, 2}; 746 R_RETURN(
1259 rb.Push(result); 747 GetResourceManager()->GetNpad()->MergeSingleJoyAsDualJoy(aruid.pid, npad_id_1, npad_id_2));
1260} 748}
1261 749
1262void IHidServer::StartLrAssignmentMode(HLERequestContext& ctx) { 750Result IHidServer::StartLrAssignmentMode(ClientAppletResourceUserId aruid) {
1263 IPC::RequestParser rp{ctx}; 751 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1264 const auto applet_resource_user_id{rp.Pop<u64>()};
1265 752
1266 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 753 GetResourceManager()->GetNpad()->StartLrAssignmentMode(aruid.pid);
1267 754 R_SUCCEED();
1268 GetResourceManager()->GetNpad()->StartLrAssignmentMode(applet_resource_user_id);
1269
1270 IPC::ResponseBuilder rb{ctx, 2};
1271 rb.Push(ResultSuccess);
1272} 755}
1273 756
1274void IHidServer::StopLrAssignmentMode(HLERequestContext& ctx) { 757Result IHidServer::StopLrAssignmentMode(ClientAppletResourceUserId aruid) {
1275 IPC::RequestParser rp{ctx}; 758 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1276 const auto applet_resource_user_id{rp.Pop<u64>()};
1277
1278 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1279 759
1280 GetResourceManager()->GetNpad()->StopLrAssignmentMode(applet_resource_user_id); 760 GetResourceManager()->GetNpad()->StopLrAssignmentMode(aruid.pid);
1281 761 R_SUCCEED();
1282 IPC::ResponseBuilder rb{ctx, 2};
1283 rb.Push(ResultSuccess);
1284} 762}
1285 763
1286void IHidServer::SetNpadHandheldActivationMode(HLERequestContext& ctx) { 764Result IHidServer::SetNpadHandheldActivationMode(ClientAppletResourceUserId aruid,
1287 IPC::RequestParser rp{ctx}; 765 NpadHandheldActivationMode activation_mode) {
1288 const auto applet_resource_user_id{rp.Pop<u64>()}; 766 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, activation_mode={}", aruid.pid,
1289 const auto activation_mode{rp.PopEnum<NpadHandheldActivationMode>()}; 767 activation_mode);
1290
1291 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, activation_mode={}",
1292 applet_resource_user_id, activation_mode);
1293 768
1294 if (activation_mode >= NpadHandheldActivationMode::MaxActivationMode) { 769 if (activation_mode >= NpadHandheldActivationMode::MaxActivationMode) {
1295 // Console should crash here 770 // Console should crash here
1296 ASSERT_MSG(false, "Activation mode should be always None, Single or Dual"); 771 ASSERT_MSG(false, "Activation mode should be always None, Single or Dual");
1297 IPC::ResponseBuilder rb{ctx, 2}; 772 R_SUCCEED();
1298 rb.Push(ResultSuccess);
1299 return;
1300 } 773 }
1301 774
1302 const auto npad = GetResourceManager()->GetNpad(); 775 R_RETURN(
1303 const auto result = 776 GetResourceManager()->GetNpad()->SetNpadHandheldActivationMode(aruid.pid, activation_mode));
1304 npad->SetNpadHandheldActivationMode(applet_resource_user_id, activation_mode);
1305
1306 IPC::ResponseBuilder rb{ctx, 2};
1307 rb.Push(result);
1308} 777}
1309 778
1310void IHidServer::GetNpadHandheldActivationMode(HLERequestContext& ctx) { 779Result IHidServer::GetNpadHandheldActivationMode(
1311 IPC::RequestParser rp{ctx}; 780 Out<NpadHandheldActivationMode> out_activation_mode, ClientAppletResourceUserId aruid) {
1312 const auto applet_resource_user_id{rp.Pop<u64>()}; 781 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1313
1314 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1315
1316 NpadHandheldActivationMode activation_mode{};
1317 const auto npad = GetResourceManager()->GetNpad();
1318 const auto result =
1319 npad->GetNpadHandheldActivationMode(applet_resource_user_id, activation_mode);
1320 782
1321 IPC::ResponseBuilder rb{ctx, 4}; 783 R_RETURN(GetResourceManager()->GetNpad()->GetNpadHandheldActivationMode(aruid.pid,
1322 rb.Push(result); 784 *out_activation_mode));
1323 rb.PushEnum(activation_mode);
1324} 785}
1325 786
1326void IHidServer::SwapNpadAssignment(HLERequestContext& ctx) { 787Result IHidServer::SwapNpadAssignment(Core::HID::NpadIdType npad_id_1,
1327 IPC::RequestParser rp{ctx}; 788 Core::HID::NpadIdType npad_id_2,
1328 const auto npad_id_1{rp.PopEnum<Core::HID::NpadIdType>()}; 789 ClientAppletResourceUserId aruid) {
1329 const auto npad_id_2{rp.PopEnum<Core::HID::NpadIdType>()};
1330 const auto applet_resource_user_id{rp.Pop<u64>()};
1331
1332 LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}", 790 LOG_DEBUG(Service_HID, "called, npad_id_1={}, npad_id_2={}, applet_resource_user_id={}",
1333 npad_id_1, npad_id_2, applet_resource_user_id); 791 npad_id_1, npad_id_2, aruid.pid);
1334
1335 const auto npad = GetResourceManager()->GetNpad();
1336 const auto result = npad->SwapNpadAssignment(applet_resource_user_id, npad_id_1, npad_id_2);
1337 792
1338 IPC::ResponseBuilder rb{ctx, 2}; 793 R_RETURN(GetResourceManager()->GetNpad()->SwapNpadAssignment(aruid.pid, npad_id_1, npad_id_2))
1339 rb.Push(result);
1340} 794}
1341 795
1342void IHidServer::IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx) { 796Result IHidServer::IsUnintendedHomeButtonInputProtectionEnabled(Out<bool> out_is_enabled,
1343 IPC::RequestParser rp{ctx}; 797 Core::HID::NpadIdType npad_id,
1344 struct Parameters { 798 ClientAppletResourceUserId aruid) {
1345 Core::HID::NpadIdType npad_id; 799 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", npad_id, aruid.pid);
1346 INSERT_PADDING_WORDS_NOINIT(1);
1347 u64 applet_resource_user_id;
1348 };
1349 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1350
1351 const auto parameters{rp.PopRaw<Parameters>()};
1352
1353 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id,
1354 parameters.applet_resource_user_id);
1355
1356 if (!IsNpadIdValid(parameters.npad_id)) {
1357 IPC::ResponseBuilder rb{ctx, 3};
1358 rb.Push(ResultInvalidNpadId);
1359 return;
1360 }
1361
1362 bool is_enabled{};
1363 const auto npad = GetResourceManager()->GetNpad();
1364 const auto result = npad->IsUnintendedHomeButtonInputProtectionEnabled(
1365 is_enabled, parameters.applet_resource_user_id, parameters.npad_id);
1366 800
1367 IPC::ResponseBuilder rb{ctx, 3}; 801 R_UNLESS(IsNpadIdValid(npad_id), ResultInvalidNpadId);
1368 rb.Push(result); 802 R_RETURN(GetResourceManager()->GetNpad()->IsUnintendedHomeButtonInputProtectionEnabled(
1369 rb.Push(is_enabled); 803 *out_is_enabled, aruid.pid, npad_id));
1370} 804}
1371 805
1372void IHidServer::EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx) { 806Result IHidServer::EnableUnintendedHomeButtonInputProtection(bool is_enabled,
1373 IPC::RequestParser rp{ctx}; 807 Core::HID::NpadIdType npad_id,
1374 struct Parameters { 808 ClientAppletResourceUserId aruid) {
1375 bool is_enabled;
1376 INSERT_PADDING_BYTES_NOINIT(3);
1377 Core::HID::NpadIdType npad_id;
1378 u64 applet_resource_user_id;
1379 };
1380 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1381
1382 const auto parameters{rp.PopRaw<Parameters>()};
1383
1384 LOG_DEBUG(Service_HID, "called, is_enabled={}, npad_id={}, applet_resource_user_id={}", 809 LOG_DEBUG(Service_HID, "called, is_enabled={}, npad_id={}, applet_resource_user_id={}",
1385 parameters.is_enabled, parameters.npad_id, parameters.applet_resource_user_id); 810 is_enabled, npad_id, aruid.pid);
1386
1387 if (!IsNpadIdValid(parameters.npad_id)) {
1388 IPC::ResponseBuilder rb{ctx, 3};
1389 rb.Push(ResultInvalidNpadId);
1390 return;
1391 }
1392 811
1393 const auto npad = GetResourceManager()->GetNpad(); 812 R_UNLESS(IsNpadIdValid(npad_id), ResultInvalidNpadId);
1394 const auto result = npad->EnableUnintendedHomeButtonInputProtection( 813 R_RETURN(GetResourceManager()->GetNpad()->EnableUnintendedHomeButtonInputProtection(
1395 parameters.applet_resource_user_id, parameters.npad_id, parameters.is_enabled); 814 aruid.pid, npad_id, is_enabled));
1396
1397 IPC::ResponseBuilder rb{ctx, 2};
1398 rb.Push(result);
1399} 815}
1400 816
1401void IHidServer::SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx) { 817Result IHidServer::SetNpadJoyAssignmentModeSingleWithDestination(
1402 IPC::RequestParser rp{ctx}; 818 Out<bool> out_is_reassigned, Out<Core::HID::NpadIdType> out_new_npad_id,
1403 struct Parameters { 819 Core::HID::NpadIdType npad_id, ClientAppletResourceUserId aruid,
1404 Core::HID::NpadIdType npad_id; 820 NpadJoyDeviceType npad_joy_device_type) {
1405 INSERT_PADDING_WORDS_NOINIT(1);
1406 u64 applet_resource_user_id;
1407 NpadJoyDeviceType npad_joy_device_type;
1408 };
1409 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1410
1411 const auto parameters{rp.PopRaw<Parameters>()};
1412
1413 Core::HID::NpadIdType new_npad_id{};
1414 auto controller = GetResourceManager()->GetNpad();
1415 const auto is_reassigned =
1416 controller->SetNpadMode(parameters.applet_resource_user_id, new_npad_id, parameters.npad_id,
1417 parameters.npad_joy_device_type, NpadJoyAssignmentMode::Single);
1418
1419 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", 821 LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}",
1420 parameters.npad_id, parameters.applet_resource_user_id, 822 npad_id, aruid.pid, npad_joy_device_type);
1421 parameters.npad_joy_device_type);
1422 823
1423 IPC::ResponseBuilder rb{ctx, 4}; 824 *out_is_reassigned = GetResourceManager()->GetNpad()->SetNpadMode(
1424 rb.Push(ResultSuccess); 825 aruid.pid, *out_new_npad_id, npad_id, npad_joy_device_type, NpadJoyAssignmentMode::Single);
1425 rb.Push(is_reassigned);
1426 rb.PushEnum(new_npad_id);
1427}
1428
1429void IHidServer::SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx) {
1430 IPC::RequestParser rp{ctx};
1431 struct Parameters {
1432 bool use_center_clamp;
1433 INSERT_PADDING_BYTES_NOINIT(7);
1434 u64 applet_resource_user_id;
1435 };
1436 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1437 826
1438 const auto parameters{rp.PopRaw<Parameters>()}; 827 R_SUCCEED();
828}
1439 829
830Result IHidServer::SetNpadAnalogStickUseCenterClamp(bool use_center_clamp,
831 ClientAppletResourceUserId aruid) {
1440 LOG_INFO(Service_HID, "called, use_center_clamp={}, applet_resource_user_id={}", 832 LOG_INFO(Service_HID, "called, use_center_clamp={}, applet_resource_user_id={}",
1441 parameters.use_center_clamp, parameters.applet_resource_user_id); 833 use_center_clamp, aruid.pid);
1442
1443 GetResourceManager()->GetNpad()->SetNpadAnalogStickUseCenterClamp(
1444 parameters.applet_resource_user_id, parameters.use_center_clamp);
1445 834
1446 IPC::ResponseBuilder rb{ctx, 2}; 835 GetResourceManager()->GetNpad()->SetNpadAnalogStickUseCenterClamp(aruid.pid, use_center_clamp);
1447 rb.Push(ResultSuccess); 836 R_SUCCEED();
1448} 837}
1449 838
1450void IHidServer::SetNpadCaptureButtonAssignment(HLERequestContext& ctx) { 839Result IHidServer::SetNpadCaptureButtonAssignment(Core::HID::NpadStyleSet npad_styleset,
1451 IPC::RequestParser rp{ctx}; 840 ClientAppletResourceUserId aruid,
1452 struct Parameters { 841 Core::HID::NpadButton button) {
1453 Core::HID::NpadStyleSet npad_styleset;
1454 INSERT_PADDING_WORDS_NOINIT(1);
1455 u64 applet_resource_user_id;
1456 Core::HID::NpadButton button;
1457 };
1458 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1459
1460 const auto parameters{rp.PopRaw<Parameters>()};
1461
1462 LOG_INFO(Service_HID, "called, npad_styleset={}, applet_resource_user_id={}, button={}", 842 LOG_INFO(Service_HID, "called, npad_styleset={}, applet_resource_user_id={}, button={}",
1463 parameters.npad_styleset, parameters.applet_resource_user_id, parameters.button); 843 npad_styleset, aruid.pid, button);
1464
1465 const auto result = GetResourceManager()->GetNpad()->SetNpadCaptureButtonAssignment(
1466 parameters.applet_resource_user_id, parameters.npad_styleset, parameters.button);
1467 844
1468 IPC::ResponseBuilder rb{ctx, 2}; 845 R_RETURN(GetResourceManager()->GetNpad()->SetNpadCaptureButtonAssignment(
1469 rb.Push(result); 846 aruid.pid, npad_styleset, button));
1470} 847}
1471 848
1472void IHidServer::ClearNpadCaptureButtonAssignment(HLERequestContext& ctx) { 849Result IHidServer::ClearNpadCaptureButtonAssignment(ClientAppletResourceUserId aruid) {
1473 IPC::RequestParser rp{ctx}; 850 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1474 const auto applet_resource_user_id{rp.Pop<u64>()};
1475 851
1476 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 852 R_RETURN(GetResourceManager()->GetNpad()->ClearNpadCaptureButtonAssignment(aruid.pid));
1477
1478 const auto result =
1479 GetResourceManager()->GetNpad()->ClearNpadCaptureButtonAssignment(applet_resource_user_id);
1480
1481 IPC::ResponseBuilder rb{ctx, 2};
1482 rb.Push(result);
1483} 853}
1484 854
1485void IHidServer::GetVibrationDeviceInfo(HLERequestContext& ctx) { 855Result IHidServer::GetVibrationDeviceInfo(
1486 IPC::RequestParser rp{ctx}; 856 Out<Core::HID::VibrationDeviceInfo> out_vibration_device_info,
1487 const auto vibration_device_handle{rp.PopRaw<Core::HID::VibrationDeviceHandle>()}; 857 Core::HID::VibrationDeviceHandle vibration_device_handle) {
1488 858 LOG_DEBUG(Service_HID, "called, npad_type={}, npad_id={}, device_index={}",
1489 Core::HID::VibrationDeviceInfo vibration_device_info{}; 859 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1490 const auto result = GetResourceManager()->GetVibrationDeviceInfo(vibration_device_info, 860 vibration_device_handle.device_index);
1491 vibration_device_handle);
1492 861
1493 IPC::ResponseBuilder rb{ctx, 4}; 862 R_RETURN(GetResourceManager()->GetVibrationDeviceInfo(*out_vibration_device_info,
1494 rb.Push(result); 863 vibration_device_handle));
1495 rb.PushRaw(vibration_device_info);
1496} 864}
1497 865
1498void IHidServer::SendVibrationValue(HLERequestContext& ctx) { 866Result IHidServer::SendVibrationValue(Core::HID::VibrationDeviceHandle vibration_device_handle,
1499 IPC::RequestParser rp{ctx}; 867 Core::HID::VibrationValue vibration_value,
1500 struct Parameters { 868 ClientAppletResourceUserId aruid) {
1501 Core::HID::VibrationDeviceHandle vibration_device_handle;
1502 Core::HID::VibrationValue vibration_value;
1503 INSERT_PADDING_WORDS_NOINIT(1);
1504 u64 applet_resource_user_id;
1505 };
1506 static_assert(sizeof(Parameters) == 0x20, "Parameters has incorrect size.");
1507
1508 const auto parameters{rp.PopRaw<Parameters>()};
1509
1510 LOG_DEBUG(Service_HID, 869 LOG_DEBUG(Service_HID,
1511 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 870 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
1512 parameters.vibration_device_handle.npad_type, 871 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1513 parameters.vibration_device_handle.npad_id, 872 vibration_device_handle.device_index, aruid.pid);
1514 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
1515
1516 GetResourceManager()->SendVibrationValue(parameters.applet_resource_user_id,
1517 parameters.vibration_device_handle,
1518 parameters.vibration_value);
1519 873
1520 IPC::ResponseBuilder rb{ctx, 2}; 874 GetResourceManager()->SendVibrationValue(aruid.pid, vibration_device_handle, vibration_value);
1521 rb.Push(ResultSuccess); 875 R_SUCCEED()
1522} 876}
1523 877
1524void IHidServer::GetActualVibrationValue(HLERequestContext& ctx) { 878Result IHidServer::GetActualVibrationValue(Out<Core::HID::VibrationValue> out_vibration_value,
1525 IPC::RequestParser rp{ctx}; 879 Core::HID::VibrationDeviceHandle vibration_device_handle,
1526 struct Parameters { 880 ClientAppletResourceUserId aruid) {
1527 Core::HID::VibrationDeviceHandle vibration_device_handle;
1528 INSERT_PADDING_WORDS_NOINIT(1);
1529 u64 applet_resource_user_id;
1530 };
1531 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1532
1533 const auto parameters{rp.PopRaw<Parameters>()};
1534
1535 LOG_DEBUG(Service_HID, 881 LOG_DEBUG(Service_HID,
1536 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 882 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
1537 parameters.vibration_device_handle.npad_type, 883 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1538 parameters.vibration_device_handle.npad_id, 884 vibration_device_handle.device_index, aruid.pid);
1539 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
1540 885
1541 bool has_active_aruid{}; 886 bool has_active_aruid{};
1542 NpadVibrationDevice* device{nullptr}; 887 R_TRY(GetResourceManager()->IsVibrationAruidActive(aruid.pid, has_active_aruid));
1543 Core::HID::VibrationValue vibration_value{};
1544 Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
1545 has_active_aruid);
1546 888
1547 if (result.IsSuccess() && has_active_aruid) { 889 if (!has_active_aruid) {
1548 result = IsVibrationHandleValid(parameters.vibration_device_handle); 890 *out_vibration_value = Core::HID::DEFAULT_VIBRATION_VALUE;
1549 } 891 R_SUCCEED();
1550 if (result.IsSuccess() && has_active_aruid) {
1551 device = GetResourceManager()->GetNSVibrationDevice(parameters.vibration_device_handle);
1552 }
1553 if (device != nullptr) {
1554 result = device->GetActualVibrationValue(vibration_value);
1555 } 892 }
1556 if (result.IsError()) { 893
1557 vibration_value = Core::HID::DEFAULT_VIBRATION_VALUE; 894 R_TRY(IsVibrationHandleValid(vibration_device_handle));
895 NpadVibrationDevice* device =
896 GetResourceManager()->GetNSVibrationDevice(vibration_device_handle);
897
898 if (device == nullptr || R_FAILED(device->GetActualVibrationValue(*out_vibration_value))) {
899 *out_vibration_value = Core::HID::DEFAULT_VIBRATION_VALUE;
1558 } 900 }
1559 901
1560 IPC::ResponseBuilder rb{ctx, 6}; 902 R_SUCCEED();
1561 rb.Push(ResultSuccess);
1562 rb.PushRaw(vibration_value);
1563} 903}
1564 904
1565void IHidServer::CreateActiveVibrationDeviceList(HLERequestContext& ctx) { 905Result IHidServer::CreateActiveVibrationDeviceList(
906 OutInterface<IActiveVibrationDeviceList> out_interface) {
1566 LOG_DEBUG(Service_HID, "called"); 907 LOG_DEBUG(Service_HID, "called");
1567 908
1568 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 909 *out_interface = std::make_shared<IActiveVibrationDeviceList>(system, GetResourceManager());
1569 rb.Push(ResultSuccess); 910 R_SUCCEED();
1570 rb.PushIpcInterface<IActiveVibrationDeviceList>(system, GetResourceManager());
1571} 911}
1572 912
1573void IHidServer::PermitVibration(HLERequestContext& ctx) { 913Result IHidServer::PermitVibration(bool can_vibrate) {
1574 IPC::RequestParser rp{ctx};
1575 const auto can_vibrate{rp.Pop<bool>()};
1576
1577 LOG_DEBUG(Service_HID, "called, can_vibrate={}", can_vibrate); 914 LOG_DEBUG(Service_HID, "called, can_vibrate={}", can_vibrate);
1578 915
1579 const auto result = 916 R_RETURN(GetResourceManager()->GetNpad()->GetVibrationHandler()->SetVibrationMasterVolume(
1580 GetResourceManager()->GetNpad()->GetVibrationHandler()->SetVibrationMasterVolume( 917 can_vibrate ? 1.0f : 0.0f));
1581 can_vibrate ? 1.0f : 0.0f);
1582
1583 IPC::ResponseBuilder rb{ctx, 2};
1584 rb.Push(result);
1585} 918}
1586 919
1587void IHidServer::IsVibrationPermitted(HLERequestContext& ctx) { 920Result IHidServer::IsVibrationPermitted(Out<bool> out_is_permitted) {
1588 LOG_DEBUG(Service_HID, "called"); 921 LOG_DEBUG(Service_HID, "called");
1589 922
1590 f32 master_volume{}; 923 f32 master_volume{};
1591 const auto result = 924 R_TRY(GetResourceManager()->GetNpad()->GetVibrationHandler()->GetVibrationMasterVolume(
1592 GetResourceManager()->GetNpad()->GetVibrationHandler()->GetVibrationMasterVolume( 925 master_volume));
1593 master_volume);
1594 926
1595 IPC::ResponseBuilder rb{ctx, 3}; 927 *out_is_permitted = master_volume > 0.0f;
1596 rb.Push(result); 928 R_SUCCEED();
1597 rb.Push(master_volume > 0.0f);
1598} 929}
1599 930
1600void IHidServer::SendVibrationValues(HLERequestContext& ctx) { 931Result IHidServer::SendVibrationValues(
1601 IPC::RequestParser rp{ctx}; 932 ClientAppletResourceUserId aruid,
1602 const auto applet_resource_user_id{rp.Pop<u64>()}; 933 InArray<Core::HID::VibrationDeviceHandle, BufferAttr_HipcPointer> vibration_handles,
1603 934 InArray<Core::HID::VibrationValue, BufferAttr_HipcPointer> vibration_values) {
1604 const auto handle_data = ctx.ReadBuffer(0); 935 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1605 const auto handle_count = ctx.GetReadBufferNumElements<Core::HID::VibrationDeviceHandle>(0);
1606 const auto vibration_data = ctx.ReadBuffer(1);
1607 const auto vibration_count = ctx.GetReadBufferNumElements<Core::HID::VibrationValue>(1);
1608 936
1609 auto vibration_device_handles = 937 R_UNLESS(vibration_handles.size() == vibration_values.size(), ResultVibrationArraySizeMismatch);
1610 std::span(reinterpret_cast<const Core::HID::VibrationDeviceHandle*>(handle_data.data()),
1611 handle_count);
1612 auto vibration_values = std::span(
1613 reinterpret_cast<const Core::HID::VibrationValue*>(vibration_data.data()), vibration_count);
1614
1615 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1616
1617 Result result = ResultSuccess;
1618 if (handle_count != vibration_count) {
1619 result = ResultVibrationArraySizeMismatch;
1620 }
1621 938
1622 for (std::size_t i = 0; i < handle_count; i++) { 939 for (std::size_t i = 0; i < vibration_handles.size(); i++) {
1623 if (result.IsSuccess()) { 940 R_TRY(GetResourceManager()->SendVibrationValue(aruid.pid, vibration_handles[i],
1624 result = GetResourceManager()->SendVibrationValue( 941 vibration_values[i]));
1625 applet_resource_user_id, vibration_device_handles[i], vibration_values[i]);
1626 }
1627 } 942 }
1628 943
1629 IPC::ResponseBuilder rb{ctx, 2}; 944 R_SUCCEED();
1630 rb.Push(result);
1631} 945}
1632 946
1633void IHidServer::SendVibrationGcErmCommand(HLERequestContext& ctx) { 947Result IHidServer::SendVibrationGcErmCommand(
1634 IPC::RequestParser rp{ctx}; 948 Core::HID::VibrationDeviceHandle vibration_device_handle, ClientAppletResourceUserId aruid,
1635 struct Parameters { 949 Core::HID::VibrationGcErmCommand gc_erm_command) {
1636 Core::HID::VibrationDeviceHandle vibration_device_handle;
1637 INSERT_PADDING_WORDS_NOINIT(1);
1638 u64 applet_resource_user_id;
1639 Core::HID::VibrationGcErmCommand gc_erm_command;
1640 };
1641 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1642
1643 const auto parameters{rp.PopRaw<Parameters>()};
1644
1645 LOG_DEBUG(Service_HID, 950 LOG_DEBUG(Service_HID,
1646 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, " 951 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, "
1647 "gc_erm_command={}", 952 "gc_erm_command={}",
1648 parameters.vibration_device_handle.npad_type, 953 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1649 parameters.vibration_device_handle.npad_id, 954 vibration_device_handle.device_index, aruid.pid, gc_erm_command);
1650 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id,
1651 parameters.gc_erm_command);
1652 955
1653 bool has_active_aruid{}; 956 bool has_active_aruid{};
1654 NpadGcVibrationDevice* gc_device{nullptr}; 957 R_TRY(GetResourceManager()->IsVibrationAruidActive(aruid.pid, has_active_aruid));
1655 Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
1656 has_active_aruid);
1657 958
1658 if (result.IsSuccess() && has_active_aruid) { 959 if (!has_active_aruid) {
1659 result = IsVibrationHandleValid(parameters.vibration_device_handle); 960 R_SUCCEED();
1660 }
1661 if (result.IsSuccess() && has_active_aruid) {
1662 gc_device = GetResourceManager()->GetGcVibrationDevice(parameters.vibration_device_handle);
1663 } 961 }
962
963 R_TRY(IsVibrationHandleValid(vibration_device_handle));
964 NpadGcVibrationDevice* gc_device =
965 GetResourceManager()->GetGcVibrationDevice(vibration_device_handle);
1664 if (gc_device != nullptr) { 966 if (gc_device != nullptr) {
1665 result = gc_device->SendVibrationGcErmCommand(parameters.gc_erm_command); 967 R_RETURN(gc_device->SendVibrationGcErmCommand(gc_erm_command));
1666 } 968 }
1667 969
1668 IPC::ResponseBuilder rb{ctx, 2}; 970 R_SUCCEED();
1669 rb.Push(result);
1670} 971}
1671 972
1672void IHidServer::GetActualVibrationGcErmCommand(HLERequestContext& ctx) { 973Result IHidServer::GetActualVibrationGcErmCommand(
1673 IPC::RequestParser rp{ctx}; 974 Out<Core::HID::VibrationGcErmCommand> out_gc_erm_command,
1674 struct Parameters { 975 Core::HID::VibrationDeviceHandle vibration_device_handle, ClientAppletResourceUserId aruid) {
1675 Core::HID::VibrationDeviceHandle vibration_device_handle;
1676 INSERT_PADDING_WORDS_NOINIT(1);
1677 u64 applet_resource_user_id;
1678 };
1679
1680 const auto parameters{rp.PopRaw<Parameters>()};
1681
1682 LOG_DEBUG(Service_HID, 976 LOG_DEBUG(Service_HID,
1683 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 977 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
1684 parameters.vibration_device_handle.npad_type, 978 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1685 parameters.vibration_device_handle.npad_id, 979 vibration_device_handle.device_index, aruid.pid);
1686 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
1687 980
1688 bool has_active_aruid{}; 981 bool has_active_aruid{};
1689 NpadGcVibrationDevice* gc_device{nullptr}; 982 R_TRY(GetResourceManager()->IsVibrationAruidActive(aruid.pid, has_active_aruid));
1690 Core::HID::VibrationGcErmCommand gc_erm_command{};
1691 Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
1692 has_active_aruid);
1693 983
1694 if (result.IsSuccess() && has_active_aruid) { 984 if (!has_active_aruid) {
1695 result = IsVibrationHandleValid(parameters.vibration_device_handle); 985 *out_gc_erm_command = Core::HID::VibrationGcErmCommand::Stop;
1696 }
1697 if (result.IsSuccess() && has_active_aruid) {
1698 gc_device = GetResourceManager()->GetGcVibrationDevice(parameters.vibration_device_handle);
1699 }
1700 if (gc_device != nullptr) {
1701 result = gc_device->GetActualVibrationGcErmCommand(gc_erm_command);
1702 }
1703 if (result.IsError()) {
1704 gc_erm_command = Core::HID::VibrationGcErmCommand::Stop;
1705 } 986 }
1706 987
1707 IPC::ResponseBuilder rb{ctx, 4}; 988 R_TRY(IsVibrationHandleValid(vibration_device_handle));
1708 rb.Push(ResultSuccess); 989 NpadGcVibrationDevice* gc_device =
1709 rb.PushEnum(gc_erm_command); 990 GetResourceManager()->GetGcVibrationDevice(vibration_device_handle);
1710}
1711 991
1712void IHidServer::BeginPermitVibrationSession(HLERequestContext& ctx) { 992 if (gc_device == nullptr ||
1713 IPC::RequestParser rp{ctx}; 993 R_FAILED(gc_device->GetActualVibrationGcErmCommand(*out_gc_erm_command))) {
1714 const auto applet_resource_user_id{rp.Pop<u64>()}; 994 *out_gc_erm_command = Core::HID::VibrationGcErmCommand::Stop;
995 }
1715 996
1716 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); 997 R_SUCCEED();
998}
1717 999
1718 const auto result = 1000Result IHidServer::BeginPermitVibrationSession(ClientAppletResourceUserId aruid) {
1719 GetResourceManager()->GetNpad()->GetVibrationHandler()->BeginPermitVibrationSession( 1001 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1720 applet_resource_user_id);
1721 1002
1722 IPC::ResponseBuilder rb{ctx, 2}; 1003 R_RETURN(GetResourceManager()->GetNpad()->GetVibrationHandler()->BeginPermitVibrationSession(
1723 rb.Push(result); 1004 aruid.pid));
1724} 1005}
1725 1006
1726void IHidServer::EndPermitVibrationSession(HLERequestContext& ctx) { 1007Result IHidServer::EndPermitVibrationSession(ClientAppletResourceUserId aruid) {
1727 LOG_DEBUG(Service_HID, "called"); 1008 LOG_DEBUG(Service_HID, "called");
1728 1009
1729 const auto result = 1010 R_RETURN(GetResourceManager()->GetNpad()->GetVibrationHandler()->EndPermitVibrationSession());
1730 GetResourceManager()->GetNpad()->GetVibrationHandler()->EndPermitVibrationSession();
1731
1732 IPC::ResponseBuilder rb{ctx, 2};
1733 rb.Push(result);
1734} 1011}
1735 1012
1736void IHidServer::IsVibrationDeviceMounted(HLERequestContext& ctx) { 1013Result IHidServer::IsVibrationDeviceMounted(
1737 IPC::RequestParser rp{ctx}; 1014 Out<bool> out_is_mounted, Core::HID::VibrationDeviceHandle vibration_device_handle,
1738 struct Parameters { 1015 ClientAppletResourceUserId aruid) {
1739 Core::HID::VibrationDeviceHandle vibration_device_handle;
1740 INSERT_PADDING_WORDS_NOINIT(1);
1741 u64 applet_resource_user_id;
1742 };
1743 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1744
1745 const auto parameters{rp.PopRaw<Parameters>()};
1746
1747 LOG_DEBUG(Service_HID, 1016 LOG_DEBUG(Service_HID,
1748 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}", 1017 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}",
1749 parameters.vibration_device_handle.npad_type, 1018 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1750 parameters.vibration_device_handle.npad_id, 1019 vibration_device_handle.device_index, aruid.pid);
1751 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id);
1752 1020
1753 bool is_mounted{}; 1021 R_TRY(IsVibrationHandleValid(vibration_device_handle));
1754 NpadVibrationBase* device{nullptr};
1755 Result result = IsVibrationHandleValid(parameters.vibration_device_handle);
1756 1022
1757 if (result.IsSuccess()) { 1023 NpadVibrationBase* device = GetResourceManager()->GetVibrationDevice(vibration_device_handle);
1758 device = GetResourceManager()->GetVibrationDevice(parameters.vibration_device_handle);
1759 }
1760 1024
1761 if (device != nullptr) { 1025 if (device != nullptr) {
1762 is_mounted = device->IsVibrationMounted(); 1026 *out_is_mounted = device->IsVibrationMounted();
1763 } 1027 }
1764 1028
1765 IPC::ResponseBuilder rb{ctx, 3}; 1029 R_SUCCEED();
1766 rb.Push(result);
1767 rb.Push(is_mounted);
1768} 1030}
1769 1031
1770void IHidServer::SendVibrationValueInBool(HLERequestContext& ctx) { 1032Result IHidServer::SendVibrationValueInBool(
1771 IPC::RequestParser rp{ctx}; 1033 bool is_vibrating, Core::HID::VibrationDeviceHandle vibration_device_handle,
1772 struct Parameters { 1034 ClientAppletResourceUserId aruid) {
1773 Core::HID::VibrationDeviceHandle vibration_device_handle;
1774 INSERT_PADDING_WORDS_NOINIT(1);
1775 u64 applet_resource_user_id;
1776 bool is_vibrating;
1777 };
1778 static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size.");
1779
1780 const auto parameters{rp.PopRaw<Parameters>()};
1781
1782 LOG_DEBUG(Service_HID, 1035 LOG_DEBUG(Service_HID,
1783 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, " 1036 "called, npad_type={}, npad_id={}, device_index={}, applet_resource_user_id={}, "
1784 "is_vibrating={}", 1037 "is_vibrating={}",
1785 parameters.vibration_device_handle.npad_type, 1038 vibration_device_handle.npad_type, vibration_device_handle.npad_id,
1786 parameters.vibration_device_handle.npad_id, 1039 vibration_device_handle.device_index, aruid.pid, is_vibrating);
1787 parameters.vibration_device_handle.device_index, parameters.applet_resource_user_id,
1788 parameters.is_vibrating);
1789 1040
1790 bool has_active_aruid{}; 1041 bool has_active_aruid{};
1791 NpadN64VibrationDevice* n64_device{nullptr}; 1042 R_TRY(GetResourceManager()->IsVibrationAruidActive(aruid.pid, has_active_aruid));
1792 Result result = GetResourceManager()->IsVibrationAruidActive(parameters.applet_resource_user_id,
1793 has_active_aruid);
1794 1043
1795 if (result.IsSuccess() && has_active_aruid) { 1044 if (!has_active_aruid) {
1796 result = IsVibrationHandleValid(parameters.vibration_device_handle); 1045 R_SUCCEED();
1797 }
1798 if (result.IsSuccess() && has_active_aruid) {
1799 n64_device =
1800 GetResourceManager()->GetN64VibrationDevice(parameters.vibration_device_handle);
1801 } 1046 }
1047
1048 R_TRY(IsVibrationHandleValid(vibration_device_handle));
1049 NpadN64VibrationDevice* n64_device =
1050 GetResourceManager()->GetN64VibrationDevice(vibration_device_handle);
1051
1802 if (n64_device != nullptr) { 1052 if (n64_device != nullptr) {
1803 result = n64_device->SendValueInBool(parameters.is_vibrating); 1053 R_TRY(n64_device->SendValueInBool(is_vibrating));
1804 } 1054 }
1805 1055
1806 IPC::ResponseBuilder rb{ctx, 2}; 1056 R_SUCCEED();
1807 rb.Push(result);
1808} 1057}
1809 1058
1810void IHidServer::ActivateConsoleSixAxisSensor(HLERequestContext& ctx) { 1059Result IHidServer::ActivateConsoleSixAxisSensor(ClientAppletResourceUserId aruid) {
1811 IPC::RequestParser rp{ctx}; 1060 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1812 const auto applet_resource_user_id{rp.Pop<u64>()};
1813
1814 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1815
1816 Result result = ResultSuccess;
1817 auto console_sixaxis = GetResourceManager()->GetConsoleSixAxis();
1818 1061
1819 if (!firmware_settings->IsDeviceManaged()) { 1062 if (!firmware_settings->IsDeviceManaged()) {
1820 result = console_sixaxis->Activate(); 1063 R_TRY(GetResourceManager()->GetConsoleSixAxis()->Activate());
1821 }
1822
1823 if (result.IsSuccess()) {
1824 result = console_sixaxis->Activate(applet_resource_user_id);
1825 } 1064 }
1826 1065
1827 IPC::ResponseBuilder rb{ctx, 2}; 1066 R_RETURN(GetResourceManager()->GetConsoleSixAxis()->Activate(aruid.pid));
1828 rb.Push(result);
1829} 1067}
1830 1068
1831void IHidServer::StartConsoleSixAxisSensor(HLERequestContext& ctx) { 1069Result IHidServer::StartConsoleSixAxisSensor(
1832 IPC::RequestParser rp{ctx}; 1070 Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle,
1833 struct Parameters { 1071 ClientAppletResourceUserId aruid) {
1834 Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle;
1835 INSERT_PADDING_WORDS_NOINIT(1);
1836 u64 applet_resource_user_id;
1837 };
1838 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1839
1840 const auto parameters{rp.PopRaw<Parameters>()};
1841
1842 LOG_WARNING(Service_HID, 1072 LOG_WARNING(Service_HID,
1843 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", 1073 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}",
1844 parameters.console_sixaxis_handle.unknown_1, 1074 console_sixaxis_handle.unknown_1, console_sixaxis_handle.unknown_2, aruid.pid);
1845 parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); 1075 R_SUCCEED();
1846
1847 IPC::ResponseBuilder rb{ctx, 2};
1848 rb.Push(ResultSuccess);
1849} 1076}
1850 1077
1851void IHidServer::StopConsoleSixAxisSensor(HLERequestContext& ctx) { 1078Result IHidServer::StopConsoleSixAxisSensor(
1852 IPC::RequestParser rp{ctx}; 1079 Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle,
1853 struct Parameters { 1080 ClientAppletResourceUserId aruid) {
1854 Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle;
1855 INSERT_PADDING_WORDS_NOINIT(1);
1856 u64 applet_resource_user_id;
1857 };
1858 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
1859
1860 const auto parameters{rp.PopRaw<Parameters>()};
1861
1862 LOG_WARNING(Service_HID, 1081 LOG_WARNING(Service_HID,
1863 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}", 1082 "(STUBBED) called, unknown_1={}, unknown_2={}, applet_resource_user_id={}",
1864 parameters.console_sixaxis_handle.unknown_1, 1083 console_sixaxis_handle.unknown_1, console_sixaxis_handle.unknown_2, aruid.pid);
1865 parameters.console_sixaxis_handle.unknown_2, parameters.applet_resource_user_id); 1084 R_SUCCEED();
1866
1867 IPC::ResponseBuilder rb{ctx, 2};
1868 rb.Push(ResultSuccess);
1869} 1085}
1870 1086
1871void IHidServer::ActivateSevenSixAxisSensor(HLERequestContext& ctx) { 1087Result IHidServer::ActivateSevenSixAxisSensor(ClientAppletResourceUserId aruid) {
1872 IPC::RequestParser rp{ctx}; 1088 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1873 const auto applet_resource_user_id{rp.Pop<u64>()};
1874
1875 LOG_INFO(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1876
1877 Result result = ResultSuccess;
1878 auto seven_sixaxis = GetResourceManager()->GetSevenSixAxis();
1879 1089
1880 if (!firmware_settings->IsDeviceManaged()) { 1090 if (!firmware_settings->IsDeviceManaged()) {
1881 result = seven_sixaxis->Activate(); 1091 R_TRY(GetResourceManager()->GetSevenSixAxis()->Activate());
1882 }
1883
1884 if (result.IsSuccess()) {
1885 seven_sixaxis->Activate(applet_resource_user_id);
1886 } 1092 }
1887 1093
1888 IPC::ResponseBuilder rb{ctx, 2}; 1094 GetResourceManager()->GetSevenSixAxis()->Activate(aruid.pid);
1889 rb.Push(ResultSuccess); 1095 R_SUCCEED();
1890} 1096}
1891 1097
1892void IHidServer::StartSevenSixAxisSensor(HLERequestContext& ctx) { 1098Result IHidServer::StartSevenSixAxisSensor(ClientAppletResourceUserId aruid) {
1893 IPC::RequestParser rp{ctx}; 1099 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
1894 const auto applet_resource_user_id{rp.Pop<u64>()}; 1100 R_SUCCEED();
1895
1896 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
1897 applet_resource_user_id);
1898
1899 IPC::ResponseBuilder rb{ctx, 2};
1900 rb.Push(ResultSuccess);
1901} 1101}
1902 1102
1903void IHidServer::StopSevenSixAxisSensor(HLERequestContext& ctx) { 1103Result IHidServer::StopSevenSixAxisSensor(ClientAppletResourceUserId aruid) {
1904 IPC::RequestParser rp{ctx}; 1104 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
1905 const auto applet_resource_user_id{rp.Pop<u64>()}; 1105 R_SUCCEED();
1906
1907 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
1908 applet_resource_user_id);
1909
1910 IPC::ResponseBuilder rb{ctx, 2};
1911 rb.Push(ResultSuccess);
1912} 1106}
1913 1107
1914void IHidServer::InitializeSevenSixAxisSensor(HLERequestContext& ctx) { 1108Result IHidServer::InitializeSevenSixAxisSensor(ClientAppletResourceUserId aruid, u64 t_mem_1_size,
1915 IPC::RequestParser rp{ctx}; 1109 u64 t_mem_2_size,
1916 const auto applet_resource_user_id{rp.Pop<u64>()}; 1110 InCopyHandle<Kernel::KTransferMemory> t_mem_1,
1917 const auto t_mem_1_size{rp.Pop<u64>()}; 1111 InCopyHandle<Kernel::KTransferMemory> t_mem_2) {
1918 const auto t_mem_2_size{rp.Pop<u64>()}; 1112 LOG_WARNING(Service_HID,
1919 const auto t_mem_1_handle{ctx.GetCopyHandle(0)}; 1113 "called, t_mem_1_size=0x{:08X}, t_mem_2_size=0x{:08X}, "
1920 const auto t_mem_2_handle{ctx.GetCopyHandle(1)}; 1114 "applet_resource_user_id={}",
1115 t_mem_1_size, t_mem_2_size, aruid.pid);
1921 1116
1922 ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes"); 1117 ASSERT_MSG(t_mem_1_size == 0x1000, "t_mem_1_size is not 0x1000 bytes");
1923 ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes"); 1118 ASSERT_MSG(t_mem_2_size == 0x7F000, "t_mem_2_size is not 0x7F000 bytes");
1924 1119
1925 auto t_mem_1 = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_1_handle);
1926
1927 if (t_mem_1.IsNull()) {
1928 LOG_ERROR(Service_HID, "t_mem_1 is a nullptr for handle=0x{:08X}", t_mem_1_handle);
1929 IPC::ResponseBuilder rb{ctx, 2};
1930 rb.Push(ResultUnknown);
1931 return;
1932 }
1933
1934 auto t_mem_2 = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_2_handle);
1935
1936 if (t_mem_2.IsNull()) {
1937 LOG_ERROR(Service_HID, "t_mem_2 is a nullptr for handle=0x{:08X}", t_mem_2_handle);
1938 IPC::ResponseBuilder rb{ctx, 2};
1939 rb.Push(ResultUnknown);
1940 return;
1941 }
1942
1943 ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size"); 1120 ASSERT_MSG(t_mem_1->GetSize() == 0x1000, "t_mem_1 has incorrect size");
1944 ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size"); 1121 ASSERT_MSG(t_mem_2->GetSize() == 0x7F000, "t_mem_2 has incorrect size");
1945 1122
@@ -1949,519 +1126,309 @@ void IHidServer::InitializeSevenSixAxisSensor(HLERequestContext& ctx) {
1949 1126
1950 GetResourceManager()->GetSevenSixAxis()->SetTransferMemoryAddress(t_mem_1->GetSourceAddress()); 1127 GetResourceManager()->GetSevenSixAxis()->SetTransferMemoryAddress(t_mem_1->GetSourceAddress());
1951 1128
1952 LOG_WARNING(Service_HID, 1129 R_SUCCEED();
1953 "called, t_mem_1_handle=0x{:08X}, t_mem_2_handle=0x{:08X}, "
1954 "applet_resource_user_id={}",
1955 t_mem_1_handle, t_mem_2_handle, applet_resource_user_id);
1956
1957 IPC::ResponseBuilder rb{ctx, 2};
1958 rb.Push(ResultSuccess);
1959} 1130}
1960 1131
1961void IHidServer::FinalizeSevenSixAxisSensor(HLERequestContext& ctx) { 1132Result IHidServer::FinalizeSevenSixAxisSensor(ClientAppletResourceUserId aruid) {
1962 IPC::RequestParser rp{ctx}; 1133 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
1963 const auto applet_resource_user_id{rp.Pop<u64>()};
1964
1965 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
1966 applet_resource_user_id);
1967 1134
1968 IPC::ResponseBuilder rb{ctx, 2}; 1135 R_SUCCEED();
1969 rb.Push(ResultSuccess);
1970} 1136}
1971 1137
1972void IHidServer::ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx) { 1138Result IHidServer::ResetSevenSixAxisSensorTimestamp(ClientAppletResourceUserId aruid) {
1973 IPC::RequestParser rp{ctx}; 1139 LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
1974 const auto applet_resource_user_id{rp.Pop<u64>()};
1975 1140
1976 GetResourceManager()->GetSevenSixAxis()->ResetTimestamp(); 1141 GetResourceManager()->GetSevenSixAxis()->ResetTimestamp();
1977 1142 R_SUCCEED();
1978 LOG_WARNING(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1979
1980 IPC::ResponseBuilder rb{ctx, 2};
1981 rb.Push(ResultSuccess);
1982} 1143}
1983 1144
1984void IHidServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) { 1145Result IHidServer::IsUsbFullKeyControllerEnabled(Out<bool> out_is_enabled,
1985 IPC::RequestParser rp{ctx}; 1146 ClientAppletResourceUserId aruid) {
1986
1987 LOG_WARNING(Service_HID, "(STUBBED) called"); 1147 LOG_WARNING(Service_HID, "(STUBBED) called");
1988 1148
1989 IPC::ResponseBuilder rb{ctx, 3}; 1149 *out_is_enabled = false;
1990 rb.Push(ResultSuccess); 1150 R_SUCCEED();
1991 rb.Push(false);
1992} 1151}
1993 1152
1994void IHidServer::GetPalmaConnectionHandle(HLERequestContext& ctx) { 1153Result IHidServer::GetPalmaConnectionHandle(Out<Palma::PalmaConnectionHandle> out_handle,
1995 IPC::RequestParser rp{ctx}; 1154 Core::HID::NpadIdType npad_id,
1996 struct Parameters { 1155 ClientAppletResourceUserId aruid) {
1997 Core::HID::NpadIdType npad_id; 1156 LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", npad_id,
1998 INSERT_PADDING_WORDS_NOINIT(1); 1157 aruid.pid);
1999 u64 applet_resource_user_id;
2000 };
2001 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
2002
2003 const auto parameters{rp.PopRaw<Parameters>()};
2004
2005 LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}",
2006 parameters.npad_id, parameters.applet_resource_user_id);
2007 1158
2008 Palma::PalmaConnectionHandle handle; 1159 R_RETURN(GetResourceManager()->GetPalma()->GetPalmaConnectionHandle(npad_id, *out_handle));
2009 auto controller = GetResourceManager()->GetPalma();
2010 const auto result = controller->GetPalmaConnectionHandle(parameters.npad_id, handle);
2011
2012 IPC::ResponseBuilder rb{ctx, 4};
2013 rb.Push(result);
2014 rb.PushRaw(handle);
2015} 1160}
2016 1161
2017void IHidServer::InitializePalma(HLERequestContext& ctx) { 1162Result IHidServer::InitializePalma(Palma::PalmaConnectionHandle connection_handle) {
2018 IPC::RequestParser rp{ctx};
2019 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2020
2021 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1163 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2022 1164
2023 auto controller = GetResourceManager()->GetPalma(); 1165 R_RETURN(GetResourceManager()->GetPalma()->InitializePalma(connection_handle));
2024 const auto result = controller->InitializePalma(connection_handle);
2025
2026 IPC::ResponseBuilder rb{ctx, 2};
2027 rb.Push(result);
2028} 1166}
2029 1167
2030void IHidServer::AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx) { 1168Result IHidServer::AcquirePalmaOperationCompleteEvent(
2031 IPC::RequestParser rp{ctx}; 1169 OutCopyHandle<Kernel::KReadableEvent> out_event,
2032 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()}; 1170 Palma::PalmaConnectionHandle connection_handle) {
2033
2034 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1171 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2035 1172
2036 auto controller = GetResourceManager()->GetPalma(); 1173 *out_event =
2037 1174 &GetResourceManager()->GetPalma()->AcquirePalmaOperationCompleteEvent(connection_handle);
2038 IPC::ResponseBuilder rb{ctx, 2, 1}; 1175 R_SUCCEED();
2039 rb.Push(ResultSuccess);
2040 rb.PushCopyObjects(controller->AcquirePalmaOperationCompleteEvent(connection_handle));
2041} 1176}
2042 1177
2043void IHidServer::GetPalmaOperationInfo(HLERequestContext& ctx) { 1178Result IHidServer::GetPalmaOperationInfo(Out<Palma::PalmaOperationType> out_operation_type,
2044 IPC::RequestParser rp{ctx}; 1179 Palma::PalmaConnectionHandle connection_handle,
2045 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()}; 1180 OutBuffer<BufferAttr_HipcMapAlias> out_data) {
2046
2047 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1181 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2048 1182
2049 Palma::PalmaOperationType operation_type; 1183 R_RETURN(GetResourceManager()->GetPalma()->GetPalmaOperationInfo(
2050 Palma::PalmaOperationData data; 1184 connection_handle, *out_operation_type, out_data));
2051 auto controller = GetResourceManager()->GetPalma();
2052 const auto result = controller->GetPalmaOperationInfo(connection_handle, operation_type, data);
2053
2054 if (result.IsError()) {
2055 IPC::ResponseBuilder rb{ctx, 2};
2056 rb.Push(result);
2057 }
2058
2059 ctx.WriteBuffer(data);
2060 IPC::ResponseBuilder rb{ctx, 4};
2061 rb.Push(result);
2062 rb.Push(static_cast<u64>(operation_type));
2063} 1185}
2064 1186
2065void IHidServer::PlayPalmaActivity(HLERequestContext& ctx) { 1187Result IHidServer::PlayPalmaActivity(Palma::PalmaConnectionHandle connection_handle,
2066 IPC::RequestParser rp{ctx}; 1188 u64 palma_activity) {
2067 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2068 const auto palma_activity{rp.Pop<u64>()};
2069
2070 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, palma_activity={}", 1189 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, palma_activity={}",
2071 connection_handle.npad_id, palma_activity); 1190 connection_handle.npad_id, palma_activity);
2072 1191
2073 auto controller = GetResourceManager()->GetPalma(); 1192 R_RETURN(
2074 const auto result = controller->PlayPalmaActivity(connection_handle, palma_activity); 1193 GetResourceManager()->GetPalma()->PlayPalmaActivity(connection_handle, palma_activity));
2075
2076 IPC::ResponseBuilder rb{ctx, 2};
2077 rb.Push(result);
2078} 1194}
2079 1195
2080void IHidServer::SetPalmaFrModeType(HLERequestContext& ctx) { 1196Result IHidServer::SetPalmaFrModeType(Palma::PalmaConnectionHandle connection_handle,
2081 IPC::RequestParser rp{ctx}; 1197 Palma::PalmaFrModeType fr_mode) {
2082 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2083 const auto fr_mode{rp.PopEnum<Palma::PalmaFrModeType>()};
2084
2085 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, fr_mode={}", 1198 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, fr_mode={}",
2086 connection_handle.npad_id, fr_mode); 1199 connection_handle.npad_id, fr_mode);
2087 1200
2088 auto controller = GetResourceManager()->GetPalma(); 1201 R_RETURN(GetResourceManager()->GetPalma()->SetPalmaFrModeType(connection_handle, fr_mode));
2089 const auto result = controller->SetPalmaFrModeType(connection_handle, fr_mode);
2090
2091 IPC::ResponseBuilder rb{ctx, 2};
2092 rb.Push(result);
2093} 1202}
2094 1203
2095void IHidServer::ReadPalmaStep(HLERequestContext& ctx) { 1204Result IHidServer::ReadPalmaStep(Palma::PalmaConnectionHandle connection_handle) {
2096 IPC::RequestParser rp{ctx};
2097 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2098
2099 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1205 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2100 1206
2101 auto controller = GetResourceManager()->GetPalma(); 1207 R_RETURN(GetResourceManager()->GetPalma()->ReadPalmaStep(connection_handle));
2102 const auto result = controller->ReadPalmaStep(connection_handle);
2103
2104 IPC::ResponseBuilder rb{ctx, 2};
2105 rb.Push(result);
2106} 1208}
2107 1209
2108void IHidServer::EnablePalmaStep(HLERequestContext& ctx) { 1210Result IHidServer::EnablePalmaStep(bool is_enabled,
2109 IPC::RequestParser rp{ctx}; 1211 Palma::PalmaConnectionHandle connection_handle) {
2110 struct Parameters {
2111 bool is_enabled;
2112 INSERT_PADDING_WORDS_NOINIT(1);
2113 Palma::PalmaConnectionHandle connection_handle;
2114 };
2115 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
2116
2117 const auto parameters{rp.PopRaw<Parameters>()};
2118
2119 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, is_enabled={}", 1212 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, is_enabled={}",
2120 parameters.connection_handle.npad_id, parameters.is_enabled); 1213 connection_handle.npad_id, is_enabled);
2121
2122 auto controller = GetResourceManager()->GetPalma();
2123 const auto result =
2124 controller->EnablePalmaStep(parameters.connection_handle, parameters.is_enabled);
2125 1214
2126 IPC::ResponseBuilder rb{ctx, 2}; 1215 R_RETURN(GetResourceManager()->GetPalma()->EnablePalmaStep(connection_handle, is_enabled));
2127 rb.Push(result);
2128} 1216}
2129 1217
2130void IHidServer::ResetPalmaStep(HLERequestContext& ctx) { 1218Result IHidServer::ResetPalmaStep(Palma::PalmaConnectionHandle connection_handle) {
2131 IPC::RequestParser rp{ctx};
2132 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2133
2134 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1219 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2135 1220
2136 auto controller = GetResourceManager()->GetPalma(); 1221 R_RETURN(GetResourceManager()->GetPalma()->ResetPalmaStep(connection_handle));
2137 const auto result = controller->ResetPalmaStep(connection_handle);
2138
2139 IPC::ResponseBuilder rb{ctx, 2};
2140 rb.Push(result);
2141} 1222}
2142 1223
2143void IHidServer::ReadPalmaApplicationSection(HLERequestContext& ctx) { 1224Result IHidServer::ReadPalmaApplicationSection(Palma::PalmaConnectionHandle connection_handle,
2144 LOG_WARNING(Service_HID, "(STUBBED) called"); 1225 u64 offset, u64 size) {
2145 1226 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, offset={}, size={}",
2146 IPC::ResponseBuilder rb{ctx, 2}; 1227 connection_handle.npad_id, offset, size);
2147 rb.Push(ResultSuccess); 1228 R_SUCCEED();
2148} 1229}
2149 1230
2150void IHidServer::WritePalmaApplicationSection(HLERequestContext& ctx) { 1231Result IHidServer::WritePalmaApplicationSection(
2151 LOG_WARNING(Service_HID, "(STUBBED) called"); 1232 Palma::PalmaConnectionHandle connection_handle, u64 offset, u64 size,
2152 1233 InLargeData<Palma::PalmaApplicationSection, BufferAttr_HipcPointer> data) {
2153 IPC::ResponseBuilder rb{ctx, 2}; 1234 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, offset={}, size={}",
2154 rb.Push(ResultSuccess); 1235 connection_handle.npad_id, offset, size);
1236 R_SUCCEED();
2155} 1237}
2156 1238
2157void IHidServer::ReadPalmaUniqueCode(HLERequestContext& ctx) { 1239Result IHidServer::ReadPalmaUniqueCode(Palma::PalmaConnectionHandle connection_handle) {
2158 IPC::RequestParser rp{ctx};
2159 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2160
2161 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1240 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2162 1241
2163 GetResourceManager()->GetPalma()->ReadPalmaUniqueCode(connection_handle); 1242 GetResourceManager()->GetPalma()->ReadPalmaUniqueCode(connection_handle);
2164 1243 R_SUCCEED();
2165 IPC::ResponseBuilder rb{ctx, 2};
2166 rb.Push(ResultSuccess);
2167} 1244}
2168 1245
2169void IHidServer::SetPalmaUniqueCodeInvalid(HLERequestContext& ctx) { 1246Result IHidServer::SetPalmaUniqueCodeInvalid(Palma::PalmaConnectionHandle connection_handle) {
2170 IPC::RequestParser rp{ctx};
2171 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2172
2173 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1247 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2174 1248
2175 GetResourceManager()->GetPalma()->SetPalmaUniqueCodeInvalid(connection_handle); 1249 GetResourceManager()->GetPalma()->SetPalmaUniqueCodeInvalid(connection_handle);
2176 1250 R_SUCCEED();
2177 IPC::ResponseBuilder rb{ctx, 2};
2178 rb.Push(ResultSuccess);
2179} 1251}
2180 1252
2181void IHidServer::WritePalmaActivityEntry(HLERequestContext& ctx) { 1253Result IHidServer::WritePalmaActivityEntry(Palma::PalmaConnectionHandle connection_handle,
2182 LOG_CRITICAL(Service_HID, "(STUBBED) called"); 1254 Palma::PalmaActivityEntry activity_entry) {
2183 1255 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2184 IPC::ResponseBuilder rb{ctx, 2}; 1256 R_SUCCEED();
2185 rb.Push(ResultSuccess);
2186} 1257}
2187 1258
2188void IHidServer::WritePalmaRgbLedPatternEntry(HLERequestContext& ctx) { 1259Result IHidServer::WritePalmaRgbLedPatternEntry(Palma::PalmaConnectionHandle connection_handle,
2189 IPC::RequestParser rp{ctx}; 1260 u64 unknown,
2190 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()}; 1261 InBuffer<BufferAttr_HipcMapAlias> led_pattern) {
2191 const auto unknown{rp.Pop<u64>()};
2192
2193 [[maybe_unused]] const auto buffer = ctx.ReadBuffer();
2194
2195 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}", 1262 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, unknown={}",
2196 connection_handle.npad_id, unknown); 1263 connection_handle.npad_id, unknown);
2197 1264
2198 GetResourceManager()->GetPalma()->WritePalmaRgbLedPatternEntry(connection_handle, unknown); 1265 GetResourceManager()->GetPalma()->WritePalmaRgbLedPatternEntry(connection_handle, unknown);
2199 1266 R_SUCCEED();
2200 IPC::ResponseBuilder rb{ctx, 2};
2201 rb.Push(ResultSuccess);
2202} 1267}
2203 1268
2204void IHidServer::WritePalmaWaveEntry(HLERequestContext& ctx) { 1269Result IHidServer::WritePalmaWaveEntry(Palma::PalmaConnectionHandle connection_handle,
2205 IPC::RequestParser rp{ctx}; 1270 Palma::PalmaWaveSet wave_set, u64 unknown, u64 t_mem_size,
2206 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()}; 1271 u64 size, InCopyHandle<Kernel::KTransferMemory> t_mem) {
2207 const auto wave_set{rp.PopEnum<Palma::PalmaWaveSet>()}; 1272 ASSERT_MSG(t_mem->GetSize() == t_mem_size, "t_mem has incorrect size");
2208 const auto unknown{rp.Pop<u64>()};
2209 const auto t_mem_size{rp.Pop<u64>()};
2210 const auto t_mem_handle{ctx.GetCopyHandle(0)};
2211 const auto size{rp.Pop<u64>()};
2212 1273
2213 ASSERT_MSG(t_mem_size == 0x3000, "t_mem_size is not 0x3000 bytes"); 1274 LOG_WARNING(
2214 1275 Service_HID,
2215 auto t_mem = ctx.GetObjectFromHandle<Kernel::KTransferMemory>(t_mem_handle); 1276 "(STUBBED) called, connection_handle={}, wave_set={}, unknown={}, t_mem_size={}, size={}",
2216 1277 connection_handle.npad_id, wave_set, unknown, t_mem_size, size);
2217 if (t_mem.IsNull()) {
2218 LOG_ERROR(Service_HID, "t_mem is a nullptr for handle=0x{:08X}", t_mem_handle);
2219 IPC::ResponseBuilder rb{ctx, 2};
2220 rb.Push(ResultUnknown);
2221 return;
2222 }
2223
2224 ASSERT_MSG(t_mem->GetSize() == 0x3000, "t_mem has incorrect size");
2225
2226 LOG_WARNING(Service_HID,
2227 "(STUBBED) called, connection_handle={}, wave_set={}, unknown={}, "
2228 "t_mem_handle=0x{:08X}, t_mem_size={}, size={}",
2229 connection_handle.npad_id, wave_set, unknown, t_mem_handle, t_mem_size, size);
2230 1278
2231 GetResourceManager()->GetPalma()->WritePalmaWaveEntry(connection_handle, wave_set, 1279 GetResourceManager()->GetPalma()->WritePalmaWaveEntry(connection_handle, wave_set,
2232 t_mem->GetSourceAddress(), t_mem_size); 1280 t_mem->GetSourceAddress(), t_mem_size);
2233 1281 R_SUCCEED();
2234 IPC::ResponseBuilder rb{ctx, 2};
2235 rb.Push(ResultSuccess);
2236} 1282}
2237 1283
2238void IHidServer::SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { 1284Result IHidServer::SetPalmaDataBaseIdentificationVersion(
2239 IPC::RequestParser rp{ctx}; 1285 s32 database_id_version, Palma::PalmaConnectionHandle connection_handle) {
2240 struct Parameters {
2241 s32 database_id_version;
2242 INSERT_PADDING_WORDS_NOINIT(1);
2243 Palma::PalmaConnectionHandle connection_handle;
2244 };
2245 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
2246
2247 const auto parameters{rp.PopRaw<Parameters>()};
2248
2249 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, database_id_version={}", 1286 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}, database_id_version={}",
2250 parameters.connection_handle.npad_id, parameters.database_id_version); 1287 connection_handle.npad_id, database_id_version);
2251
2252 GetResourceManager()->GetPalma()->SetPalmaDataBaseIdentificationVersion(
2253 parameters.connection_handle, parameters.database_id_version);
2254 1288
2255 IPC::ResponseBuilder rb{ctx, 2}; 1289 GetResourceManager()->GetPalma()->SetPalmaDataBaseIdentificationVersion(connection_handle,
2256 rb.Push(ResultSuccess); 1290 database_id_version);
1291 R_SUCCEED();
2257} 1292}
2258 1293
2259void IHidServer::GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx) { 1294Result IHidServer::GetPalmaDataBaseIdentificationVersion(
2260 IPC::RequestParser rp{ctx}; 1295 Palma::PalmaConnectionHandle connection_handle) {
2261 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2262
2263 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1296 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2264 1297
2265 GetResourceManager()->GetPalma()->GetPalmaDataBaseIdentificationVersion(connection_handle); 1298 R_RETURN(
2266 1299 GetResourceManager()->GetPalma()->GetPalmaDataBaseIdentificationVersion(connection_handle));
2267 IPC::ResponseBuilder rb{ctx, 2};
2268 rb.Push(ResultSuccess);
2269} 1300}
2270 1301
2271void IHidServer::SuspendPalmaFeature(HLERequestContext& ctx) { 1302Result IHidServer::SuspendPalmaFeature(Palma::PalmaFeature feature,
2272 LOG_WARNING(Service_HID, "(STUBBED) called"); 1303 Palma::PalmaConnectionHandle connection_handle) {
2273 1304 LOG_WARNING(Service_HID, "(STUBBED) called, feature={}, connection_handle={}", feature,
2274 IPC::ResponseBuilder rb{ctx, 2}; 1305 connection_handle.npad_id);
2275 rb.Push(ResultSuccess); 1306 R_SUCCEED();
2276} 1307}
2277 1308
2278void IHidServer::GetPalmaOperationResult(HLERequestContext& ctx) { 1309Result IHidServer::GetPalmaOperationResult(Palma::PalmaConnectionHandle connection_handle) {
2279 IPC::RequestParser rp{ctx};
2280 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2281
2282 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1310 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2283 1311
2284 const auto result = 1312 R_RETURN(GetResourceManager()->GetPalma()->GetPalmaOperationResult(connection_handle));
2285 GetResourceManager()->GetPalma()->GetPalmaOperationResult(connection_handle);
2286
2287 IPC::ResponseBuilder rb{ctx, 2};
2288 rb.Push(result);
2289} 1313}
2290 1314
2291void IHidServer::ReadPalmaPlayLog(HLERequestContext& ctx) { 1315Result IHidServer::ReadPalmaPlayLog(u16 unknown, Palma::PalmaConnectionHandle connection_handle) {
2292 LOG_WARNING(Service_HID, "(STUBBED) called"); 1316 LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, connection_handle={}", unknown,
2293 1317 connection_handle.npad_id);
2294 IPC::ResponseBuilder rb{ctx, 2}; 1318 R_SUCCEED();
2295 rb.Push(ResultSuccess);
2296} 1319}
2297 1320
2298void IHidServer::ResetPalmaPlayLog(HLERequestContext& ctx) { 1321Result IHidServer::ResetPalmaPlayLog(u16 unknown, Palma::PalmaConnectionHandle connection_handle) {
2299 LOG_WARNING(Service_HID, "(STUBBED) called"); 1322 LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, connection_handle={}", unknown,
2300 1323 connection_handle.npad_id);
2301 IPC::ResponseBuilder rb{ctx, 2}; 1324 R_SUCCEED();
2302 rb.Push(ResultSuccess);
2303} 1325}
2304 1326
2305void IHidServer::SetIsPalmaAllConnectable(HLERequestContext& ctx) { 1327Result IHidServer::SetIsPalmaAllConnectable(bool is_palma_all_connectable,
2306 IPC::RequestParser rp{ctx}; 1328 ClientAppletResourceUserId aruid) {
2307 struct Parameters {
2308 bool is_palma_all_connectable;
2309 INSERT_PADDING_BYTES_NOINIT(7);
2310 u64 applet_resource_user_id;
2311 };
2312 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
2313
2314 const auto parameters{rp.PopRaw<Parameters>()};
2315
2316 LOG_WARNING(Service_HID, 1329 LOG_WARNING(Service_HID,
2317 "(STUBBED) called, is_palma_all_connectable={},applet_resource_user_id={}", 1330 "(STUBBED) called, is_palma_all_connectable={}, applet_resource_user_id={}",
2318 parameters.is_palma_all_connectable, parameters.applet_resource_user_id); 1331 is_palma_all_connectable, aruid.pid);
2319
2320 GetResourceManager()->GetPalma()->SetIsPalmaAllConnectable(parameters.is_palma_all_connectable);
2321 1332
2322 IPC::ResponseBuilder rb{ctx, 2}; 1333 GetResourceManager()->GetPalma()->SetIsPalmaAllConnectable(is_palma_all_connectable);
2323 rb.Push(ResultSuccess); 1334 R_SUCCEED();
2324} 1335}
2325 1336
2326void IHidServer::SetIsPalmaPairedConnectable(HLERequestContext& ctx) { 1337Result IHidServer::SetIsPalmaPairedConnectable(bool is_palma_paired_connectable,
2327 LOG_WARNING(Service_HID, "(STUBBED) called"); 1338 ClientAppletResourceUserId aruid) {
2328 1339 LOG_WARNING(Service_HID,
2329 IPC::ResponseBuilder rb{ctx, 2}; 1340 "(STUBBED) called, is_palma_paired_connectable={}, applet_resource_user_id={}",
2330 rb.Push(ResultSuccess); 1341 is_palma_paired_connectable, aruid.pid);
1342 R_SUCCEED();
2331} 1343}
2332 1344
2333void IHidServer::PairPalma(HLERequestContext& ctx) { 1345Result IHidServer::PairPalma(Palma::PalmaConnectionHandle connection_handle) {
2334 IPC::RequestParser rp{ctx};
2335 const auto connection_handle{rp.PopRaw<Palma::PalmaConnectionHandle>()};
2336
2337 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id); 1346 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2338 1347
2339 GetResourceManager()->GetPalma()->PairPalma(connection_handle); 1348 GetResourceManager()->GetPalma()->PairPalma(connection_handle);
2340 1349 R_SUCCEED();
2341 IPC::ResponseBuilder rb{ctx, 2};
2342 rb.Push(ResultSuccess);
2343} 1350}
2344 1351
2345void IHidServer::SetPalmaBoostMode(HLERequestContext& ctx) { 1352Result IHidServer::SetPalmaBoostMode(bool is_enabled) {
2346 IPC::RequestParser rp{ctx}; 1353 LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
2347 const auto palma_boost_mode{rp.Pop<bool>()};
2348
2349 LOG_WARNING(Service_HID, "(STUBBED) called, palma_boost_mode={}", palma_boost_mode);
2350
2351 GetResourceManager()->GetPalma()->SetPalmaBoostMode(palma_boost_mode);
2352 1354
2353 IPC::ResponseBuilder rb{ctx, 2}; 1355 GetResourceManager()->GetPalma()->SetPalmaBoostMode(is_enabled);
2354 rb.Push(ResultSuccess); 1356 R_SUCCEED();
2355} 1357}
2356 1358
2357void IHidServer::CancelWritePalmaWaveEntry(HLERequestContext& ctx) { 1359Result IHidServer::CancelWritePalmaWaveEntry(Palma::PalmaConnectionHandle connection_handle) {
2358 LOG_WARNING(Service_HID, "(STUBBED) called"); 1360 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2359 1361 R_SUCCEED();
2360 IPC::ResponseBuilder rb{ctx, 2};
2361 rb.Push(ResultSuccess);
2362} 1362}
2363 1363
2364void IHidServer::EnablePalmaBoostMode(HLERequestContext& ctx) { 1364Result IHidServer::EnablePalmaBoostMode(bool is_enabled, ClientAppletResourceUserId aruid) {
2365 LOG_WARNING(Service_HID, "(STUBBED) called"); 1365 LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}, applet_resource_user_id={}",
2366 1366 is_enabled, aruid.pid);
2367 IPC::ResponseBuilder rb{ctx, 2}; 1367 R_SUCCEED();
2368 rb.Push(ResultSuccess);
2369} 1368}
2370 1369
2371void IHidServer::GetPalmaBluetoothAddress(HLERequestContext& ctx) { 1370Result IHidServer::GetPalmaBluetoothAddress(Out<Palma::Address> out_bt_address,
2372 LOG_WARNING(Service_HID, "(STUBBED) called"); 1371 Palma::PalmaConnectionHandle connection_handle) {
2373 1372 LOG_WARNING(Service_HID, "(STUBBED) called, connection_handle={}", connection_handle.npad_id);
2374 IPC::ResponseBuilder rb{ctx, 2}; 1373 R_SUCCEED();
2375 rb.Push(ResultSuccess);
2376} 1374}
2377 1375
2378void IHidServer::SetDisallowedPalmaConnection(HLERequestContext& ctx) { 1376Result IHidServer::SetDisallowedPalmaConnection(
2379 LOG_WARNING(Service_HID, "(STUBBED) called"); 1377 ClientAppletResourceUserId aruid,
2380 1378 InArray<Palma::Address, BufferAttr_HipcPointer> disallowed_address) {
2381 IPC::ResponseBuilder rb{ctx, 2}; 1379 LOG_DEBUG(Service_HID, "(STUBBED) called, applet_resource_user_id={}", aruid.pid);
2382 rb.Push(ResultSuccess); 1380 R_SUCCEED();
2383} 1381}
2384 1382
2385void IHidServer::SetNpadCommunicationMode(HLERequestContext& ctx) { 1383Result IHidServer::SetNpadCommunicationMode(ClientAppletResourceUserId aruid,
2386 IPC::RequestParser rp{ctx}; 1384 NpadCommunicationMode communication_mode) {
2387 const auto applet_resource_user_id{rp.Pop<u64>()}; 1385 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, communication_mode={}", aruid.pid,
2388 const auto communication_mode{rp.PopEnum<NpadCommunicationMode>()}; 1386 communication_mode);
2389
2390 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, communication_mode={}",
2391 applet_resource_user_id, communication_mode);
2392 1387
2393 // This function has been stubbed since 2.0.0+ 1388 // This function has been stubbed since 2.0.0+
2394 1389 R_SUCCEED();
2395 IPC::ResponseBuilder rb{ctx, 2};
2396 rb.Push(ResultSuccess);
2397} 1390}
2398 1391
2399void IHidServer::GetNpadCommunicationMode(HLERequestContext& ctx) { 1392Result IHidServer::GetNpadCommunicationMode(Out<NpadCommunicationMode> out_communication_mode,
2400 IPC::RequestParser rp{ctx}; 1393 ClientAppletResourceUserId aruid) {
2401 const auto applet_resource_user_id{rp.Pop<u64>()}; 1394 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", aruid.pid);
2402
2403 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
2404 1395
2405 // This function has been stubbed since 2.0.0+ 1396 // This function has been stubbed since 2.0.0+
2406 1397 *out_communication_mode = NpadCommunicationMode::Default;
2407 IPC::ResponseBuilder rb{ctx, 4}; 1398 R_SUCCEED();
2408 rb.Push(ResultSuccess);
2409 rb.PushEnum(NpadCommunicationMode::Default);
2410} 1399}
2411 1400
2412void IHidServer::SetTouchScreenConfiguration(HLERequestContext& ctx) { 1401Result IHidServer::SetTouchScreenConfiguration(
2413 IPC::RequestParser rp{ctx}; 1402 Core::HID::TouchScreenConfigurationForNx touchscreen_config, ClientAppletResourceUserId aruid) {
2414 auto touchscreen_config{rp.PopRaw<Core::HID::TouchScreenConfigurationForNx>()};
2415 const auto applet_resource_user_id{rp.Pop<u64>()};
2416
2417 LOG_INFO(Service_HID, "called, touchscreen_config={}, applet_resource_user_id={}", 1403 LOG_INFO(Service_HID, "called, touchscreen_config={}, applet_resource_user_id={}",
2418 touchscreen_config.mode, applet_resource_user_id); 1404 touchscreen_config.mode, aruid.pid);
2419 1405
2420 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 && 1406 if (touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Heat2 &&
2421 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) { 1407 touchscreen_config.mode != Core::HID::TouchScreenModeForNx::Finger) {
2422 touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting; 1408 touchscreen_config.mode = Core::HID::TouchScreenModeForNx::UseSystemSetting;
2423 } 1409 }
2424 1410
2425 const Result result = GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration( 1411 R_RETURN(GetResourceManager()->GetTouchScreen()->SetTouchScreenConfiguration(touchscreen_config,
2426 touchscreen_config, applet_resource_user_id); 1412 aruid.pid));
2427
2428 IPC::ResponseBuilder rb{ctx, 2};
2429 rb.Push(result);
2430} 1413}
2431 1414
2432void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) { 1415Result IHidServer::IsFirmwareUpdateNeededForNotification(Out<bool> out_is_firmware_update_needed,
2433 IPC::RequestParser rp{ctx}; 1416 s32 unknown,
2434 struct Parameters { 1417 ClientAppletResourceUserId aruid) {
2435 s32 unknown; 1418 LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", unknown,
2436 INSERT_PADDING_WORDS_NOINIT(1); 1419 aruid.pid);
2437 u64 applet_resource_user_id;
2438 };
2439 static_assert(sizeof(Parameters) == 0x10, "Parameters has incorrect size.");
2440
2441 const auto parameters{rp.PopRaw<Parameters>()};
2442 1420
2443 LOG_WARNING(Service_HID, "(STUBBED) called, unknown={}, applet_resource_user_id={}", 1421 *out_is_firmware_update_needed = false;
2444 parameters.unknown, parameters.applet_resource_user_id); 1422 R_SUCCEED();
2445
2446 IPC::ResponseBuilder rb{ctx, 3};
2447 rb.Push(ResultSuccess);
2448 rb.Push(false);
2449} 1423}
2450 1424
2451void IHidServer::SetTouchScreenResolution(HLERequestContext& ctx) { 1425Result IHidServer::SetTouchScreenResolution(u32 width, u32 height,
2452 IPC::RequestParser rp{ctx}; 1426 ClientAppletResourceUserId aruid) {
2453 const auto width{rp.Pop<u32>()};
2454 const auto height{rp.Pop<u32>()};
2455 const auto applet_resource_user_id{rp.Pop<u64>()};
2456
2457 LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height, 1427 LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height,
2458 applet_resource_user_id); 1428 aruid.pid);
2459
2460 GetResourceManager()->GetTouchScreen()->SetTouchScreenResolution(width, height,
2461 applet_resource_user_id);
2462 1429
2463 IPC::ResponseBuilder rb{ctx, 2}; 1430 GetResourceManager()->GetTouchScreen()->SetTouchScreenResolution(width, height, aruid.pid);
2464 rb.Push(ResultSuccess); 1431 R_SUCCEED();
2465} 1432}
2466 1433
2467std::shared_ptr<ResourceManager> IHidServer::GetResourceManager() { 1434std::shared_ptr<ResourceManager> IHidServer::GetResourceManager() {
diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h
index faf775689..cfa31c2de 100644
--- a/src/core/hle/service/hid/hid_server.h
+++ b/src/core/hle/service/hid/hid_server.h
@@ -6,12 +6,20 @@
6#include "core/hle/service/cmif_types.h" 6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8#include "hid_core/hid_types.h" 8#include "hid_core/hid_types.h"
9#include "hid_core/resources/npad/npad_types.h"
10#include "hid_core/resources/palma/palma.h"
9 11
10namespace Core { 12namespace Core {
11class System; 13class System;
12} 14}
13 15
16namespace Kernel {
17class KReadableEvent;
18}
19
14namespace Service::HID { 20namespace Service::HID {
21class IActiveVibrationDeviceList;
22class IAppletResource;
15class ResourceManager; 23class ResourceManager;
16class HidFirmwareSettings; 24class HidFirmwareSettings;
17 25
@@ -24,128 +32,232 @@ public:
24 std::shared_ptr<ResourceManager> GetResourceManager(); 32 std::shared_ptr<ResourceManager> GetResourceManager();
25 33
26private: 34private:
27 void CreateAppletResource(HLERequestContext& ctx); 35 Result CreateAppletResource(OutInterface<IAppletResource> out_applet_resource,
28 void ActivateDebugPad(HLERequestContext& ctx); 36 ClientAppletResourceUserId aruid);
29 void ActivateTouchScreen(HLERequestContext& ctx); 37 Result ActivateDebugPad(ClientAppletResourceUserId aruid);
30 void ActivateMouse(HLERequestContext& ctx); 38 Result ActivateTouchScreen(ClientAppletResourceUserId aruid);
31 void ActivateKeyboard(HLERequestContext& ctx); 39 Result ActivateMouse(ClientAppletResourceUserId aruid);
32 void SendKeyboardLockKeyEvent(HLERequestContext& ctx); 40 Result ActivateKeyboard(ClientAppletResourceUserId aruid);
33 void AcquireXpadIdEventHandle(HLERequestContext& ctx); 41 Result SendKeyboardLockKeyEvent(u32 flags);
34 void ReleaseXpadIdEventHandle(HLERequestContext& ctx); 42 Result AcquireXpadIdEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event,
35 void ActivateXpad(HLERequestContext& ctx); 43 ClientAppletResourceUserId aruid);
36 void GetXpadIds(HLERequestContext& ctx); 44 Result ReleaseXpadIdEventHandle(ClientAppletResourceUserId aruid);
37 void ActivateJoyXpad(HLERequestContext& ctx); 45 Result ActivateXpad(u32 basic_xpad_id, ClientAppletResourceUserId aruid);
38 void GetJoyXpadLifoHandle(HLERequestContext& ctx); 46 Result GetXpadIds(Out<u64> out_count, OutArray<u32, BufferAttr_HipcPointer> out_basic_pad_ids);
39 void GetJoyXpadIds(HLERequestContext& ctx); 47 Result ActivateJoyXpad(u32 joy_xpad_id);
40 void ActivateSixAxisSensor(HLERequestContext& ctx); 48 Result GetJoyXpadLifoHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle,
41 void DeactivateSixAxisSensor(HLERequestContext& ctx); 49 u32 joy_xpad_id);
42 void GetSixAxisSensorLifoHandle(HLERequestContext& ctx); 50 Result GetJoyXpadIds(Out<s64> out_basic_xpad_id_count);
43 void ActivateJoySixAxisSensor(HLERequestContext& ctx); 51 Result ActivateSixAxisSensor(u32 joy_xpad_id);
44 void DeactivateJoySixAxisSensor(HLERequestContext& ctx); 52 Result DeactivateSixAxisSensor(u32 joy_xpad_id);
45 void GetJoySixAxisSensorLifoHandle(HLERequestContext& ctx); 53 Result GetSixAxisSensorLifoHandle(OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle,
46 void StartSixAxisSensor(HLERequestContext& ctx); 54 u32 joy_xpad_id);
47 void StopSixAxisSensor(HLERequestContext& ctx); 55 Result ActivateJoySixAxisSensor(u32 joy_xpad_id);
48 void IsSixAxisSensorFusionEnabled(HLERequestContext& ctx); 56 Result DeactivateJoySixAxisSensor(u32 joy_xpad_id);
49 void EnableSixAxisSensorFusion(HLERequestContext& ctx); 57 Result GetJoySixAxisSensorLifoHandle(
50 void SetSixAxisSensorFusionParameters(HLERequestContext& ctx); 58 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_handle, u32 joy_xpad_id);
51 void GetSixAxisSensorFusionParameters(HLERequestContext& ctx); 59 Result StartSixAxisSensor(Core::HID::SixAxisSensorHandle sixaxis_handle,
52 void ResetSixAxisSensorFusionParameters(HLERequestContext& ctx); 60 ClientAppletResourceUserId aruid);
53 void SetGyroscopeZeroDriftMode(HLERequestContext& ctx); 61 Result StopSixAxisSensor(Core::HID::SixAxisSensorHandle sixaxis_handle,
54 void GetGyroscopeZeroDriftMode(HLERequestContext& ctx); 62 ClientAppletResourceUserId aruid);
55 void ResetGyroscopeZeroDriftMode(HLERequestContext& ctx); 63 Result IsSixAxisSensorFusionEnabled(Out<bool> out_is_enabled,
56 void IsSixAxisSensorAtRest(HLERequestContext& ctx); 64 Core::HID::SixAxisSensorHandle sixaxis_handle,
57 void IsFirmwareUpdateAvailableForSixAxisSensor(HLERequestContext& ctx); 65 ClientAppletResourceUserId aruid);
58 void EnableSixAxisSensorUnalteredPassthrough(HLERequestContext& ctx); 66 Result EnableSixAxisSensorFusion(bool is_enabled, Core::HID::SixAxisSensorHandle sixaxis_handle,
59 void IsSixAxisSensorUnalteredPassthroughEnabled(HLERequestContext& ctx); 67 ClientAppletResourceUserId aruid);
60 void LoadSixAxisSensorCalibrationParameter(HLERequestContext& ctx); 68 Result SetSixAxisSensorFusionParameters(Core::HID::SixAxisSensorHandle sixaxis_handle,
61 void GetSixAxisSensorIcInformation(HLERequestContext& ctx); 69 Core::HID::SixAxisSensorFusionParameters sixaxis_fusion,
62 void ResetIsSixAxisSensorDeviceNewlyAssigned(HLERequestContext& ctx); 70 ClientAppletResourceUserId aruid);
63 void ActivateGesture(HLERequestContext& ctx); 71 Result GetSixAxisSensorFusionParameters(
64 void SetSupportedNpadStyleSet(HLERequestContext& ctx); 72 Out<Core::HID::SixAxisSensorFusionParameters> out_fusion_parameters,
65 void GetSupportedNpadStyleSet(HLERequestContext& ctx); 73 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid);
66 void SetSupportedNpadIdType(HLERequestContext& ctx); 74 Result ResetSixAxisSensorFusionParameters(Core::HID::SixAxisSensorHandle sixaxis_handle,
67 void ActivateNpad(HLERequestContext& ctx); 75 ClientAppletResourceUserId aruid);
68 void DeactivateNpad(HLERequestContext& ctx); 76 Result SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
69 void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); 77 Core::HID::GyroscopeZeroDriftMode drift_mode,
70 void DisconnectNpad(HLERequestContext& ctx); 78 ClientAppletResourceUserId aruid);
79 Result GetGyroscopeZeroDriftMode(Out<Core::HID::GyroscopeZeroDriftMode> out_drift_mode,
80 Core::HID::SixAxisSensorHandle sixaxis_handle,
81 ClientAppletResourceUserId aruid);
82 Result ResetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
83 ClientAppletResourceUserId aruid);
84 Result IsSixAxisSensorAtRest(Out<bool> out_is_at_rest,
85 Core::HID::SixAxisSensorHandle sixaxis_handle,
86 ClientAppletResourceUserId aruid);
87 Result IsFirmwareUpdateAvailableForSixAxisSensor(Out<bool> out_is_firmware_available,
88 Core::HID::SixAxisSensorHandle sixaxis_handle,
89 ClientAppletResourceUserId aruid);
90 Result EnableSixAxisSensorUnalteredPassthrough(bool is_enabled,
91 Core::HID::SixAxisSensorHandle sixaxis_handle,
92 ClientAppletResourceUserId aruid);
93 Result IsSixAxisSensorUnalteredPassthroughEnabled(Out<bool> out_is_enabled,
94 Core::HID::SixAxisSensorHandle sixaxis_handle,
95 ClientAppletResourceUserId aruid);
96 Result LoadSixAxisSensorCalibrationParameter(
97 OutLargeData<Core::HID::SixAxisSensorCalibrationParameter, BufferAttr_HipcMapAlias>
98 out_calibration,
99 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid);
100 Result GetSixAxisSensorIcInformation(
101 OutLargeData<Core::HID::SixAxisSensorIcInformation, BufferAttr_HipcPointer>
102 out_ic_information,
103 Core::HID::SixAxisSensorHandle sixaxis_handle, ClientAppletResourceUserId aruid);
104 Result ResetIsSixAxisSensorDeviceNewlyAssigned(Core::HID::SixAxisSensorHandle sixaxis_handle,
105 ClientAppletResourceUserId aruid);
106 Result ActivateGesture(u32 basic_gesture_id, ClientAppletResourceUserId aruid);
107 Result SetSupportedNpadStyleSet(Core::HID::NpadStyleSet supported_style_set,
108 ClientAppletResourceUserId aruid);
109 Result GetSupportedNpadStyleSet(Out<Core::HID::NpadStyleSet> out_supported_style_set,
110 ClientAppletResourceUserId aruid);
111 Result SetSupportedNpadIdType(
112 ClientAppletResourceUserId aruid,
113 InArray<Core::HID::NpadIdType, BufferAttr_HipcPointer> supported_npad_list);
114 Result ActivateNpad(ClientAppletResourceUserId aruid);
115 Result DeactivateNpad(ClientAppletResourceUserId aruid);
116 Result AcquireNpadStyleSetUpdateEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event,
117 Core::HID::NpadIdType npad_id,
118 ClientAppletResourceUserId aruid, u64 unknown);
119 Result DisconnectNpad(Core::HID::NpadIdType npad_id, ClientAppletResourceUserId aruid);
71 Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, 120 Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern,
72 Core::HID::NpadIdType npad_id); 121 Core::HID::NpadIdType npad_id);
73 void ActivateNpadWithRevision(HLERequestContext& ctx); 122 Result ActivateNpadWithRevision(NpadRevision revision, ClientAppletResourceUserId aruid);
74 void SetNpadJoyHoldType(HLERequestContext& ctx); 123 Result SetNpadJoyHoldType(ClientAppletResourceUserId aruid, NpadJoyHoldType hold_type);
75 void GetNpadJoyHoldType(HLERequestContext& ctx); 124 Result GetNpadJoyHoldType(Out<NpadJoyHoldType> out_hold_type, ClientAppletResourceUserId aruid);
76 void SetNpadJoyAssignmentModeSingleByDefault(HLERequestContext& ctx); 125 Result SetNpadJoyAssignmentModeSingleByDefault(Core::HID::NpadIdType npad_id,
77 void SetNpadJoyAssignmentModeSingle(HLERequestContext& ctx); 126 ClientAppletResourceUserId aruid);
78 void SetNpadJoyAssignmentModeDual(HLERequestContext& ctx); 127 Result SetNpadJoyAssignmentModeSingle(Core::HID::NpadIdType npad_id,
79 void MergeSingleJoyAsDualJoy(HLERequestContext& ctx); 128 ClientAppletResourceUserId aruid,
80 void StartLrAssignmentMode(HLERequestContext& ctx); 129 NpadJoyDeviceType npad_joy_device_type);
81 void StopLrAssignmentMode(HLERequestContext& ctx); 130 Result SetNpadJoyAssignmentModeDual(Core::HID::NpadIdType npad_id,
82 void SetNpadHandheldActivationMode(HLERequestContext& ctx); 131 ClientAppletResourceUserId aruid);
83 void GetNpadHandheldActivationMode(HLERequestContext& ctx); 132 Result MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2,
84 void SwapNpadAssignment(HLERequestContext& ctx); 133 ClientAppletResourceUserId aruid);
85 void IsUnintendedHomeButtonInputProtectionEnabled(HLERequestContext& ctx); 134 Result StartLrAssignmentMode(ClientAppletResourceUserId aruid);
86 void EnableUnintendedHomeButtonInputProtection(HLERequestContext& ctx); 135 Result StopLrAssignmentMode(ClientAppletResourceUserId aruid);
87 void SetNpadJoyAssignmentModeSingleWithDestination(HLERequestContext& ctx); 136 Result SetNpadHandheldActivationMode(ClientAppletResourceUserId aruid,
88 void SetNpadAnalogStickUseCenterClamp(HLERequestContext& ctx); 137 NpadHandheldActivationMode activation_mode);
89 void SetNpadCaptureButtonAssignment(HLERequestContext& ctx); 138 Result GetNpadHandheldActivationMode(Out<NpadHandheldActivationMode> out_activation_mode,
90 void ClearNpadCaptureButtonAssignment(HLERequestContext& ctx); 139 ClientAppletResourceUserId aruid);
91 void GetVibrationDeviceInfo(HLERequestContext& ctx); 140 Result SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2,
92 void SendVibrationValue(HLERequestContext& ctx); 141 ClientAppletResourceUserId aruid);
93 void GetActualVibrationValue(HLERequestContext& ctx); 142 Result IsUnintendedHomeButtonInputProtectionEnabled(Out<bool> out_is_enabled,
94 void CreateActiveVibrationDeviceList(HLERequestContext& ctx); 143 Core::HID::NpadIdType npad_id,
95 void PermitVibration(HLERequestContext& ctx); 144 ClientAppletResourceUserId aruid);
96 void IsVibrationPermitted(HLERequestContext& ctx); 145 Result EnableUnintendedHomeButtonInputProtection(bool is_enabled, Core::HID::NpadIdType npad_id,
97 void SendVibrationValues(HLERequestContext& ctx); 146 ClientAppletResourceUserId aruid);
98 void SendVibrationGcErmCommand(HLERequestContext& ctx); 147 Result SetNpadJoyAssignmentModeSingleWithDestination(Out<bool> out_is_reassigned,
99 void GetActualVibrationGcErmCommand(HLERequestContext& ctx); 148 Out<Core::HID::NpadIdType> out_new_npad_id,
100 void BeginPermitVibrationSession(HLERequestContext& ctx); 149 Core::HID::NpadIdType npad_id,
101 void EndPermitVibrationSession(HLERequestContext& ctx); 150 ClientAppletResourceUserId aruid,
102 void IsVibrationDeviceMounted(HLERequestContext& ctx); 151 NpadJoyDeviceType npad_joy_device_type);
103 void SendVibrationValueInBool(HLERequestContext& ctx); 152 Result SetNpadAnalogStickUseCenterClamp(bool use_center_clamp,
104 void ActivateConsoleSixAxisSensor(HLERequestContext& ctx); 153 ClientAppletResourceUserId aruid);
105 void StartConsoleSixAxisSensor(HLERequestContext& ctx); 154 Result SetNpadCaptureButtonAssignment(Core::HID::NpadStyleSet npad_styleset,
106 void StopConsoleSixAxisSensor(HLERequestContext& ctx); 155 ClientAppletResourceUserId aruid,
107 void ActivateSevenSixAxisSensor(HLERequestContext& ctx); 156 Core::HID::NpadButton button);
108 void StartSevenSixAxisSensor(HLERequestContext& ctx); 157 Result ClearNpadCaptureButtonAssignment(ClientAppletResourceUserId aruid);
109 void StopSevenSixAxisSensor(HLERequestContext& ctx); 158 Result GetVibrationDeviceInfo(Out<Core::HID::VibrationDeviceInfo> out_vibration_device_info,
110 void InitializeSevenSixAxisSensor(HLERequestContext& ctx); 159 Core::HID::VibrationDeviceHandle vibration_device_handle);
111 void FinalizeSevenSixAxisSensor(HLERequestContext& ctx); 160 Result SendVibrationValue(Core::HID::VibrationDeviceHandle vibration_device_handle,
112 void ResetSevenSixAxisSensorTimestamp(HLERequestContext& ctx); 161 Core::HID::VibrationValue vibration_value,
113 void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx); 162 ClientAppletResourceUserId aruid);
114 void GetPalmaConnectionHandle(HLERequestContext& ctx); 163 Result GetActualVibrationValue(Out<Core::HID::VibrationValue> out_vibration_value,
115 void InitializePalma(HLERequestContext& ctx); 164 Core::HID::VibrationDeviceHandle vibration_device_handle,
116 void AcquirePalmaOperationCompleteEvent(HLERequestContext& ctx); 165 ClientAppletResourceUserId aruid);
117 void GetPalmaOperationInfo(HLERequestContext& ctx); 166 Result CreateActiveVibrationDeviceList(OutInterface<IActiveVibrationDeviceList> out_interface);
118 void PlayPalmaActivity(HLERequestContext& ctx); 167 Result PermitVibration(bool can_vibrate);
119 void SetPalmaFrModeType(HLERequestContext& ctx); 168 Result IsVibrationPermitted(Out<bool> out_is_permitted);
120 void ReadPalmaStep(HLERequestContext& ctx); 169 Result SendVibrationValues(
121 void EnablePalmaStep(HLERequestContext& ctx); 170 ClientAppletResourceUserId aruid,
122 void ResetPalmaStep(HLERequestContext& ctx); 171 InArray<Core::HID::VibrationDeviceHandle, BufferAttr_HipcPointer> vibration_handles,
123 void ReadPalmaApplicationSection(HLERequestContext& ctx); 172 InArray<Core::HID::VibrationValue, BufferAttr_HipcPointer> vibration_values);
124 void WritePalmaApplicationSection(HLERequestContext& ctx); 173 Result SendVibrationGcErmCommand(Core::HID::VibrationDeviceHandle vibration_device_handle,
125 void ReadPalmaUniqueCode(HLERequestContext& ctx); 174 ClientAppletResourceUserId aruid,
126 void SetPalmaUniqueCodeInvalid(HLERequestContext& ctx); 175 Core::HID::VibrationGcErmCommand gc_erm_command);
127 void WritePalmaActivityEntry(HLERequestContext& ctx); 176 Result GetActualVibrationGcErmCommand(Out<Core::HID::VibrationGcErmCommand> out_gc_erm_command,
128 void WritePalmaRgbLedPatternEntry(HLERequestContext& ctx); 177 Core::HID::VibrationDeviceHandle vibration_device_handle,
129 void WritePalmaWaveEntry(HLERequestContext& ctx); 178 ClientAppletResourceUserId aruid);
130 void SetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx); 179 Result BeginPermitVibrationSession(ClientAppletResourceUserId aruid);
131 void GetPalmaDataBaseIdentificationVersion(HLERequestContext& ctx); 180 Result EndPermitVibrationSession(ClientAppletResourceUserId aruid);
132 void SuspendPalmaFeature(HLERequestContext& ctx); 181 Result IsVibrationDeviceMounted(Out<bool> out_is_mounted,
133 void GetPalmaOperationResult(HLERequestContext& ctx); 182 Core::HID::VibrationDeviceHandle vibration_device_handle,
134 void ReadPalmaPlayLog(HLERequestContext& ctx); 183 ClientAppletResourceUserId aruid);
135 void ResetPalmaPlayLog(HLERequestContext& ctx); 184 Result SendVibrationValueInBool(bool is_vibrating,
136 void SetIsPalmaAllConnectable(HLERequestContext& ctx); 185 Core::HID::VibrationDeviceHandle vibration_device_handle,
137 void SetIsPalmaPairedConnectable(HLERequestContext& ctx); 186 ClientAppletResourceUserId aruid);
138 void PairPalma(HLERequestContext& ctx); 187 Result ActivateConsoleSixAxisSensor(ClientAppletResourceUserId aruid);
139 void SetPalmaBoostMode(HLERequestContext& ctx); 188 Result StartConsoleSixAxisSensor(Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle,
140 void CancelWritePalmaWaveEntry(HLERequestContext& ctx); 189 ClientAppletResourceUserId aruid);
141 void EnablePalmaBoostMode(HLERequestContext& ctx); 190 Result StopConsoleSixAxisSensor(Core::HID::ConsoleSixAxisSensorHandle console_sixaxis_handle,
142 void GetPalmaBluetoothAddress(HLERequestContext& ctx); 191 ClientAppletResourceUserId aruid);
143 void SetDisallowedPalmaConnection(HLERequestContext& ctx); 192 Result ActivateSevenSixAxisSensor(ClientAppletResourceUserId aruid);
144 void SetNpadCommunicationMode(HLERequestContext& ctx); 193 Result StartSevenSixAxisSensor(ClientAppletResourceUserId aruid);
145 void GetNpadCommunicationMode(HLERequestContext& ctx); 194 Result StopSevenSixAxisSensor(ClientAppletResourceUserId aruid);
146 void SetTouchScreenConfiguration(HLERequestContext& ctx); 195 Result InitializeSevenSixAxisSensor(ClientAppletResourceUserId aruid, u64 t_mem_1_size,
147 void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); 196 u64 t_mem_2_size,
148 void SetTouchScreenResolution(HLERequestContext& ctx); 197 InCopyHandle<Kernel::KTransferMemory> t_mem_1,
198 InCopyHandle<Kernel::KTransferMemory> t_mem_2);
199 Result FinalizeSevenSixAxisSensor(ClientAppletResourceUserId aruid);
200 Result ResetSevenSixAxisSensorTimestamp(ClientAppletResourceUserId aruid);
201 Result IsUsbFullKeyControllerEnabled(Out<bool> out_is_enabled,
202 ClientAppletResourceUserId aruid);
203 Result GetPalmaConnectionHandle(Out<Palma::PalmaConnectionHandle> out_handle,
204 Core::HID::NpadIdType npad_id,
205 ClientAppletResourceUserId aruid);
206 Result InitializePalma(Palma::PalmaConnectionHandle connection_handle);
207 Result AcquirePalmaOperationCompleteEvent(OutCopyHandle<Kernel::KReadableEvent> out_event,
208 Palma::PalmaConnectionHandle connection_handle);
209 Result GetPalmaOperationInfo(Out<Palma::PalmaOperationType> out_operation_type,
210 Palma::PalmaConnectionHandle connection_handle,
211 OutBuffer<BufferAttr_HipcMapAlias> out_data);
212 Result PlayPalmaActivity(Palma::PalmaConnectionHandle connection_handle, u64 palma_activity);
213 Result SetPalmaFrModeType(Palma::PalmaConnectionHandle connection_handle,
214 Palma::PalmaFrModeType fr_mode);
215 Result ReadPalmaStep(Palma::PalmaConnectionHandle connection_handle);
216 Result EnablePalmaStep(bool is_enabled, Palma::PalmaConnectionHandle connection_handle);
217 Result ResetPalmaStep(Palma::PalmaConnectionHandle connection_handle);
218 Result ReadPalmaApplicationSection(Palma::PalmaConnectionHandle connection_handle, u64 offset,
219 u64 size);
220 Result WritePalmaApplicationSection(
221 Palma::PalmaConnectionHandle connection_handle, u64 offset, u64 size,
222 InLargeData<Palma::PalmaApplicationSection, BufferAttr_HipcPointer> data);
223 Result ReadPalmaUniqueCode(Palma::PalmaConnectionHandle connection_handle);
224 Result SetPalmaUniqueCodeInvalid(Palma::PalmaConnectionHandle connection_handle);
225 Result WritePalmaActivityEntry(Palma::PalmaConnectionHandle connection_handle,
226 Palma::PalmaActivityEntry activity_entry);
227 Result WritePalmaRgbLedPatternEntry(Palma::PalmaConnectionHandle connection_handle, u64 unknown,
228 InBuffer<BufferAttr_HipcMapAlias> led_pattern);
229 Result WritePalmaWaveEntry(Palma::PalmaConnectionHandle connection_handle,
230 Palma::PalmaWaveSet wave_set, u64 unknown, u64 t_mem_size, u64 size,
231 InCopyHandle<Kernel::KTransferMemory> t_mem);
232 Result SetPalmaDataBaseIdentificationVersion(s32 database_id_version,
233 Palma::PalmaConnectionHandle connection_handle);
234 Result GetPalmaDataBaseIdentificationVersion(Palma::PalmaConnectionHandle connection_handle);
235 Result SuspendPalmaFeature(Palma::PalmaFeature feature,
236 Palma::PalmaConnectionHandle connection_handle);
237 Result GetPalmaOperationResult(Palma::PalmaConnectionHandle connection_handle);
238 Result ReadPalmaPlayLog(u16 unknown, Palma::PalmaConnectionHandle connection_handle);
239 Result ResetPalmaPlayLog(u16 unknown, Palma::PalmaConnectionHandle connection_handle);
240 Result SetIsPalmaAllConnectable(bool is_palma_all_connectable, ClientAppletResourceUserId arui);
241 Result SetIsPalmaPairedConnectable(bool is_palma_paired_connectable,
242 ClientAppletResourceUserId aruid);
243 Result PairPalma(Palma::PalmaConnectionHandle connection_handle);
244 Result SetPalmaBoostMode(bool is_enabled);
245 Result CancelWritePalmaWaveEntry(Palma::PalmaConnectionHandle connection_handle);
246 Result EnablePalmaBoostMode(bool is_enabled, ClientAppletResourceUserId aruid);
247 Result GetPalmaBluetoothAddress(Out<Palma::Address> out_bt_address,
248 Palma::PalmaConnectionHandle connection_handle);
249 Result SetDisallowedPalmaConnection(
250 ClientAppletResourceUserId aruid,
251 InArray<Palma::Address, BufferAttr_HipcPointer> disallowed_address);
252 Result SetNpadCommunicationMode(ClientAppletResourceUserId aruid,
253 NpadCommunicationMode communication_mode);
254 Result GetNpadCommunicationMode(Out<NpadCommunicationMode> out_communication_mode,
255 ClientAppletResourceUserId aruid);
256 Result SetTouchScreenConfiguration(Core::HID::TouchScreenConfigurationForNx touchscreen_config,
257 ClientAppletResourceUserId aruid);
258 Result IsFirmwareUpdateNeededForNotification(Out<bool> out_is_firmware_update_needed,
259 s32 unknown, ClientAppletResourceUserId aruid);
260 Result SetTouchScreenResolution(u32 width, u32 height, ClientAppletResourceUserId aruid);
149 261
150 std::shared_ptr<ResourceManager> resource_manager; 262 std::shared_ptr<ResourceManager> resource_manager;
151 std::shared_ptr<HidFirmwareSettings> firmware_settings; 263 std::shared_ptr<HidFirmwareSettings> firmware_settings;
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
567struct SixAxisSensorCalibrationParameter { 567struct SixAxisSensorCalibrationParameter {
568 std::array<u8, 0x744> unknown_data{}; 568 std::array<u8, 0x744> unknown_data;
569}; 569};
570static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744, 570static_assert(sizeof(SixAxisSensorCalibrationParameter) == 0x744,
571 "SixAxisSensorCalibrationParameter is an invalid size"); 571 "SixAxisSensorCalibrationParameter is an invalid size");
572static_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
574struct SixAxisSensorIcInformation { 576struct 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};
596static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8, 586static_assert(sizeof(SixAxisSensorIcInformation) == 0xC8,
597 "SixAxisSensorIcInformation is an invalid size"); 587 "SixAxisSensorIcInformation is an invalid size");
588static_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
600struct SixAxisSensorAttribute { 592struct 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
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);