Fix some network,npmanager issues (#1215)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions

* improved np toolkit callbacks

* added ExecuteGuest in callback

* clang format
This commit is contained in:
georgemoralis 2024-10-03 14:03:26 +03:00 committed by GitHub
parent 7209b7d786
commit ed24632ceb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 19 deletions

View file

@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <common/singleton.h>
#include <core/linker.h>
#include "common/config.h" #include "common/config.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/libraries/error_codes.h" #include "core/libraries/error_codes.h"
@ -874,19 +876,6 @@ int PS4_SYSV_ABI sceNpCheckCallback() {
return ORBIS_OK; return ORBIS_OK;
} }
struct NpStateCallbackForNpToolkit {
OrbisNpStateCallbackForNpToolkit func;
void* userdata;
};
NpStateCallbackForNpToolkit NpStateCbForNp;
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
// LOG_ERROR(Lib_NpManager, "(STUBBED) called");
NpStateCbForNp.func(0, ORBIS_NP_STATE_SIGNED_OUT, NpStateCbForNp.userdata);
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNpCheckNpAvailability() { int PS4_SYSV_ABI sceNpCheckNpAvailability() {
LOG_ERROR(Lib_NpManager, "(STUBBED) called"); LOG_ERROR(Lib_NpManager, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -983,9 +972,10 @@ int PS4_SYSV_ABI sceNpGetGamePresenceStatusA() {
} }
int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId userId, OrbisNpId* npId) { int PS4_SYSV_ABI sceNpGetNpId(OrbisUserServiceUserId userId, OrbisNpId* npId) {
LOG_ERROR(Lib_NpManager, "(DUMMY) called"); LOG_INFO(Lib_NpManager, "userId {}", userId);
std::string name = Config::getUserName(); std::string name = Config::getUserName();
// Fill the unused stuffs to 0
memset(npId, 0, sizeof(*npId));
strcpy(npId->handle.data, name.c_str()); strcpy(npId->handle.data, name.c_str());
return ORBIS_OK; return ORBIS_OK;
} }
@ -1010,8 +1000,9 @@ int PS4_SYSV_ABI sceNpGetParentalControlInfoA() {
return ORBIS_OK; return ORBIS_OK;
} }
int PS4_SYSV_ABI sceNpGetState() { int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state) {
LOG_ERROR(Lib_NpManager, "(STUBBED) called"); *state = ORBIS_NP_STATE_SIGNED_OUT;
LOG_DEBUG(Lib_NpManager, "Signed out");
return ORBIS_OK; return ORBIS_OK;
} }
@ -2515,12 +2506,28 @@ int PS4_SYSV_ABI Func_FF966E4351E564D6() {
return ORBIS_OK; return ORBIS_OK;
} }
struct NpStateCallbackForNpToolkit {
OrbisNpStateCallbackForNpToolkit func;
void* userdata;
};
NpStateCallbackForNpToolkit NpStateCbForNp;
int PS4_SYSV_ABI sceNpCheckCallbackForLib() {
// LOG_ERROR(Lib_NpManager, "(STUBBED) called");
const auto* linker = Common::Singleton<Core::Linker>::Instance();
linker->ExecuteGuest(NpStateCbForNp.func, 1, ORBIS_NP_STATE_SIGNED_OUT,
NpStateCbForNp.userdata);
return ORBIS_OK;
}
int PS4_SYSV_ABI sceNpRegisterStateCallbackForToolkit(OrbisNpStateCallbackForNpToolkit callback, int PS4_SYSV_ABI sceNpRegisterStateCallbackForToolkit(OrbisNpStateCallbackForNpToolkit callback,
void* userdata) { void* userdata) {
static int id = 0;
LOG_ERROR(Lib_NpManager, "(STUBBED) called"); LOG_ERROR(Lib_NpManager, "(STUBBED) called");
NpStateCbForNp.func = callback; NpStateCbForNp.func = callback;
NpStateCbForNp.userdata = userdata; NpStateCbForNp.userdata = userdata;
return 1; return id;
} }
int PS4_SYSV_ABI sceNpUnregisterStateCallbackForToolkit() { int PS4_SYSV_ABI sceNpUnregisterStateCallbackForToolkit() {

View file

@ -11,6 +11,8 @@ class SymbolsResolver;
namespace Libraries::NpManager { namespace Libraries::NpManager {
constexpr int ORBIS_NP_ERROR_SIGNED_OUT = 0x80550006;
enum OrbisNpState { enum OrbisNpState {
ORBIS_NP_STATE_UNKNOWN = 0, ORBIS_NP_STATE_UNKNOWN = 0,
ORBIS_NP_STATE_SIGNED_OUT, ORBIS_NP_STATE_SIGNED_OUT,
@ -234,7 +236,7 @@ int PS4_SYSV_ABI sceNpGetNpReachabilityState();
int PS4_SYSV_ABI sceNpGetOnlineId(); int PS4_SYSV_ABI sceNpGetOnlineId();
int PS4_SYSV_ABI sceNpGetParentalControlInfo(); int PS4_SYSV_ABI sceNpGetParentalControlInfo();
int PS4_SYSV_ABI sceNpGetParentalControlInfoA(); int PS4_SYSV_ABI sceNpGetParentalControlInfoA();
int PS4_SYSV_ABI sceNpGetState(); int PS4_SYSV_ABI sceNpGetState(s32 userId, OrbisNpState* state);
int PS4_SYSV_ABI sceNpGetUserIdByAccountId(); int PS4_SYSV_ABI sceNpGetUserIdByAccountId();
int PS4_SYSV_ABI sceNpGetUserIdByOnlineId(); int PS4_SYSV_ABI sceNpGetUserIdByOnlineId();
int PS4_SYSV_ABI sceNpHasSignedUp(); int PS4_SYSV_ABI sceNpHasSignedUp();