mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(userservice): implement foreground user, registered list, user colour and NP account id
Four exports that titles call during start-up were missing. They now follow the single-user / offline model already used in this file (sceUserServiceGetInitialUser, sceUserServiceGetLoginUserIdList, sceUserServiceGetPlatformPrivacyWs1): - sceUserServiceGetForegroundUser(int*) -> the initial user - sceUserServiceGetRegisteredUserIdList(UserServiceRegisteredUserIdList*) -> initial user in slot 0, the other 15 slots invalid - sceUserServiceGetUserColor(int, int*) -> blue (0) - sceUserServiceGetNpAccountId(int, uint64_t*) -> 0 (no PSN account linked) Adds UserServiceRegisteredUserIdList (int[16]) to SceTypes.hpp and a CMakeLists.txt so the library can carry its guest test. Signatures follow the public OpenOrbis SDK headers. New test core/libs/tests/GuestUserService.cpp checks the valid returns, the pointer and wrong-user-id error paths; it fails without the change (the symbols are undefined) and passes with it.
This commit is contained in:
@@ -1729,6 +1729,8 @@ struct SystemGestureTouchEvent { std::uint8_t reserve[168]; };
|
||||
|
||||
struct UserServiceLoginUserIdList { int user_id[4]; };
|
||||
|
||||
struct UserServiceRegisteredUserIdList { int user_id[16]; };
|
||||
|
||||
struct SceUserServiceEvent {
|
||||
std::uint32_t event_type;
|
||||
int user_id;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
add_library(libSceUserService SHARED EXCLUDE_FROM_ALL Export.cpp)
|
||||
target_include_directories(libSceUserService PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
configure_windows_unwind(libSceUserService)
|
||||
|
||||
if(MINGW)
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test_executable(guest_user_service_tests ${LIBS_INCLUDE_DIR}/tests/GuestUserService.cpp)
|
||||
target_include_directories(guest_user_service_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_user_service_tests PRIVATE libSceUserService)
|
||||
add_test(NAME guest_user_service COMMAND guest_user_service_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_user_service PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceUserService>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -156,4 +156,39 @@ int APS5_VABI sceUserServiceGetPlatformPrivacyWs1(int32_t user_id, int32_t* valu
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI sceUserServiceGetForegroundUser(int* user_id) {
|
||||
if (user_id == nullptr) {
|
||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
*user_id = USER_SERVICE_INITIAL_USER_ID;
|
||||
return USER_SERVICE_OK;
|
||||
}
|
||||
|
||||
int APS5_VABI sceUserServiceGetRegisteredUserIdList(UserServiceRegisteredUserIdList* user_id_list) {
|
||||
if (user_id_list == nullptr) {
|
||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
user_id_list->user_id[0] = USER_SERVICE_INITIAL_USER_ID;
|
||||
for (int i = 1; i < 16; ++i) {
|
||||
user_id_list->user_id[i] = USER_SERVICE_USER_ID_INVALID;
|
||||
}
|
||||
return USER_SERVICE_OK;
|
||||
}
|
||||
|
||||
int APS5_VABI sceUserServiceGetUserColor(int user_id, int* color) {
|
||||
if (color == nullptr || user_id != USER_SERVICE_INITIAL_USER_ID) {
|
||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
*color = 0;
|
||||
return USER_SERVICE_OK;
|
||||
}
|
||||
|
||||
int APS5_VABI sceUserServiceGetNpAccountId(int user_id, uint64_t* account_id) {
|
||||
if (account_id == nullptr || user_id != USER_SERVICE_INITIAL_USER_ID) {
|
||||
return USER_SERVICE_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
*account_id = 0;
|
||||
return USER_SERVICE_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libSceUserService/UserService.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
int APS5_VABI sceUserServiceGetForegroundUser(int* user_id);
|
||||
int APS5_VABI sceUserServiceGetRegisteredUserIdList(UserServiceRegisteredUserIdList* user_id_list);
|
||||
int APS5_VABI sceUserServiceGetUserColor(int user_id, int* color);
|
||||
int APS5_VABI sceUserServiceGetNpAccountId(int user_id, std::uint64_t* account_id);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void Require(bool value) { if (!value) std::abort(); }
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
Require(sceUserServiceGetForegroundUser(nullptr) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
int foreground = -1;
|
||||
Require(sceUserServiceGetForegroundUser(&foreground) == USER_SERVICE_OK);
|
||||
Require(foreground == USER_SERVICE_INITIAL_USER_ID);
|
||||
|
||||
Require(sceUserServiceGetRegisteredUserIdList(nullptr) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
UserServiceRegisteredUserIdList registered{};
|
||||
Require(sceUserServiceGetRegisteredUserIdList(®istered) == USER_SERVICE_OK);
|
||||
Require(registered.user_id[0] == USER_SERVICE_INITIAL_USER_ID);
|
||||
for (int i = 1; i < 16; ++i) {
|
||||
Require(registered.user_id[i] == USER_SERVICE_USER_ID_INVALID);
|
||||
}
|
||||
|
||||
int color = -1;
|
||||
Require(sceUserServiceGetUserColor(USER_SERVICE_INITIAL_USER_ID, nullptr) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
Require(sceUserServiceGetUserColor(123, &color) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
Require(sceUserServiceGetUserColor(USER_SERVICE_INITIAL_USER_ID, &color) == USER_SERVICE_OK);
|
||||
Require(color == 0);
|
||||
|
||||
std::uint64_t account_id = 0xdeadbeefu;
|
||||
Require(sceUserServiceGetNpAccountId(USER_SERVICE_INITIAL_USER_ID, nullptr) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
Require(sceUserServiceGetNpAccountId(123, &account_id) == USER_SERVICE_ERROR_INVALID_ARGUMENT);
|
||||
Require(sceUserServiceGetNpAccountId(USER_SERVICE_INITIAL_USER_ID, &account_id) == USER_SERVICE_OK);
|
||||
Require(account_id == 0);
|
||||
}
|
||||
Reference in New Issue
Block a user