diff options
| author | 2024-02-21 20:52:51 -0500 | |
|---|---|---|
| committer | 2024-02-21 22:58:20 -0500 | |
| commit | 01d89acd139e50470c41e5cd04df4acd49b635c6 (patch) | |
| tree | 314e77aff102c9d4422964b07d72ead777a07cdd /src/core | |
| parent | olsc: rewrite IOlscServiceForSystemService (diff) | |
| download | yuzu-01d89acd139e50470c41e5cd04df4acd49b635c6.tar.gz yuzu-01d89acd139e50470c41e5cd04df4acd49b635c6.tar.xz yuzu-01d89acd139e50470c41e5cd04df4acd49b635c6.zip | |
pctl: move types and results
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/pctl/pctl_module.cpp | 82 | ||||
| -rw-r--r-- | src/core/hle/service/pctl/pctl_module.h | 13 | ||||
| -rw-r--r-- | src/core/hle/service/pctl/pctl_results.h | 15 | ||||
| -rw-r--r-- | src/core/hle/service/pctl/pctl_types.h | 43 |
5 files changed, 88 insertions, 67 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d48696654..9e913fb10 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -897,6 +897,8 @@ add_library(core STATIC | |||
| 897 | hle/service/pctl/pctl.h | 897 | hle/service/pctl/pctl.h |
| 898 | hle/service/pctl/pctl_module.cpp | 898 | hle/service/pctl/pctl_module.cpp |
| 899 | hle/service/pctl/pctl_module.h | 899 | hle/service/pctl/pctl_module.h |
| 900 | hle/service/pctl/pctl_results.h | ||
| 901 | hle/service/pctl/pctl_types.h | ||
| 900 | hle/service/pcv/pcv.cpp | 902 | hle/service/pcv/pcv.cpp |
| 901 | hle/service/pcv/pcv.h | 903 | hle/service/pcv/pcv.h |
| 902 | hle/service/pm/pm.cpp | 904 | hle/service/pm/pm.cpp |
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index 6a7fd72bc..dab37cdc4 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp | |||
| @@ -9,18 +9,28 @@ | |||
| 9 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 10 | #include "core/hle/service/pctl/pctl.h" | 10 | #include "core/hle/service/pctl/pctl.h" |
| 11 | #include "core/hle/service/pctl/pctl_module.h" | 11 | #include "core/hle/service/pctl/pctl_module.h" |
| 12 | #include "core/hle/service/pctl/pctl_results.h" | ||
| 13 | #include "core/hle/service/pctl/pctl_types.h" | ||
| 12 | #include "core/hle/service/server_manager.h" | 14 | #include "core/hle/service/server_manager.h" |
| 13 | 15 | ||
| 14 | namespace Service::PCTL { | 16 | namespace Service::PCTL { |
| 15 | 17 | ||
| 16 | namespace Error { | 18 | struct States { |
| 17 | 19 | u64 current_tid{}; | |
| 18 | constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101}; | 20 | ApplicationInfo application_info{}; |
| 19 | constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; | 21 | u64 tid_from_event{}; |
| 20 | constexpr Result ResultNoCapability{ErrorModule::PCTL, 131}; | 22 | bool launch_time_valid{}; |
| 21 | constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; | 23 | bool is_suspended{}; |
| 24 | bool temporary_unlocked{}; | ||
| 25 | bool free_communication{}; | ||
| 26 | bool stereo_vision{}; | ||
| 27 | }; | ||
| 22 | 28 | ||
| 23 | } // namespace Error | 29 | struct ParentalControlSettings { |
| 30 | bool is_stero_vision_restricted{}; | ||
| 31 | bool is_free_communication_default_on{}; | ||
| 32 | bool disabled{}; | ||
| 33 | }; | ||
| 24 | 34 | ||
| 25 | class IParentalControlService final : public ServiceFramework<IParentalControlService> { | 35 | class IParentalControlService final : public ServiceFramework<IParentalControlService> { |
| 26 | public: | 36 | public: |
| @@ -214,7 +224,7 @@ private: | |||
| 214 | states.free_communication = false; | 224 | states.free_communication = false; |
| 215 | states.stereo_vision = false; | 225 | states.stereo_vision = false; |
| 216 | states.application_info = ApplicationInfo{ | 226 | states.application_info = ApplicationInfo{ |
| 217 | .tid = tid, | 227 | .application_id = tid, |
| 218 | .age_rating = control.first->GetRatingAge(), | 228 | .age_rating = control.first->GetRatingAge(), |
| 219 | .parental_control_flag = control.first->GetParentalControlFlag(), | 229 | .parental_control_flag = control.first->GetParentalControlFlag(), |
| 220 | .capability = capability, | 230 | .capability = capability, |
| @@ -234,7 +244,7 @@ private: | |||
| 234 | 244 | ||
| 235 | IPC::ResponseBuilder rb{ctx, 2}; | 245 | IPC::ResponseBuilder rb{ctx, 2}; |
| 236 | if (!CheckFreeCommunicationPermissionImpl()) { | 246 | if (!CheckFreeCommunicationPermissionImpl()) { |
| 237 | rb.Push(Error::ResultNoFreeCommunication); | 247 | rb.Push(ResultNoFreeCommunication); |
| 238 | } else { | 248 | } else { |
| 239 | rb.Push(ResultSuccess); | 249 | rb.Push(ResultSuccess); |
| 240 | } | 250 | } |
| @@ -246,7 +256,7 @@ private: | |||
| 246 | LOG_WARNING(Service_PCTL, "(STUBBED) called"); | 256 | LOG_WARNING(Service_PCTL, "(STUBBED) called"); |
| 247 | 257 | ||
| 248 | IPC::ResponseBuilder rb{ctx, 2}; | 258 | IPC::ResponseBuilder rb{ctx, 2}; |
| 249 | rb.Push(Error::ResultNoFreeCommunication); | 259 | rb.Push(ResultNoFreeCommunication); |
| 250 | } | 260 | } |
| 251 | 261 | ||
| 252 | void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { | 262 | void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { |
| @@ -280,7 +290,7 @@ private: | |||
| 280 | 290 | ||
| 281 | IPC::ResponseBuilder rb{ctx, 2}; | 291 | IPC::ResponseBuilder rb{ctx, 2}; |
| 282 | if (!CheckFreeCommunicationPermissionImpl()) { | 292 | if (!CheckFreeCommunicationPermissionImpl()) { |
| 283 | rb.Push(Error::ResultNoFreeCommunication); | 293 | rb.Push(ResultNoFreeCommunication); |
| 284 | } else { | 294 | } else { |
| 285 | rb.Push(ResultSuccess); | 295 | rb.Push(ResultSuccess); |
| 286 | } | 296 | } |
| @@ -292,7 +302,7 @@ private: | |||
| 292 | IPC::ResponseBuilder rb{ctx, 3}; | 302 | IPC::ResponseBuilder rb{ctx, 3}; |
| 293 | if (False(capability & (Capability::Status | Capability::Recovery))) { | 303 | if (False(capability & (Capability::Status | Capability::Recovery))) { |
| 294 | LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); | 304 | LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); |
| 295 | rb.Push(Error::ResultNoCapability); | 305 | rb.Push(ResultNoCapability); |
| 296 | rb.Push(false); | 306 | rb.Push(false); |
| 297 | return; | 307 | return; |
| 298 | } | 308 | } |
| @@ -335,12 +345,12 @@ private: | |||
| 335 | 345 | ||
| 336 | if (False(capability & Capability::StereoVision)) { | 346 | if (False(capability & Capability::StereoVision)) { |
| 337 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); | 347 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); |
| 338 | rb.Push(Error::ResultNoCapability); | 348 | rb.Push(ResultNoCapability); |
| 339 | return; | 349 | return; |
| 340 | } | 350 | } |
| 341 | 351 | ||
| 342 | if (pin_code[0] == '\0') { | 352 | if (pin_code[0] == '\0') { |
| 343 | rb.Push(Error::ResultNoRestrictionEnabled); | 353 | rb.Push(ResultNoRestrictionEnabled); |
| 344 | return; | 354 | return; |
| 345 | } | 355 | } |
| 346 | 356 | ||
| @@ -352,7 +362,7 @@ private: | |||
| 352 | 362 | ||
| 353 | IPC::ResponseBuilder rb{ctx, 3}; | 363 | IPC::ResponseBuilder rb{ctx, 3}; |
| 354 | if (!ConfirmStereoVisionPermissionImpl()) { | 364 | if (!ConfirmStereoVisionPermissionImpl()) { |
| 355 | rb.Push(Error::ResultStereoVisionRestricted); | 365 | rb.Push(ResultStereoVisionRestricted); |
| 356 | rb.Push(false); | 366 | rb.Push(false); |
| 357 | } else { | 367 | } else { |
| 358 | rb.Push(ResultSuccess); | 368 | rb.Push(ResultSuccess); |
| @@ -423,7 +433,7 @@ private: | |||
| 423 | IPC::ResponseBuilder rb{ctx, 2}; | 433 | IPC::ResponseBuilder rb{ctx, 2}; |
| 424 | if (False(capability & Capability::StereoVision)) { | 434 | if (False(capability & Capability::StereoVision)) { |
| 425 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); | 435 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); |
| 426 | rb.Push(Error::ResultNoCapability); | 436 | rb.Push(ResultNoCapability); |
| 427 | return; | 437 | return; |
| 428 | } | 438 | } |
| 429 | 439 | ||
| @@ -437,7 +447,7 @@ private: | |||
| 437 | IPC::ResponseBuilder rb{ctx, 3}; | 447 | IPC::ResponseBuilder rb{ctx, 3}; |
| 438 | if (False(capability & Capability::StereoVision)) { | 448 | if (False(capability & Capability::StereoVision)) { |
| 439 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); | 449 | LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); |
| 440 | rb.Push(Error::ResultNoCapability); | 450 | rb.Push(ResultNoCapability); |
| 441 | rb.Push(false); | 451 | rb.Push(false); |
| 442 | return; | 452 | return; |
| 443 | } | 453 | } |
| @@ -455,44 +465,6 @@ private: | |||
| 455 | rb.Push(ResultSuccess); | 465 | rb.Push(ResultSuccess); |
| 456 | } | 466 | } |
| 457 | 467 | ||
| 458 | struct ApplicationInfo { | ||
| 459 | u64 tid{}; | ||
| 460 | std::array<u8, 32> age_rating{}; | ||
| 461 | u32 parental_control_flag{}; | ||
| 462 | Capability capability{}; | ||
| 463 | }; | ||
| 464 | |||
| 465 | struct States { | ||
| 466 | u64 current_tid{}; | ||
| 467 | ApplicationInfo application_info{}; | ||
| 468 | u64 tid_from_event{}; | ||
| 469 | bool launch_time_valid{}; | ||
| 470 | bool is_suspended{}; | ||
| 471 | bool temporary_unlocked{}; | ||
| 472 | bool free_communication{}; | ||
| 473 | bool stereo_vision{}; | ||
| 474 | }; | ||
| 475 | |||
| 476 | struct ParentalControlSettings { | ||
| 477 | bool is_stero_vision_restricted{}; | ||
| 478 | bool is_free_communication_default_on{}; | ||
| 479 | bool disabled{}; | ||
| 480 | }; | ||
| 481 | |||
| 482 | // This is nn::pctl::RestrictionSettings | ||
| 483 | struct RestrictionSettings { | ||
| 484 | u8 rating_age; | ||
| 485 | bool sns_post_restriction; | ||
| 486 | bool free_communication_restriction; | ||
| 487 | }; | ||
| 488 | static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size."); | ||
| 489 | |||
| 490 | // This is nn::pctl::PlayTimerSettings | ||
| 491 | struct PlayTimerSettings { | ||
| 492 | std::array<u32, 13> settings; | ||
| 493 | }; | ||
| 494 | static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size."); | ||
| 495 | |||
| 496 | States states{}; | 468 | States states{}; |
| 497 | ParentalControlSettings settings{}; | 469 | ParentalControlSettings settings{}; |
| 498 | RestrictionSettings restriction_settings{}; | 470 | RestrictionSettings restriction_settings{}; |
diff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.h index dff0d3f08..715c05b20 100644 --- a/src/core/hle/service/pctl/pctl_module.h +++ b/src/core/hle/service/pctl/pctl_module.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "common/common_funcs.h" | 6 | #include "core/hle/service/pctl/pctl_types.h" |
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | 8 | ||
| 9 | namespace Core { | 9 | namespace Core { |
| @@ -12,17 +12,6 @@ class System; | |||
| 12 | 12 | ||
| 13 | namespace Service::PCTL { | 13 | namespace Service::PCTL { |
| 14 | 14 | ||
| 15 | enum class Capability : u32 { | ||
| 16 | None = 0, | ||
| 17 | Application = 1 << 0, | ||
| 18 | SnsPost = 1 << 1, | ||
| 19 | Recovery = 1 << 6, | ||
| 20 | Status = 1 << 8, | ||
| 21 | StereoVision = 1 << 9, | ||
| 22 | System = 1 << 15, | ||
| 23 | }; | ||
| 24 | DECLARE_ENUM_FLAG_OPERATORS(Capability); | ||
| 25 | |||
| 26 | class Module final { | 15 | class Module final { |
| 27 | public: | 16 | public: |
| 28 | class Interface : public ServiceFramework<Interface> { | 17 | class Interface : public ServiceFramework<Interface> { |
diff --git a/src/core/hle/service/pctl/pctl_results.h b/src/core/hle/service/pctl/pctl_results.h new file mode 100644 index 000000000..1fc54727b --- /dev/null +++ b/src/core/hle/service/pctl/pctl_results.h | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/hle/result.h" | ||
| 7 | |||
| 8 | namespace Service::PCTL { | ||
| 9 | |||
| 10 | constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101}; | ||
| 11 | constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; | ||
| 12 | constexpr Result ResultNoCapability{ErrorModule::PCTL, 131}; | ||
| 13 | constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; | ||
| 14 | |||
| 15 | } // namespace Service::PCTL | ||
diff --git a/src/core/hle/service/pctl/pctl_types.h b/src/core/hle/service/pctl/pctl_types.h new file mode 100644 index 000000000..daaecdf48 --- /dev/null +++ b/src/core/hle/service/pctl/pctl_types.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_funcs.h" | ||
| 7 | |||
| 8 | namespace Service::PCTL { | ||
| 9 | |||
| 10 | enum class Capability : u32 { | ||
| 11 | None = 0, | ||
| 12 | Application = 1 << 0, | ||
| 13 | SnsPost = 1 << 1, | ||
| 14 | Recovery = 1 << 6, | ||
| 15 | Status = 1 << 8, | ||
| 16 | StereoVision = 1 << 9, | ||
| 17 | System = 1 << 15, | ||
| 18 | }; | ||
| 19 | DECLARE_ENUM_FLAG_OPERATORS(Capability); | ||
| 20 | |||
| 21 | struct ApplicationInfo { | ||
| 22 | u64 application_id{}; | ||
| 23 | std::array<u8, 32> age_rating{}; | ||
| 24 | u32 parental_control_flag{}; | ||
| 25 | Capability capability{}; | ||
| 26 | }; | ||
| 27 | static_assert(sizeof(ApplicationInfo) == 0x30, "ApplicationInfo has incorrect size."); | ||
| 28 | |||
| 29 | // This is nn::pctl::RestrictionSettings | ||
| 30 | struct RestrictionSettings { | ||
| 31 | u8 rating_age; | ||
| 32 | bool sns_post_restriction; | ||
| 33 | bool free_communication_restriction; | ||
| 34 | }; | ||
| 35 | static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size."); | ||
| 36 | |||
| 37 | // This is nn::pctl::PlayTimerSettings | ||
| 38 | struct PlayTimerSettings { | ||
| 39 | std::array<u32, 13> settings; | ||
| 40 | }; | ||
| 41 | static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size."); | ||
| 42 | |||
| 43 | } // namespace Service::PCTL | ||