Skip to content

Commit

Permalink
dummy implement user service event
Browse files Browse the repository at this point in the history
fix nier doesn't read pad
  • Loading branch information
Inori committed May 14, 2022
1 parent 1466ffc commit 9aa2448
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions GPCS4/GPCS4.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
<ClInclude Include="SceModules\SceNet\sce_net.h" />
<ClInclude Include="SceModules\SceNpCommerce\sce_npcommerce.h" />
<ClInclude Include="SceModules\SceNpCommon\sce_npcommon.h" />
<ClInclude Include="SceModules\SceNpCommon\sce_npcommon_types.h" />
<ClInclude Include="SceModules\SceNpManager\sce_npmanager.h" />
<ClInclude Include="SceModules\SceNpMatching2\sce_npmatching2.h" />
<ClInclude Include="SceModules\SceNpProfileDialog\sce_npprofiledialog.h" />
Expand Down
3 changes: 3 additions & 0 deletions GPCS4/GPCS4.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,9 @@
<ClInclude Include="Graphics\Sce\SceLabelManager.h">
<Filter>Source Files\Graphics\Sce</Filter>
</ClInclude>
<ClInclude Include="SceModules\SceNpCommon\sce_npcommon_types.h">
<Filter>SceModules\SceNpCommon</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Loader\EbootObject.cpp">
Expand Down
22 changes: 22 additions & 0 deletions GPCS4/SceModules/SceNpCommon/sce_npcommon_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "GPCS4Common.h"

#define SCE_NP_ONLINEID_MIN_LENGTH 3
#define SCE_NP_ONLINEID_MAX_LENGTH 16

/* Online ID */
typedef struct SceNpOnlineId
{
char data[SCE_NP_ONLINEID_MAX_LENGTH];
char term;
char dummy[3];
} SceNpOnlineId;

/* NP ID */
typedef struct SceNpId
{
SceNpOnlineId handle;
uint8_t opt[8];
uint8_t reserved[8];
} SceNpId;
11 changes: 9 additions & 2 deletions GPCS4/SceModules/SceNpManager/sce_npmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ int PS4API sceNpDeleteRequest(void)
}


int PS4API sceNpGetNpId(void)
int PS4API sceNpGetNpId(SceUserServiceUserId userId, SceNpId* npId)
{
LOG_FIXME("Not implemented");
LOG_SCE_DUMMY_IMPL();
LOG_SCE_TRACE("userId %x", userId);

LOG_ASSERT(std::strlen(GPCS4_APP_NAME) < SCE_NP_ONLINEID_MAX_LENGTH, "app name too long.");
std::memset(npId, 0, sizeof(SceNpId));
std::strcpy(npId->handle.data, GPCS4_APP_NAME);
npId->handle.term = '\0';

return SCE_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion GPCS4/SceModules/SceNpManager/sce_npmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "sce_module_common.h"
#include "../SceNpCommon/sce_npcommon_types.h"


extern const SCE_EXPORT_MODULE g_ExpModuleSceNpManager;
Expand Down Expand Up @@ -46,7 +47,7 @@ int PS4API sceNpCreateAsyncRequest(void);
int PS4API sceNpDeleteRequest(void);


int PS4API sceNpGetNpId(void);
int PS4API sceNpGetNpId(SceUserServiceUserId userId, SceNpId* npId);


int PS4API sceNpGetOnlineId(void);
Expand Down
18 changes: 15 additions & 3 deletions GPCS4/SceModules/SceUserService/sce_userservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,21 @@ int PS4API sceUserServiceGetUserName(const SceUserServiceUserId userId, char *us
int PS4API sceUserServiceGetEvent(SceUserServiceEvent* event)
{
LOG_SCE_TRACE("event %p", event);
event->eventType = SCE_USER_SERVICE_EVENT_TYPE_LOGIN;
event->userId = SCE_DUMMY_USERID;
return SCE_USER_SERVICE_ERROR_NO_EVENT;

static bool firstEvent = true;

int ret = SCE_USER_SERVICE_ERROR_NO_EVENT;
// We should at least queue one login event even
// if there's no user login happened.
if (firstEvent)
{
event->eventType = SCE_USER_SERVICE_EVENT_TYPE_LOGIN;
event->userId = SCE_DUMMY_USERID;
ret = SCE_OK;
firstEvent = false;
}

return ret;
}

int PS4API sceUserServiceGetLoginUserIdList(SceUserServiceLoginUserIdList* userIdList)
Expand Down

0 comments on commit 9aa2448

Please sign in to comment.