[APT] Add inquireNotification/setScreencapPermission

This commit is contained in:
wheremyfoodat 2023-01-03 22:02:12 +02:00
parent 9396b1ec9c
commit 70dd8b2e9d
2 changed files with 39 additions and 0 deletions

View file

@ -27,14 +27,33 @@ class APTService {
void checkNew3DSApp(u32 messagePointer);
void enable(u32 messagePointer);
void initialize(u32 messagePointer);
void inquireNotification(u32 messagePointer);
void notifyToWait(u32 messagePointer);
void receiveParameter(u32 messagePointer);
void replySleepQuery(u32 messagePointer);
void setApplicationCpuTimeLimit(u32 messagePointer);
void setScreencapPostPermission(u32 messagePointer);
// Percentage of the syscore available to the application, between 5% and 89%
u32 cpuTimeLimit;
enum class NotificationType : u32 {
None = 0,
HomeButton1 = 1,
HomeButton2 = 2,
SleepQuery = 3,
SleepCanceledByOpen = 4,
SleepAccepted = 5,
SleepAwake = 6,
Shutdown = 7,
PowerButtonClick = 8,
PowerButtonClear = 9,
TrySleep = 10,
OrderToClose = 11
};
u32 screencapPostPermission;
public:
APTService(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
void reset();

View file

@ -6,12 +6,14 @@ namespace APTCommands {
GetLockHandle = 0x00010040,
Initialize = 0x00020080,
Enable = 0x00030040,
InquireNotification = 0x000B0040,
ReceiveParameter = 0x000D0080,
ReplySleepQuery = 0x003E0080,
NotifyToWait = 0x00430040,
AppletUtility = 0x004B00C2,
SetApplicationCpuTimeLimit = 0x004F0080,
GetApplicationCpuTimeLimit = 0x00500040,
SetScreencapPostPermission = 0x00550040,
CheckNew3DSApp = 0x01010000,
CheckNew3DS = 0x01020000
};
@ -49,12 +51,14 @@ void APTService::handleSyncRequest(u32 messagePointer) {
case APTCommands::CheckNew3DSApp: checkNew3DSApp(messagePointer); break;
case APTCommands::Enable: enable(messagePointer); break;
case APTCommands::Initialize: initialize(messagePointer); break;
case APTCommands::InquireNotification: inquireNotification(messagePointer); break;
case APTCommands::GetApplicationCpuTimeLimit: getApplicationCpuTimeLimit(messagePointer); break;
case APTCommands::GetLockHandle: getLockHandle(messagePointer); break;
case APTCommands::NotifyToWait: notifyToWait(messagePointer); break;
case APTCommands::ReceiveParameter: receiveParameter(messagePointer); break;
case APTCommands::ReplySleepQuery: replySleepQuery(messagePointer); break;
case APTCommands::SetApplicationCpuTimeLimit: setApplicationCpuTimeLimit(messagePointer); break;
case APTCommands::SetScreencapPostPermission: setScreencapPostPermission(messagePointer); break;
default: Helpers::panic("APT service requested. Command: %08X\n", command);
}
}
@ -99,6 +103,13 @@ void APTService::initialize(u32 messagePointer) {
mem.write32(messagePointer + 16, resumeEvent.value()); // Resume Event Handle
}
void APTService::inquireNotification(u32 messagePointer) {
log("APT::InquireNotification\n");
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, static_cast<u32>(NotificationType::None));
}
void APTService::getLockHandle(u32 messagePointer) {
log("APT::GetLockHandle\n");
@ -159,4 +170,13 @@ void APTService::getApplicationCpuTimeLimit(u32 messagePointer) {
log("APT::GetApplicationCpuTimeLimit\n");
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, cpuTimeLimit);
}
void APTService::setScreencapPostPermission(u32 messagePointer) {
u32 perm = mem.read32(messagePointer + 4);
log("APT::SetScreencapPostPermission (perm = %d)\n");
// Apparently only 1-3 are valid values, but I see 0 used in some games like Pokemon Rumble
mem.write32(messagePointer, Result::Success);
screencapPostPermission = perm;
}