pctl: move types and results

This commit is contained in:
Liam 2024-02-21 20:52:51 -05:00
parent e540757279
commit 01d89acd13
5 changed files with 88 additions and 67 deletions

View file

@ -897,6 +897,8 @@ add_library(core STATIC
hle/service/pctl/pctl.h hle/service/pctl/pctl.h
hle/service/pctl/pctl_module.cpp hle/service/pctl/pctl_module.cpp
hle/service/pctl/pctl_module.h hle/service/pctl/pctl_module.h
hle/service/pctl/pctl_results.h
hle/service/pctl/pctl_types.h
hle/service/pcv/pcv.cpp hle/service/pcv/pcv.cpp
hle/service/pcv/pcv.h hle/service/pcv/pcv.h
hle/service/pm/pm.cpp hle/service/pm/pm.cpp

View file

@ -9,18 +9,28 @@
#include "core/hle/service/kernel_helpers.h" #include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/pctl/pctl.h" #include "core/hle/service/pctl/pctl.h"
#include "core/hle/service/pctl/pctl_module.h" #include "core/hle/service/pctl/pctl_module.h"
#include "core/hle/service/pctl/pctl_results.h"
#include "core/hle/service/pctl/pctl_types.h"
#include "core/hle/service/server_manager.h" #include "core/hle/service/server_manager.h"
namespace Service::PCTL { namespace Service::PCTL {
namespace Error { struct States {
u64 current_tid{};
ApplicationInfo application_info{};
u64 tid_from_event{};
bool launch_time_valid{};
bool is_suspended{};
bool temporary_unlocked{};
bool free_communication{};
bool stereo_vision{};
};
constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101}; struct ParentalControlSettings {
constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; bool is_stero_vision_restricted{};
constexpr Result ResultNoCapability{ErrorModule::PCTL, 131}; bool is_free_communication_default_on{};
constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; bool disabled{};
};
} // namespace Error
class IParentalControlService final : public ServiceFramework<IParentalControlService> { class IParentalControlService final : public ServiceFramework<IParentalControlService> {
public: public:
@ -214,7 +224,7 @@ private:
states.free_communication = false; states.free_communication = false;
states.stereo_vision = false; states.stereo_vision = false;
states.application_info = ApplicationInfo{ states.application_info = ApplicationInfo{
.tid = tid, .application_id = tid,
.age_rating = control.first->GetRatingAge(), .age_rating = control.first->GetRatingAge(),
.parental_control_flag = control.first->GetParentalControlFlag(), .parental_control_flag = control.first->GetParentalControlFlag(),
.capability = capability, .capability = capability,
@ -234,7 +244,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
if (!CheckFreeCommunicationPermissionImpl()) { if (!CheckFreeCommunicationPermissionImpl()) {
rb.Push(Error::ResultNoFreeCommunication); rb.Push(ResultNoFreeCommunication);
} else { } else {
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} }
@ -246,7 +256,7 @@ private:
LOG_WARNING(Service_PCTL, "(STUBBED) called"); LOG_WARNING(Service_PCTL, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
rb.Push(Error::ResultNoFreeCommunication); rb.Push(ResultNoFreeCommunication);
} }
void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) {
@ -280,7 +290,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
if (!CheckFreeCommunicationPermissionImpl()) { if (!CheckFreeCommunicationPermissionImpl()) {
rb.Push(Error::ResultNoFreeCommunication); rb.Push(ResultNoFreeCommunication);
} else { } else {
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} }
@ -292,7 +302,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
if (False(capability & (Capability::Status | Capability::Recovery))) { if (False(capability & (Capability::Status | Capability::Recovery))) {
LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!");
rb.Push(Error::ResultNoCapability); rb.Push(ResultNoCapability);
rb.Push(false); rb.Push(false);
return; return;
} }
@ -335,12 +345,12 @@ private:
if (False(capability & Capability::StereoVision)) { if (False(capability & Capability::StereoVision)) {
LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!");
rb.Push(Error::ResultNoCapability); rb.Push(ResultNoCapability);
return; return;
} }
if (pin_code[0] == '\0') { if (pin_code[0] == '\0') {
rb.Push(Error::ResultNoRestrictionEnabled); rb.Push(ResultNoRestrictionEnabled);
return; return;
} }
@ -352,7 +362,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
if (!ConfirmStereoVisionPermissionImpl()) { if (!ConfirmStereoVisionPermissionImpl()) {
rb.Push(Error::ResultStereoVisionRestricted); rb.Push(ResultStereoVisionRestricted);
rb.Push(false); rb.Push(false);
} else { } else {
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
@ -423,7 +433,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
if (False(capability & Capability::StereoVision)) { if (False(capability & Capability::StereoVision)) {
LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!");
rb.Push(Error::ResultNoCapability); rb.Push(ResultNoCapability);
return; return;
} }
@ -437,7 +447,7 @@ private:
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
if (False(capability & Capability::StereoVision)) { if (False(capability & Capability::StereoVision)) {
LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!");
rb.Push(Error::ResultNoCapability); rb.Push(ResultNoCapability);
rb.Push(false); rb.Push(false);
return; return;
} }
@ -455,44 +465,6 @@ private:
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} }
struct ApplicationInfo {
u64 tid{};
std::array<u8, 32> age_rating{};
u32 parental_control_flag{};
Capability capability{};
};
struct States {
u64 current_tid{};
ApplicationInfo application_info{};
u64 tid_from_event{};
bool launch_time_valid{};
bool is_suspended{};
bool temporary_unlocked{};
bool free_communication{};
bool stereo_vision{};
};
struct ParentalControlSettings {
bool is_stero_vision_restricted{};
bool is_free_communication_default_on{};
bool disabled{};
};
// This is nn::pctl::RestrictionSettings
struct RestrictionSettings {
u8 rating_age;
bool sns_post_restriction;
bool free_communication_restriction;
};
static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size.");
// This is nn::pctl::PlayTimerSettings
struct PlayTimerSettings {
std::array<u32, 13> settings;
};
static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size.");
States states{}; States states{};
ParentalControlSettings settings{}; ParentalControlSettings settings{};
RestrictionSettings restriction_settings{}; RestrictionSettings restriction_settings{};

View file

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "common/common_funcs.h" #include "core/hle/service/pctl/pctl_types.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Core { namespace Core {
@ -12,17 +12,6 @@ class System;
namespace Service::PCTL { namespace Service::PCTL {
enum class Capability : u32 {
None = 0,
Application = 1 << 0,
SnsPost = 1 << 1,
Recovery = 1 << 6,
Status = 1 << 8,
StereoVision = 1 << 9,
System = 1 << 15,
};
DECLARE_ENUM_FLAG_OPERATORS(Capability);
class Module final { class Module final {
public: public:
class Interface : public ServiceFramework<Interface> { class Interface : public ServiceFramework<Interface> {

View file

@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/hle/result.h"
namespace Service::PCTL {
constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101};
constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104};
constexpr Result ResultNoCapability{ErrorModule::PCTL, 131};
constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181};
} // namespace Service::PCTL

View file

@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_funcs.h"
namespace Service::PCTL {
enum class Capability : u32 {
None = 0,
Application = 1 << 0,
SnsPost = 1 << 1,
Recovery = 1 << 6,
Status = 1 << 8,
StereoVision = 1 << 9,
System = 1 << 15,
};
DECLARE_ENUM_FLAG_OPERATORS(Capability);
struct ApplicationInfo {
u64 application_id{};
std::array<u8, 32> age_rating{};
u32 parental_control_flag{};
Capability capability{};
};
static_assert(sizeof(ApplicationInfo) == 0x30, "ApplicationInfo has incorrect size.");
// This is nn::pctl::RestrictionSettings
struct RestrictionSettings {
u8 rating_age;
bool sns_post_restriction;
bool free_communication_restriction;
};
static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size.");
// This is nn::pctl::PlayTimerSettings
struct PlayTimerSettings {
std::array<u32, 13> settings;
};
static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size.");
} // namespace Service::PCTL