Merge pull request #206 from wheremyfoodat/services

FRD and AC stuff
This commit is contained in:
wheremyfoodat 2023-08-19 17:35:33 +03:00 committed by GitHub
commit 3f98b200d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 1 deletions

View file

@ -12,6 +12,7 @@ class ACService {
// Service commands
void cancelConnectAsync(u32 messagePointer);
void closeAsync(u32 messagePointer);
void createDefaultConfig(u32 messagePointer);
void getLastErrorCode(u32 messagePointer);
void setClientVersion(u32 messagePointer);

View file

@ -19,6 +19,8 @@ class FRDService {
Memory& mem;
MAKE_LOG_FUNCTION(log, frdLogger)
bool loggedIn = false;
// Service commands
void attachToEventNotification(u32 messagePointer);
void getFriendKeyList(u32 messagePointer);
@ -27,6 +29,8 @@ class FRDService {
void getMyPresence(u32 messagePointer);
void getMyProfile(u32 messagePointer);
void getMyScreenName(u32 messsagePointer);
void hasLoggedIn(u32 messagePointer);
void logout(u32 messagePointer);
void setClientSDKVersion(u32 messagePointer);
void setNotificationMask(u32 messagePointer);
void updateGameModeDescription(u32 messagePointer);

View file

@ -5,6 +5,7 @@ namespace ACCommands {
enum : u32 {
CreateDefaultConfig = 0x00010000,
CancelConnectAsync = 0x00070002,
CloseAsync = 0x00080004,
GetLastErrorCode = 0x000A0000,
SetClientVersion = 0x00400042,
};
@ -16,6 +17,7 @@ void ACService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
switch (command) {
case ACCommands::CancelConnectAsync: cancelConnectAsync(messagePointer); break;
case ACCommands::CloseAsync: closeAsync(messagePointer); break;
case ACCommands::CreateDefaultConfig: createDefaultConfig(messagePointer); break;
case ACCommands::GetLastErrorCode: getLastErrorCode(messagePointer); break;
case ACCommands::SetClientVersion: setClientVersion(messagePointer); break;
@ -31,6 +33,14 @@ void ACService::cancelConnectAsync(u32 messagePointer) {
mem.write32(messagePointer + 4, Result::Success);
}
void ACService::closeAsync(u32 messagePointer) {
log("AC::CloseAsync (stubbed)\n");
// TODO: Verify if this response header is correct on hardware
mem.write32(messagePointer, IPC::responseHeader(0x8, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
}
void ACService::createDefaultConfig(u32 messagePointer) {
log("AC::CreateDefaultConfig (stubbed)\n");

View file

@ -7,9 +7,11 @@
namespace FRDCommands {
enum : u32 {
HasLoggedIn = 0x00010000,
AttachToEventNotification = 0x00200002,
SetNotificationMask = 0x00210040,
SetClientSdkVersion = 0x00320042,
Logout = 0x00040000,
GetMyFriendKey = 0x00050000,
GetMyProfile = 0x00070000,
GetMyPresence = 0x00080000,
@ -20,7 +22,7 @@ namespace FRDCommands {
};
}
void FRDService::reset() {}
void FRDService::reset() { loggedIn = false; }
void FRDService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
@ -32,6 +34,8 @@ void FRDService::handleSyncRequest(u32 messagePointer) {
case FRDCommands::GetMyPresence: getMyPresence(messagePointer); break;
case FRDCommands::GetMyProfile: getMyProfile(messagePointer); break;
case FRDCommands::GetMyScreenName: getMyScreenName(messagePointer); break;
case FRDCommands::HasLoggedIn: hasLoggedIn(messagePointer); break;
case FRDCommands::Logout: logout(messagePointer); break;
case FRDCommands::SetClientSdkVersion: setClientSDKVersion(messagePointer); break;
case FRDCommands::SetNotificationMask: setNotificationMask(messagePointer); break;
case FRDCommands::UpdateGameModeDescription: updateGameModeDescription(messagePointer); break;
@ -146,4 +150,20 @@ void FRDService::getMyMii(u32 messagePointer) {
// TODO: How is the mii data even returned?
mem.write32(messagePointer, IPC::responseHeader(0xA, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
}
void FRDService::hasLoggedIn(u32 messagePointer) {
log("FRD::HasLoggedIn\n");
mem.write32(messagePointer, IPC::responseHeader(0x1, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write8(messagePointer + 8, loggedIn ? 1 : 0);
}
void FRDService::logout(u32 messagePointer) {
log("FRD::Logout\n");
loggedIn = false;
mem.write32(messagePointer, IPC::responseHeader(0x4, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
}