diff options
| author | 2024-01-30 10:36:42 -0600 | |
|---|---|---|
| committer | 2024-01-30 10:57:03 -0600 | |
| commit | a0f7f2b309e4920e0e3f1217441a4628023f59b8 (patch) | |
| tree | 5f8c8b2b284369d1e5b9562ad7d7df20f3abc2d9 | |
| parent | Merge pull request #12843 from t895/system-driver-whoops (diff) | |
| download | yuzu-a0f7f2b309e4920e0e3f1217441a4628023f59b8.tar.gz yuzu-a0f7f2b309e4920e0e3f1217441a4628023f59b8.tar.xz yuzu-a0f7f2b309e4920e0e3f1217441a4628023f59b8.zip | |
service: hid: Implement GetPlayerLedPattern accurately
| -rw-r--r-- | src/core/hle/service/hid/hid_server.cpp | 45 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.h | 5 | ||||
| -rw-r--r-- | src/hid_core/hid_types.h | 5 | ||||
| -rw-r--r-- | src/hid_core/resources/npad/npad.cpp | 11 | ||||
| -rw-r--r-- | src/hid_core/resources/npad/npad.h | 2 |
5 files changed, 41 insertions, 27 deletions
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 09c47b5e3..938b93451 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "core/hle/kernel/k_shared_memory.h" | 8 | #include "core/hle/kernel/k_shared_memory.h" |
| 9 | #include "core/hle/kernel/k_transfer_memory.h" | 9 | #include "core/hle/kernel/k_transfer_memory.h" |
| 10 | #include "core/hle/kernel/kernel.h" | 10 | #include "core/hle/kernel/kernel.h" |
| 11 | #include "core/hle/service/cmif_serialization.h" | ||
| 11 | #include "core/hle/service/hid/hid_server.h" | 12 | #include "core/hle/service/hid/hid_server.h" |
| 12 | #include "core/hle/service/ipc_helpers.h" | 13 | #include "core/hle/service/ipc_helpers.h" |
| 13 | #include "core/memory.h" | 14 | #include "core/memory.h" |
| @@ -153,7 +154,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r | |||
| 153 | {104, &IHidServer::DeactivateNpad, "DeactivateNpad"}, | 154 | {104, &IHidServer::DeactivateNpad, "DeactivateNpad"}, |
| 154 | {106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, | 155 | {106, &IHidServer::AcquireNpadStyleSetUpdateEventHandle, "AcquireNpadStyleSetUpdateEventHandle"}, |
| 155 | {107, &IHidServer::DisconnectNpad, "DisconnectNpad"}, | 156 | {107, &IHidServer::DisconnectNpad, "DisconnectNpad"}, |
| 156 | {108, &IHidServer::GetPlayerLedPattern, "GetPlayerLedPattern"}, | 157 | {108, C<&IHidServer::GetPlayerLedPattern>, "GetPlayerLedPattern"}, |
| 157 | {109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, | 158 | {109, &IHidServer::ActivateNpadWithRevision, "ActivateNpadWithRevision"}, |
| 158 | {120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, | 159 | {120, &IHidServer::SetNpadJoyHoldType, "SetNpadJoyHoldType"}, |
| 159 | {121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, | 160 | {121, &IHidServer::GetNpadJoyHoldType, "GetNpadJoyHoldType"}, |
| @@ -1136,19 +1137,39 @@ void IHidServer::DisconnectNpad(HLERequestContext& ctx) { | |||
| 1136 | rb.Push(ResultSuccess); | 1137 | rb.Push(ResultSuccess); |
| 1137 | } | 1138 | } |
| 1138 | 1139 | ||
| 1139 | void IHidServer::GetPlayerLedPattern(HLERequestContext& ctx) { | 1140 | Result IHidServer::GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, |
| 1140 | IPC::RequestParser rp{ctx}; | 1141 | Core::HID::NpadIdType npad_id) { |
| 1141 | const auto npad_id{rp.PopEnum<Core::HID::NpadIdType>()}; | ||
| 1142 | |||
| 1143 | Core::HID::LedPattern pattern{0, 0, 0, 0}; | ||
| 1144 | auto controller = GetResourceManager()->GetNpad(); | ||
| 1145 | const auto result = controller->GetLedPattern(npad_id, pattern); | ||
| 1146 | |||
| 1147 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); | 1142 | LOG_DEBUG(Service_HID, "called, npad_id={}", npad_id); |
| 1148 | 1143 | ||
| 1149 | IPC::ResponseBuilder rb{ctx, 4}; | 1144 | switch (npad_id) { |
| 1150 | rb.Push(result); | 1145 | case Core::HID::NpadIdType::Player1: |
| 1151 | rb.Push(pattern.raw); | 1146 | *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 0}; |
| 1147 | R_SUCCEED(); | ||
| 1148 | case Core::HID::NpadIdType::Player2: | ||
| 1149 | *out_led_pattern = Core::HID::LedPattern{1, 1, 0, 0}; | ||
| 1150 | R_SUCCEED(); | ||
| 1151 | case Core::HID::NpadIdType::Player3: | ||
| 1152 | *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 0}; | ||
| 1153 | R_SUCCEED(); | ||
| 1154 | case Core::HID::NpadIdType::Player4: | ||
| 1155 | *out_led_pattern = Core::HID::LedPattern{1, 1, 1, 1}; | ||
| 1156 | R_SUCCEED(); | ||
| 1157 | case Core::HID::NpadIdType::Player5: | ||
| 1158 | *out_led_pattern = Core::HID::LedPattern{1, 0, 0, 1}; | ||
| 1159 | R_SUCCEED(); | ||
| 1160 | case Core::HID::NpadIdType::Player6: | ||
| 1161 | *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 0}; | ||
| 1162 | R_SUCCEED(); | ||
| 1163 | case Core::HID::NpadIdType::Player7: | ||
| 1164 | *out_led_pattern = Core::HID::LedPattern{1, 0, 1, 1}; | ||
| 1165 | R_SUCCEED(); | ||
| 1166 | case Core::HID::NpadIdType::Player8: | ||
| 1167 | *out_led_pattern = Core::HID::LedPattern{0, 1, 1, 0}; | ||
| 1168 | R_SUCCEED(); | ||
| 1169 | default: | ||
| 1170 | *out_led_pattern = Core::HID::LedPattern{0, 0, 0, 0}; | ||
| 1171 | R_SUCCEED(); | ||
| 1172 | } | ||
| 1152 | } | 1173 | } |
| 1153 | 1174 | ||
| 1154 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { | 1175 | void IHidServer::ActivateNpadWithRevision(HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index 3a2e0a230..faf775689 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/cmif_types.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | #include "hid_core/hid_types.h" | ||
| 7 | 9 | ||
| 8 | namespace Core { | 10 | namespace Core { |
| 9 | class System; | 11 | class System; |
| @@ -66,7 +68,8 @@ private: | |||
| 66 | void DeactivateNpad(HLERequestContext& ctx); | 68 | void DeactivateNpad(HLERequestContext& ctx); |
| 67 | void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); | 69 | void AcquireNpadStyleSetUpdateEventHandle(HLERequestContext& ctx); |
| 68 | void DisconnectNpad(HLERequestContext& ctx); | 70 | void DisconnectNpad(HLERequestContext& ctx); |
| 69 | void GetPlayerLedPattern(HLERequestContext& ctx); | 71 | Result GetPlayerLedPattern(Out<Core::HID::LedPattern> out_led_pattern, |
| 72 | Core::HID::NpadIdType npad_id); | ||
| 70 | void ActivateNpadWithRevision(HLERequestContext& ctx); | 73 | void ActivateNpadWithRevision(HLERequestContext& ctx); |
| 71 | void SetNpadJoyHoldType(HLERequestContext& ctx); | 74 | void SetNpadJoyHoldType(HLERequestContext& ctx); |
| 72 | void GetNpadJoyHoldType(HLERequestContext& ctx); | 75 | void GetNpadJoyHoldType(HLERequestContext& ctx); |
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h index b310ab72d..ffb5f1926 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h | |||
| @@ -422,7 +422,10 @@ struct NpadPowerInfo { | |||
| 422 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); | 422 | static_assert(sizeof(NpadPowerInfo) == 0xC, "NpadPowerInfo is an invalid size"); |
| 423 | 423 | ||
| 424 | struct LedPattern { | 424 | struct LedPattern { |
| 425 | explicit LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { | 425 | LedPattern() { |
| 426 | raw = 0; | ||
| 427 | } | ||
| 428 | LedPattern(u64 light1, u64 light2, u64 light3, u64 light4) { | ||
| 426 | position1.Assign(light1); | 429 | position1.Assign(light1); |
| 427 | position2.Assign(light2); | 430 | position2.Assign(light2); |
| 428 | position3.Assign(light3); | 431 | position3.Assign(light3); |
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index cde84b1bb..2823be348 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp | |||
| @@ -956,17 +956,6 @@ Result NPad::SwapNpadAssignment(u64 aruid, Core::HID::NpadIdType npad_id_1, | |||
| 956 | return ResultSuccess; | 956 | return ResultSuccess; |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | Result NPad::GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const { | ||
| 960 | if (!IsNpadIdValid(npad_id)) { | ||
| 961 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | ||
| 962 | return ResultInvalidNpadId; | ||
| 963 | } | ||
| 964 | const auto aruid = applet_resource_holder.applet_resource->GetActiveAruid(); | ||
| 965 | const auto& controller = GetControllerFromNpadIdType(aruid, npad_id).device; | ||
| 966 | pattern = controller->GetLedPattern(); | ||
| 967 | return ResultSuccess; | ||
| 968 | } | ||
| 969 | |||
| 970 | Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, | 959 | Result NPad::IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, |
| 971 | Core::HID::NpadIdType npad_id) const { | 960 | Core::HID::NpadIdType npad_id) const { |
| 972 | std::scoped_lock lock{mutex}; | 961 | std::scoped_lock lock{mutex}; |
diff --git a/src/hid_core/resources/npad/npad.h b/src/hid_core/resources/npad/npad.h index 502cb9b55..3b1a69e7f 100644 --- a/src/hid_core/resources/npad/npad.h +++ b/src/hid_core/resources/npad/npad.h | |||
| @@ -97,8 +97,6 @@ public: | |||
| 97 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( | 97 | Result ResetIsSixAxisSensorDeviceNewlyAssigned( |
| 98 | u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle); | 98 | u64 aruid, const Core::HID::SixAxisSensorHandle& sixaxis_handle); |
| 99 | 99 | ||
| 100 | Result GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const; | ||
| 101 | |||
| 102 | Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, | 100 | Result IsUnintendedHomeButtonInputProtectionEnabled(bool& out_is_enabled, u64 aruid, |
| 103 | Core::HID::NpadIdType npad_id) const; | 101 | Core::HID::NpadIdType npad_id) const; |
| 104 | Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id, | 102 | Result EnableUnintendedHomeButtonInputProtection(u64 aruid, Core::HID::NpadIdType npad_id, |